aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/Kconfig20
-rw-r--r--arch/powerpc/Makefile18
-rw-r--r--arch/powerpc/boot/.gitignore1
-rw-r--r--arch/powerpc/boot/dts/ac14xx.dts2
-rw-r--r--arch/powerpc/boot/dts/b4420qds.dts2
-rw-r--r--arch/powerpc/boot/dts/b4860qds.dts2
-rw-r--r--arch/powerpc/boot/dts/b4qds.dtsi (renamed from arch/powerpc/boot/dts/b4qds.dts)0
-rw-r--r--arch/powerpc/boot/dts/c293pcie.dts223
-rw-r--r--arch/powerpc/boot/dts/fsl/b4si-post.dtsi2
-rw-r--r--arch/powerpc/boot/dts/fsl/c293si-post.dtsi193
-rw-r--r--arch/powerpc/boot/dts/fsl/c293si-pre.dtsi63
-rw-r--r--arch/powerpc/boot/dts/fsl/qoriq-mpic4.3.dtsi149
-rw-r--r--arch/powerpc/boot/dts/fsl/qoriq-sec6.0-0.dtsi56
-rw-r--r--arch/powerpc/boot/dts/fsl/t4240si-post.dtsi2
l---------arch/powerpc/boot/dts/include/dt-bindings1
-rw-r--r--arch/powerpc/boot/dts/mpc5121ads.dts2
-rw-r--r--arch/powerpc/boot/dts/p1020rdb-pd.dts280
-rw-r--r--arch/powerpc/boot/dts/p1023rdb.dts234
-rw-r--r--arch/powerpc/boot/dts/pdm360ng.dts2
-rw-r--r--arch/powerpc/boot/ppc_asm.h3
-rw-r--r--arch/powerpc/boot/util.S10
-rw-r--r--arch/powerpc/configs/85xx/p1023_defconfig (renamed from arch/powerpc/configs/85xx/p1023rds_defconfig)25
-rw-r--r--arch/powerpc/configs/corenet32_smp_defconfig1
-rw-r--r--arch/powerpc/configs/corenet64_smp_defconfig3
-rw-r--r--arch/powerpc/configs/mpc83xx_defconfig1
-rw-r--r--arch/powerpc/configs/mpc85xx_defconfig2
-rw-r--r--arch/powerpc/configs/mpc85xx_smp_defconfig2
-rw-r--r--arch/powerpc/include/asm/asm-compat.h9
-rw-r--r--arch/powerpc/include/asm/btext.h1
-rw-r--r--arch/powerpc/include/asm/cacheflush.h8
-rw-r--r--arch/powerpc/include/asm/cputable.h9
-rw-r--r--arch/powerpc/include/asm/emulated_ops.h2
-rw-r--r--arch/powerpc/include/asm/epapr_hcalls.h6
-rw-r--r--arch/powerpc/include/asm/exception-64s.h35
-rw-r--r--arch/powerpc/include/asm/io.h33
-rw-r--r--arch/powerpc/include/asm/irqflags.h7
-rw-r--r--arch/powerpc/include/asm/lppaca.h68
-rw-r--r--arch/powerpc/include/asm/mpc5121.h18
-rw-r--r--arch/powerpc/include/asm/mpc85xx.h92
-rw-r--r--arch/powerpc/include/asm/mpic.h7
-rw-r--r--arch/powerpc/include/asm/opal.h27
-rw-r--r--arch/powerpc/include/asm/paca.h11
-rw-r--r--arch/powerpc/include/asm/pci-bridge.h2
-rw-r--r--arch/powerpc/include/asm/perf_event_fsl_emb.h2
-rw-r--r--arch/powerpc/include/asm/plpar_wrappers.h (renamed from arch/powerpc/platforms/pseries/plpar_wrappers.h)30
-rw-r--r--arch/powerpc/include/asm/ppc-opcode.h47
-rw-r--r--arch/powerpc/include/asm/ppc_asm.h22
-rw-r--r--arch/powerpc/include/asm/prom.h7
-rw-r--r--arch/powerpc/include/asm/reg.h29
-rw-r--r--arch/powerpc/include/asm/reg_booke.h8
-rw-r--r--arch/powerpc/include/asm/reg_fsl_emb.h24
-rw-r--r--arch/powerpc/include/asm/rtas.h8
-rw-r--r--arch/powerpc/include/asm/smp.h3
-rw-r--r--arch/powerpc/include/asm/spinlock.h6
-rw-r--r--arch/powerpc/include/asm/switch_to.h11
-rw-r--r--arch/powerpc/include/asm/timex.h4
-rw-r--r--arch/powerpc/include/asm/topology.h1
-rw-r--r--arch/powerpc/include/asm/udbg.h9
-rw-r--r--arch/powerpc/include/uapi/asm/elf.h21
-rw-r--r--arch/powerpc/kernel/Makefile5
-rw-r--r--arch/powerpc/kernel/align.c14
-rw-r--r--arch/powerpc/kernel/btext.c254
-rw-r--r--arch/powerpc/kernel/cacheinfo.c12
-rw-r--r--arch/powerpc/kernel/cpu_setup_fsl_booke.S2
-rw-r--r--arch/powerpc/kernel/cputable.c2
-rw-r--r--arch/powerpc/kernel/entry_64.S46
-rw-r--r--arch/powerpc/kernel/epapr_paravirt.c28
-rw-r--r--arch/powerpc/kernel/exceptions-64e.S4
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S39
-rw-r--r--arch/powerpc/kernel/head_40x.S8
-rw-r--r--arch/powerpc/kernel/head_44x.S10
-rw-r--r--arch/powerpc/kernel/head_64.S1
-rw-r--r--arch/powerpc/kernel/head_8xx.S4
-rw-r--r--arch/powerpc/kernel/head_fsl_booke.S10
-rw-r--r--arch/powerpc/kernel/io-workarounds.c19
-rw-r--r--arch/powerpc/kernel/io.c3
-rw-r--r--arch/powerpc/kernel/legacy_serial.c62
-rw-r--r--arch/powerpc/kernel/misc_32.S3
-rw-r--r--arch/powerpc/kernel/misc_64.S50
-rw-r--r--arch/powerpc/kernel/paca.c10
-rw-r--r--arch/powerpc/kernel/pci-common.c13
-rw-r--r--arch/powerpc/kernel/pci_64.c4
-rw-r--r--arch/powerpc/kernel/pci_dn.c20
-rw-r--r--arch/powerpc/kernel/pci_of_scan.c23
-rw-r--r--arch/powerpc/kernel/ppc_ksyms.c3
-rw-r--r--arch/powerpc/kernel/process.c2
-rw-r--r--arch/powerpc/kernel/prom.c82
-rw-r--r--arch/powerpc/kernel/prom_init.c269
-rw-r--r--arch/powerpc/kernel/prom_init_check.sh3
-rw-r--r--arch/powerpc/kernel/prom_parse.c17
-rw-r--r--arch/powerpc/kernel/rtas.c66
-rw-r--r--arch/powerpc/kernel/setup-common.c13
-rw-r--r--arch/powerpc/kernel/setup_32.c4
-rw-r--r--arch/powerpc/kernel/setup_64.c36
-rw-r--r--arch/powerpc/kernel/signal_32.c9
-rw-r--r--arch/powerpc/kernel/signal_64.c18
-rw-r--r--arch/powerpc/kernel/smp.c156
-rw-r--r--arch/powerpc/kernel/softemu8xx.c199
-rw-r--r--arch/powerpc/kernel/swsusp_asm64.S45
-rw-r--r--arch/powerpc/kernel/swsusp_booke.S8
-rw-r--r--arch/powerpc/kernel/time.c18
-rw-r--r--arch/powerpc/kernel/tm.S4
-rw-r--r--arch/powerpc/kernel/traps.c111
-rw-r--r--arch/powerpc/kernel/udbg_16550.c370
-rw-r--r--arch/powerpc/kernel/vdso32/gettimeofday.S6
-rw-r--r--arch/powerpc/kernel/vio.c33
-rw-r--r--arch/powerpc/kvm/book3s_64_slb.S4
-rw-r--r--arch/powerpc/kvm/book3s_hv.c2
-rw-r--r--arch/powerpc/kvm/book3s_hv_rm_mmu.c4
-rw-r--r--arch/powerpc/kvm/book3s_hv_rmhandlers.S12
-rw-r--r--arch/powerpc/kvm/emulate.c45
-rw-r--r--arch/powerpc/lib/locks.c4
-rw-r--r--arch/powerpc/lib/sstep.c8
-rw-r--r--arch/powerpc/math-emu/Makefile24
-rw-r--r--arch/powerpc/math-emu/math.c89
-rw-r--r--arch/powerpc/mm/fault.c6
-rw-r--r--arch/powerpc/mm/gup.c37
-rw-r--r--arch/powerpc/mm/hash_utils_64.c2
-rw-r--r--arch/powerpc/mm/mem.c2
-rw-r--r--arch/powerpc/mm/numa.c102
-rw-r--r--arch/powerpc/mm/slb.c9
-rw-r--r--arch/powerpc/mm/subpage-prot.c4
-rw-r--r--arch/powerpc/oprofile/op_model_fsl_emb.c30
-rw-r--r--arch/powerpc/perf/Makefile2
-rw-r--r--arch/powerpc/perf/core-book3s.c2
-rw-r--r--arch/powerpc/perf/core-fsl-emb.c30
-rw-r--r--arch/powerpc/perf/e6500-pmu.c121
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_pic.c3
-rw-r--r--arch/powerpc/platforms/85xx/Kconfig10
-rw-r--r--arch/powerpc/platforms/85xx/Makefile1
-rw-r--r--arch/powerpc/platforms/85xx/c293pcie.c75
-rw-r--r--arch/powerpc/platforms/85xx/corenet_ds.c6
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_rdb.c22
-rw-r--r--arch/powerpc/platforms/85xx/p1023_rds.c24
-rw-r--r--arch/powerpc/platforms/85xx/smp.c26
-rw-r--r--arch/powerpc/platforms/Kconfig7
-rw-r--r--arch/powerpc/platforms/Kconfig.cputype13
-rw-r--r--arch/powerpc/platforms/cell/iommu.c2
-rw-r--r--arch/powerpc/platforms/cell/smp.c15
-rw-r--r--arch/powerpc/platforms/powernv/Kconfig2
-rw-r--r--arch/powerpc/platforms/powernv/Makefile2
-rw-r--r--arch/powerpc/platforms/powernv/eeh-ioda.c22
-rw-r--r--arch/powerpc/platforms/powernv/opal-lpc.c203
-rw-r--r--arch/powerpc/platforms/powernv/opal-wrappers.S5
-rw-r--r--arch/powerpc/platforms/powernv/opal.c18
-rw-r--r--arch/powerpc/platforms/powernv/pci-ioda.c47
-rw-r--r--arch/powerpc/platforms/powernv/powernv.h2
-rw-r--r--arch/powerpc/platforms/powernv/setup.c17
-rw-r--r--arch/powerpc/platforms/powernv/smp.c18
-rw-r--r--arch/powerpc/platforms/pseries/Makefile1
-rw-r--r--arch/powerpc/platforms/pseries/cmm.c3
-rw-r--r--arch/powerpc/platforms/pseries/dlpar.c67
-rw-r--r--arch/powerpc/platforms/pseries/dtl.c5
-rw-r--r--arch/powerpc/platforms/pseries/hotplug-cpu.c7
-rw-r--r--arch/powerpc/platforms/pseries/hvconsole.c19
-rw-r--r--arch/powerpc/platforms/pseries/iommu.c11
-rw-r--r--arch/powerpc/platforms/pseries/kexec.c2
-rw-r--r--arch/powerpc/platforms/pseries/lpar.c12
-rw-r--r--arch/powerpc/platforms/pseries/lparcfg.c (renamed from arch/powerpc/kernel/lparcfg.c)14
-rw-r--r--arch/powerpc/platforms/pseries/mobility.c45
-rw-r--r--arch/powerpc/platforms/pseries/processor_idle.c12
-rw-r--r--arch/powerpc/platforms/pseries/pseries.h5
-rw-r--r--arch/powerpc/platforms/pseries/pseries_energy.c4
-rw-r--r--arch/powerpc/platforms/pseries/setup.c6
-rw-r--r--arch/powerpc/platforms/pseries/smp.c20
-rw-r--r--arch/powerpc/platforms/wsp/wsp.h1
-rw-r--r--arch/powerpc/sysdev/fsl_msi.c137
-rw-r--r--arch/powerpc/sysdev/fsl_msi.h10
-rw-r--r--arch/powerpc/sysdev/fsl_pci.c184
-rw-r--r--arch/powerpc/sysdev/fsl_pci.h6
-rw-r--r--arch/powerpc/sysdev/xics/icp-native.c2
-rw-r--r--arch/powerpc/sysdev/xics/xics-common.c10
-rw-r--r--arch/powerpc/xmon/xmon.c31
173 files changed, 3968 insertions, 1709 deletions
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 5aecda05e0da..a4e3a93bf2d4 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -312,6 +312,26 @@ config MATH_EMULATION
312 such as fsqrt on cores that do have an FPU but do not implement 312 such as fsqrt on cores that do have an FPU but do not implement
313 them (such as Freescale BookE). 313 them (such as Freescale BookE).
314 314
315choice
316 prompt "Math emulation options"
317 default MATH_EMULATION_FULL
318 depends on MATH_EMULATION
319
320config MATH_EMULATION_FULL
321 bool "Emulate all the floating point instructions"
322 ---help---
323 Select this option will enable the kernel to support to emulate
324 all the floating point instructions. If your SoC doesn't have
325 a FPU, you should select this.
326
327config MATH_EMULATION_HW_UNIMPLEMENTED
328 bool "Just emulate the FPU unimplemented instructions"
329 ---help---
330 Select this if you know there does have a hardware FPU on your
331 SoC, but some floating point instructions are not implemented by that.
332
333endchoice
334
315config PPC_TRANSACTIONAL_MEM 335config PPC_TRANSACTIONAL_MEM
316 bool "Transactional Memory support for POWERPC" 336 bool "Transactional Memory support for POWERPC"
317 depends on PPC_BOOK3S_64 337 depends on PPC_BOOK3S_64
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 967fd23ace78..51cfb78d4061 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -88,13 +88,30 @@ CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,-mminimal-toc)
88CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions) 88CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
89CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 -mmultiple 89CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 -mmultiple
90 90
91ifeq ($(CONFIG_PPC_BOOK3S_64),y)
91CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,-mtune=power4) 92CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,-mtune=power4)
93else
94CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
95endif
96
92CFLAGS-$(CONFIG_CELL_CPU) += $(call cc-option,-mcpu=cell) 97CFLAGS-$(CONFIG_CELL_CPU) += $(call cc-option,-mcpu=cell)
93CFLAGS-$(CONFIG_POWER4_CPU) += $(call cc-option,-mcpu=power4) 98CFLAGS-$(CONFIG_POWER4_CPU) += $(call cc-option,-mcpu=power4)
94CFLAGS-$(CONFIG_POWER5_CPU) += $(call cc-option,-mcpu=power5) 99CFLAGS-$(CONFIG_POWER5_CPU) += $(call cc-option,-mcpu=power5)
95CFLAGS-$(CONFIG_POWER6_CPU) += $(call cc-option,-mcpu=power6) 100CFLAGS-$(CONFIG_POWER6_CPU) += $(call cc-option,-mcpu=power6)
96CFLAGS-$(CONFIG_POWER7_CPU) += $(call cc-option,-mcpu=power7) 101CFLAGS-$(CONFIG_POWER7_CPU) += $(call cc-option,-mcpu=power7)
97 102
103E5500_CPU := $(call cc-option,-mcpu=e500mc64,-mcpu=powerpc64)
104CFLAGS-$(CONFIG_E5500_CPU) += $(E5500_CPU)
105CFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU))
106
107ifeq ($(CONFIG_PPC32),y)
108ifeq ($(CONFIG_PPC_E500MC),y)
109CFLAGS-y += $(call cc-option,-mcpu=e500mc,-mcpu=powerpc)
110else
111CFLAGS-$(CONFIG_E500) += $(call cc-option,-mcpu=8540 -msoft-float,-mcpu=powerpc)
112endif
113endif
114
98CFLAGS-$(CONFIG_TUNE_CELL) += $(call cc-option,-mtune=cell) 115CFLAGS-$(CONFIG_TUNE_CELL) += $(call cc-option,-mtune=cell)
99 116
100KBUILD_CPPFLAGS += -Iarch/$(ARCH) 117KBUILD_CPPFLAGS += -Iarch/$(ARCH)
@@ -139,7 +156,6 @@ endif
139 156
140cpu-as-$(CONFIG_4xx) += -Wa,-m405 157cpu-as-$(CONFIG_4xx) += -Wa,-m405
141cpu-as-$(CONFIG_ALTIVEC) += -Wa,-maltivec 158cpu-as-$(CONFIG_ALTIVEC) += -Wa,-maltivec
142cpu-as-$(CONFIG_E500) += -Wa,-me500
143cpu-as-$(CONFIG_E200) += -Wa,-me200 159cpu-as-$(CONFIG_E200) += -Wa,-me200
144 160
145KBUILD_AFLAGS += $(cpu-as-y) 161KBUILD_AFLAGS += $(cpu-as-y)
diff --git a/arch/powerpc/boot/.gitignore b/arch/powerpc/boot/.gitignore
index c32ae5ce9fff..554734ff302e 100644
--- a/arch/powerpc/boot/.gitignore
+++ b/arch/powerpc/boot/.gitignore
@@ -22,6 +22,7 @@ zImage.initrd
22zImage.bin.* 22zImage.bin.*
23zImage.chrp 23zImage.chrp
24zImage.coff 24zImage.coff
25zImage.epapr
25zImage.holly 26zImage.holly
26zImage.*lds 27zImage.*lds
27zImage.miboot 28zImage.miboot
diff --git a/arch/powerpc/boot/dts/ac14xx.dts b/arch/powerpc/boot/dts/ac14xx.dts
index a27a4609bb42..a543c4088cba 100644
--- a/arch/powerpc/boot/dts/ac14xx.dts
+++ b/arch/powerpc/boot/dts/ac14xx.dts
@@ -10,7 +10,7 @@
10 */ 10 */
11 11
12 12
13/include/ "mpc5121.dtsi" 13#include <mpc5121.dtsi>
14 14
15/ { 15/ {
16 model = "ac14xx"; 16 model = "ac14xx";
diff --git a/arch/powerpc/boot/dts/b4420qds.dts b/arch/powerpc/boot/dts/b4420qds.dts
index 923156d03b30..508dbdf33c81 100644
--- a/arch/powerpc/boot/dts/b4420qds.dts
+++ b/arch/powerpc/boot/dts/b4420qds.dts
@@ -33,7 +33,7 @@
33 */ 33 */
34 34
35/include/ "fsl/b4420si-pre.dtsi" 35/include/ "fsl/b4420si-pre.dtsi"
36/include/ "b4qds.dts" 36/include/ "b4qds.dtsi"
37 37
38/ { 38/ {
39 model = "fsl,B4420QDS"; 39 model = "fsl,B4420QDS";
diff --git a/arch/powerpc/boot/dts/b4860qds.dts b/arch/powerpc/boot/dts/b4860qds.dts
index 78907f38bb77..6bb3707ffe3d 100644
--- a/arch/powerpc/boot/dts/b4860qds.dts
+++ b/arch/powerpc/boot/dts/b4860qds.dts
@@ -33,7 +33,7 @@
33 */ 33 */
34 34
35/include/ "fsl/b4860si-pre.dtsi" 35/include/ "fsl/b4860si-pre.dtsi"
36/include/ "b4qds.dts" 36/include/ "b4qds.dtsi"
37 37
38/ { 38/ {
39 model = "fsl,B4860QDS"; 39 model = "fsl,B4860QDS";
diff --git a/arch/powerpc/boot/dts/b4qds.dts b/arch/powerpc/boot/dts/b4qds.dtsi
index e6d2f8f90544..e6d2f8f90544 100644
--- a/arch/powerpc/boot/dts/b4qds.dts
+++ b/arch/powerpc/boot/dts/b4qds.dtsi
diff --git a/arch/powerpc/boot/dts/c293pcie.dts b/arch/powerpc/boot/dts/c293pcie.dts
new file mode 100644
index 000000000000..1238bda8901f
--- /dev/null
+++ b/arch/powerpc/boot/dts/c293pcie.dts
@@ -0,0 +1,223 @@
1/*
2 * C293 PCIE Device Tree Source
3 *
4 * Copyright 2013 Freescale Semiconductor Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Freescale Semiconductor nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation, either version 2 of that License or (at your option) any
21 * later version.
22 *
23 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor "AS IS" AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35/include/ "fsl/c293si-pre.dtsi"
36
37/ {
38 model = "fsl,C293PCIE";
39 compatible = "fsl,C293PCIE";
40
41 memory {
42 device_type = "memory";
43 };
44
45 ifc: ifc@fffe1e000 {
46 reg = <0xf 0xffe1e000 0 0x2000>;
47 ranges = <0x0 0x0 0xf 0xec000000 0x04000000
48 0x2 0x0 0xf 0xffdf0000 0x00010000>;
49
50 };
51
52 soc: soc@fffe00000 {
53 ranges = <0x0 0xf 0xffe00000 0x100000>;
54 };
55
56 pci0: pcie@fffe0a000 {
57 reg = <0xf 0xffe0a000 0 0x1000>;
58 ranges = <0x2000000 0x0 0x80000000 0xc 0x00000000 0x0 0x20000000
59 0x1000000 0x0 0x00000000 0xf 0xffc00000 0x0 0x10000>;
60 pcie@0 {
61 ranges = <0x2000000 0x0 0x80000000
62 0x2000000 0x0 0x80000000
63 0x0 0x20000000
64
65 0x1000000 0x0 0x0
66 0x1000000 0x0 0x0
67 0x0 0x100000>;
68 };
69 };
70};
71
72&ifc {
73 nor@0,0 {
74 #address-cells = <1>;
75 #size-cells = <1>;
76 compatible = "cfi-flash";
77 reg = <0x0 0x0 0x4000000>;
78 bank-width = <2>;
79 device-width = <1>;
80
81 partition@0 {
82 /* 1MB for DTB Image */
83 reg = <0x0 0x00100000>;
84 label = "NOR DTB Image";
85 };
86
87 partition@100000 {
88 /* 8 MB for Linux Kernel Image */
89 reg = <0x00100000 0x00800000>;
90 label = "NOR Linux Kernel Image";
91 };
92
93 partition@900000 {
94 /* 53MB for rootfs */
95 reg = <0x00900000 0x03500000>;
96 label = "NOR Rootfs Image";
97 };
98
99 partition@3e00000 {
100 /* 1MB for blob encrypted key */
101 reg = <0x03e00000 0x00100000>;
102 label = "NOR blob encrypted key";
103 };
104
105 partition@3f00000 {
106 /* 512KB for u-boot Bootloader Image and evn */
107 reg = <0x03f00000 0x00100000>;
108 label = "NOR U-Boot Image";
109 read-only;
110 };
111 };
112
113 nand@1,0 {
114 #address-cells = <1>;
115 #size-cells = <1>;
116 compatible = "fsl,ifc-nand";
117 reg = <0x1 0x0 0x10000>;
118
119 partition@0 {
120 /* This location must not be altered */
121 /* 1MB for u-boot Bootloader Image */
122 reg = <0x0 0x00100000>;
123 label = "NAND U-Boot Image";
124 read-only;
125 };
126
127 partition@100000 {
128 /* 1MB for DTB Image */
129 reg = <0x00100000 0x00100000>;
130 label = "NAND DTB Image";
131 };
132
133 partition@200000 {
134 /* 16MB for Linux Kernel Image */
135 reg = <0x00200000 0x01000000>;
136 label = "NAND Linux Kernel Image";
137 };
138
139 partition@1200000 {
140 /* 4078MB for Root file System Image */
141 reg = <0x00600000 0xfee00000>;
142 label = "NAND RFS Image";
143 };
144 };
145
146 cpld@2,0 {
147 compatible = "fsl,c293pcie-cpld";
148 reg = <0x2 0x0 0x20>;
149 };
150};
151
152&soc {
153 i2c@3000 {
154 eeprom@50 {
155 compatible = "st,24c1024";
156 reg = <0x50>;
157 };
158
159 adt7461@4c {
160 compatible = "adi,adt7461";
161 reg = <0x4c>;
162 };
163 };
164
165 spi@7000 {
166 flash@0 {
167 #address-cells = <1>;
168 #size-cells = <1>;
169 compatible = "spansion,s25sl12801";
170 reg = <0>;
171 spi-max-frequency = <50000000>;
172
173 partition@0 {
174 /* 1MB for u-boot Bootloader Image */
175 /* 1MB for Environment */
176 reg = <0x0 0x00100000>;
177 label = "SPI Flash U-Boot Image";
178 read-only;
179 };
180
181 partition@100000 {
182 /* 512KB for DTB Image */
183 reg = <0x00100000 0x00080000>;
184 label = "SPI Flash DTB Image";
185 };
186
187 partition@180000 {
188 /* 4MB for Linux Kernel Image */
189 reg = <0x00180000 0x00400000>;
190 label = "SPI Flash Linux Kernel Image";
191 };
192
193 partition@580000 {
194 /* 10.5MB for RFS Image */
195 reg = <0x00580000 0x00a80000>;
196 label = "SPI Flash RFS Image";
197 };
198 };
199 };
200
201 mdio@24000 {
202 phy0: ethernet-phy@0 {
203 interrupts = <2 1 0 0>;
204 reg = <0x0>;
205 };
206
207 phy1: ethernet-phy@1 {
208 interrupts = <2 1 0 0>;
209 reg = <0x2>;
210 };
211 };
212
213 enet0: ethernet@b0000 {
214 phy-handle = <&phy0>;
215 phy-connection-type = "rgmii-id";
216 };
217
218 enet1: ethernet@b1000 {
219 phy-handle = <&phy1>;
220 phy-connection-type = "rgmii-id";
221 };
222};
223/include/ "fsl/c293si-post.dtsi"
diff --git a/arch/powerpc/boot/dts/fsl/b4si-post.dtsi b/arch/powerpc/boot/dts/fsl/b4si-post.dtsi
index 73991547c69b..4c617bf8cdb2 100644
--- a/arch/powerpc/boot/dts/fsl/b4si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/b4si-post.dtsi
@@ -204,7 +204,7 @@
204 }; 204 };
205 }; 205 };
206 206
207/include/ "qoriq-mpic.dtsi" 207/include/ "qoriq-mpic4.3.dtsi"
208 208
209 guts: global-utilities@e0000 { 209 guts: global-utilities@e0000 {
210 compatible = "fsl,b4-device-config"; 210 compatible = "fsl,b4-device-config";
diff --git a/arch/powerpc/boot/dts/fsl/c293si-post.dtsi b/arch/powerpc/boot/dts/fsl/c293si-post.dtsi
new file mode 100644
index 000000000000..bd208320bff5
--- /dev/null
+++ b/arch/powerpc/boot/dts/fsl/c293si-post.dtsi
@@ -0,0 +1,193 @@
1/*
2 * C293 Silicon/SoC Device Tree Source (post include)
3 *
4 * Copyright 2012 Freescale Semiconductor Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Freescale Semiconductor nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation, either version 2 of that License or (at your option) any
21 * later version.
22 *
23 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35&ifc {
36 #address-cells = <2>;
37 #size-cells = <1>;
38 compatible = "fsl,ifc", "simple-bus";
39 interrupts = <19 2 0 0>;
40};
41
42/* controller at 0xa000 */
43&pci0 {
44 compatible = "fsl,qoriq-pcie-v2.2", "fsl,qoriq-pcie";
45 device_type = "pci";
46 #size-cells = <2>;
47 #address-cells = <3>;
48 bus-range = <0 255>;
49 clock-frequency = <33333333>;
50 interrupts = <16 2 0 0>;
51
52 pcie@0 {
53 reg = <0 0 0 0 0>;
54 #interrupt-cells = <1>;
55 #size-cells = <2>;
56 #address-cells = <3>;
57 device_type = "pci";
58 interrupts = <16 2 0 0>;
59 interrupt-map-mask = <0xf800 0 0 7>;
60 interrupt-map = <
61 /* IDSEL 0x0 */
62 0000 0x0 0x0 0x1 &mpic 0x0 0x1 0x0 0x0
63 0000 0x0 0x0 0x2 &mpic 0x1 0x1 0x0 0x0
64 0000 0x0 0x0 0x3 &mpic 0x2 0x1 0x0 0x0
65 0000 0x0 0x0 0x4 &mpic 0x3 0x1 0x0 0x0
66 >;
67 };
68};
69
70&soc {
71 #address-cells = <1>;
72 #size-cells = <1>;
73 device_type = "soc";
74 compatible = "simple-bus";
75 bus-frequency = <0>; // Filled out by uboot.
76
77 ecm-law@0 {
78 compatible = "fsl,ecm-law";
79 reg = <0x0 0x1000>;
80 fsl,num-laws = <12>;
81 };
82
83 ecm@1000 {
84 compatible = "fsl,c293-ecm", "fsl,ecm";
85 reg = <0x1000 0x1000>;
86 interrupts = <16 2 0 0>;
87 };
88
89 memory-controller@2000 {
90 compatible = "fsl,c293-memory-controller";
91 reg = <0x2000 0x1000>;
92 interrupts = <16 2 0 0>;
93 };
94
95/include/ "pq3-i2c-0.dtsi"
96/include/ "pq3-i2c-1.dtsi"
97/include/ "pq3-duart-0.dtsi"
98/include/ "pq3-espi-0.dtsi"
99 spi0: spi@7000 {
100 fsl,espi-num-chipselects = <1>;
101 };
102
103/include/ "pq3-gpio-0.dtsi"
104 L2: l2-cache-controller@20000 {
105 compatible = "fsl,c293-l2-cache-controller";
106 reg = <0x20000 0x1000>;
107 cache-line-size = <32>; // 32 bytes
108 cache-size = <0x80000>; // L2,512K
109 interrupts = <16 2 0 0>;
110 };
111
112/include/ "pq3-dma-0.dtsi"
113/include/ "pq3-esdhc-0.dtsi"
114 sdhc@2e000 {
115 compatible = "fsl,c293-esdhc", "fsl,esdhc";
116 sdhci,auto-cmd12;
117 };
118
119 crypto@80000 {
120/include/ "qoriq-sec6.0-0.dtsi"
121 };
122
123 crypto@80000 {
124 reg = <0x80000 0x20000>;
125 ranges = <0x0 0x80000 0x20000>;
126
127 jr@1000{
128 interrupts = <45 2 0 0>;
129 };
130 jr@2000{
131 interrupts = <57 2 0 0>;
132 };
133 };
134
135 crypto@a0000 {
136/include/ "qoriq-sec6.0-0.dtsi"
137 };
138
139 crypto@a0000 {
140 reg = <0xa0000 0x20000>;
141 ranges = <0x0 0xa0000 0x20000>;
142
143 jr@1000{
144 interrupts = <49 2 0 0>;
145 };
146 jr@2000{
147 interrupts = <50 2 0 0>;
148 };
149 };
150
151 crypto@c0000 {
152/include/ "qoriq-sec6.0-0.dtsi"
153 };
154
155 crypto@c0000 {
156 reg = <0xc0000 0x20000>;
157 ranges = <0x0 0xc0000 0x20000>;
158
159 jr@1000{
160 interrupts = <55 2 0 0>;
161 };
162 jr@2000{
163 interrupts = <56 2 0 0>;
164 };
165 };
166
167/include/ "pq3-mpic.dtsi"
168/include/ "pq3-mpic-timer-B.dtsi"
169
170/include/ "pq3-etsec2-0.dtsi"
171 enet0: ethernet@b0000 {
172 queue-group@b0000 {
173 reg = <0x10000 0x1000>;
174 fsl,rx-bit-map = <0xff>;
175 fsl,tx-bit-map = <0xff>;
176 };
177 };
178
179/include/ "pq3-etsec2-1.dtsi"
180 enet1: ethernet@b1000 {
181 queue-group@b1000 {
182 reg = <0x11000 0x1000>;
183 fsl,rx-bit-map = <0xff>;
184 fsl,tx-bit-map = <0xff>;
185 };
186 };
187
188 global-utilities@e0000 {
189 compatible = "fsl,c293-guts";
190 reg = <0xe0000 0x1000>;
191 fsl,has-rstcr;
192 };
193};
diff --git a/arch/powerpc/boot/dts/fsl/c293si-pre.dtsi b/arch/powerpc/boot/dts/fsl/c293si-pre.dtsi
new file mode 100644
index 000000000000..065049d76245
--- /dev/null
+++ b/arch/powerpc/boot/dts/fsl/c293si-pre.dtsi
@@ -0,0 +1,63 @@
1/*
2 * C293 Silicon/SoC Device Tree Source (pre include)
3 *
4 * Copyright 2012 Freescale Semiconductor Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Freescale Semiconductor nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation, either version 2 of that License or (at your option) any
21 * later version.
22 *
23 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35/dts-v1/;
36
37/include/ "e500v2_power_isa.dtsi"
38
39/ {
40 compatible = "fsl,C293";
41 #address-cells = <2>;
42 #size-cells = <2>;
43 interrupt-parent = <&mpic>;
44
45 aliases {
46 serial0 = &serial0;
47 serial1 = &serial1;
48 ethernet0 = &enet0;
49 ethernet1 = &enet1;
50 pci0 = &pci0;
51 };
52
53 cpus {
54 #address-cells = <1>;
55 #size-cells = <0>;
56
57 PowerPC,e500v2@0 {
58 device_type = "cpu";
59 reg = <0x0>;
60 next-level-cache = <&L2>;
61 };
62 };
63};
diff --git a/arch/powerpc/boot/dts/fsl/qoriq-mpic4.3.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-mpic4.3.dtsi
new file mode 100644
index 000000000000..64f713c24825
--- /dev/null
+++ b/arch/powerpc/boot/dts/fsl/qoriq-mpic4.3.dtsi
@@ -0,0 +1,149 @@
1/*
2 * QorIQ MPIC device tree stub [ controller @ offset 0x40000 ]
3 *
4 * Copyright 2013 Freescale Semiconductor Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Freescale Semiconductor nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation, either version 2 of that License or (at your option) any
21 * later version.
22 *
23 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35mpic: pic@40000 {
36 interrupt-controller;
37 #address-cells = <0>;
38 #interrupt-cells = <4>;
39 reg = <0x40000 0x40000>;
40 compatible = "fsl,mpic";
41 device_type = "open-pic";
42 clock-frequency = <0x0>;
43};
44
45timer@41100 {
46 compatible = "fsl,mpic-global-timer";
47 reg = <0x41100 0x100 0x41300 4>;
48 interrupts = <0 0 3 0
49 1 0 3 0
50 2 0 3 0
51 3 0 3 0>;
52};
53
54msi0: msi@41600 {
55 compatible = "fsl,mpic-msi-v4.3";
56 reg = <0x41600 0x200 0x44148 4>;
57 interrupts = <
58 0xe0 0 0 0
59 0xe1 0 0 0
60 0xe2 0 0 0
61 0xe3 0 0 0
62 0xe4 0 0 0
63 0xe5 0 0 0
64 0xe6 0 0 0
65 0xe7 0 0 0
66 0x100 0 0 0
67 0x101 0 0 0
68 0x102 0 0 0
69 0x103 0 0 0
70 0x104 0 0 0
71 0x105 0 0 0
72 0x106 0 0 0
73 0x107 0 0 0>;
74};
75
76msi1: msi@41800 {
77 compatible = "fsl,mpic-msi-v4.3";
78 reg = <0x41800 0x200 0x45148 4>;
79 interrupts = <
80 0xe8 0 0 0
81 0xe9 0 0 0
82 0xea 0 0 0
83 0xeb 0 0 0
84 0xec 0 0 0
85 0xed 0 0 0
86 0xee 0 0 0
87 0xef 0 0 0
88 0x108 0 0 0
89 0x109 0 0 0
90 0x10a 0 0 0
91 0x10b 0 0 0
92 0x10c 0 0 0
93 0x10d 0 0 0
94 0x10e 0 0 0
95 0x10f 0 0 0>;
96};
97
98msi2: msi@41a00 {
99 compatible = "fsl,mpic-msi-v4.3";
100 reg = <0x41a00 0x200 0x46148 4>;
101 interrupts = <
102 0xf0 0 0 0
103 0xf1 0 0 0
104 0xf2 0 0 0
105 0xf3 0 0 0
106 0xf4 0 0 0
107 0xf5 0 0 0
108 0xf6 0 0 0
109 0xf7 0 0 0
110 0x110 0 0 0
111 0x111 0 0 0
112 0x112 0 0 0
113 0x113 0 0 0
114 0x114 0 0 0
115 0x115 0 0 0
116 0x116 0 0 0
117 0x117 0 0 0>;
118};
119
120msi3: msi@41c00 {
121 compatible = "fsl,mpic-msi-v4.3";
122 reg = <0x41c00 0x200 0x47148 4>;
123 interrupts = <
124 0xf8 0 0 0
125 0xf9 0 0 0
126 0xfa 0 0 0
127 0xfb 0 0 0
128 0xfc 0 0 0
129 0xfd 0 0 0
130 0xfe 0 0 0
131 0xff 0 0 0
132 0x118 0 0 0
133 0x119 0 0 0
134 0x11a 0 0 0
135 0x11b 0 0 0
136 0x11c 0 0 0
137 0x11d 0 0 0
138 0x11e 0 0 0
139 0x11f 0 0 0>;
140};
141
142timer@42100 {
143 compatible = "fsl,mpic-global-timer";
144 reg = <0x42100 0x100 0x42300 4>;
145 interrupts = <4 0 3 0
146 5 0 3 0
147 6 0 3 0
148 7 0 3 0>;
149};
diff --git a/arch/powerpc/boot/dts/fsl/qoriq-sec6.0-0.dtsi b/arch/powerpc/boot/dts/fsl/qoriq-sec6.0-0.dtsi
new file mode 100644
index 000000000000..f75b4f820c3c
--- /dev/null
+++ b/arch/powerpc/boot/dts/fsl/qoriq-sec6.0-0.dtsi
@@ -0,0 +1,56 @@
1/*
2 * QorIQ Sec/Crypto 6.0 device tree stub
3 *
4 * Copyright 2013 Freescale Semiconductor Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Freescale Semiconductor nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation, either version 2 of that License or (at your option) any
21 * later version.
22 *
23 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 compatible = "fsl,sec-v6.0";
36 fsl,sec-era = <6>;
37 #address-cells = <1>;
38 #size-cells = <1>;
39
40 jr@1000 {
41 compatible = "fsl,sec-v6.0-job-ring",
42 "fsl,sec-v5.2-job-ring",
43 "fsl,sec-v5.0-job-ring",
44 "fsl,sec-v4.4-job-ring",
45 "fsl,sec-v4.0-job-ring";
46 reg = <0x1000 0x1000>;
47 };
48
49 jr@2000 {
50 compatible = "fsl,sec-v6.0-job-ring",
51 "fsl,sec-v5.2-job-ring",
52 "fsl,sec-v5.0-job-ring",
53 "fsl,sec-v4.4-job-ring",
54 "fsl,sec-v4.0-job-ring";
55 reg = <0x2000 0x1000>;
56 };
diff --git a/arch/powerpc/boot/dts/fsl/t4240si-post.dtsi b/arch/powerpc/boot/dts/fsl/t4240si-post.dtsi
index bd611a9cad32..510afa362de1 100644
--- a/arch/powerpc/boot/dts/fsl/t4240si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/t4240si-post.dtsi
@@ -358,7 +358,7 @@
358 16 2 1 30>; 358 16 2 1 30>;
359 }; 359 };
360 360
361/include/ "qoriq-mpic.dtsi" 361/include/ "qoriq-mpic4.3.dtsi"
362 362
363 guts: global-utilities@e0000 { 363 guts: global-utilities@e0000 {
364 compatible = "fsl,t4240-device-config", "fsl,qoriq-device-config-2.0"; 364 compatible = "fsl,t4240-device-config", "fsl,qoriq-device-config-2.0";
diff --git a/arch/powerpc/boot/dts/include/dt-bindings b/arch/powerpc/boot/dts/include/dt-bindings
new file mode 120000
index 000000000000..08c00e4972fa
--- /dev/null
+++ b/arch/powerpc/boot/dts/include/dt-bindings
@@ -0,0 +1 @@
../../../../../include/dt-bindings \ No newline at end of file
diff --git a/arch/powerpc/boot/dts/mpc5121ads.dts b/arch/powerpc/boot/dts/mpc5121ads.dts
index 7d3cb79185cb..c228a0a232a6 100644
--- a/arch/powerpc/boot/dts/mpc5121ads.dts
+++ b/arch/powerpc/boot/dts/mpc5121ads.dts
@@ -9,7 +9,7 @@
9 * option) any later version. 9 * option) any later version.
10 */ 10 */
11 11
12/include/ "mpc5121.dtsi" 12#include <mpc5121.dtsi>
13 13
14/ { 14/ {
15 model = "mpc5121ads"; 15 model = "mpc5121ads";
diff --git a/arch/powerpc/boot/dts/p1020rdb-pd.dts b/arch/powerpc/boot/dts/p1020rdb-pd.dts
new file mode 100644
index 000000000000..987017ea36b6
--- /dev/null
+++ b/arch/powerpc/boot/dts/p1020rdb-pd.dts
@@ -0,0 +1,280 @@
1/*
2 * P1020 RDB-PD Device Tree Source (32-bit address map)
3 *
4 * Copyright 2013 Freescale Semiconductor Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Freescale Semiconductor nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation, either version 2 of that License or (at your option) any
21 * later version.
22 *
23 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35/include/ "fsl/p1020si-pre.dtsi"
36/ {
37 model = "fsl,P1020RDB-PD";
38 compatible = "fsl,P1020RDB-PD";
39
40 memory {
41 device_type = "memory";
42 };
43
44 lbc: localbus@ffe05000 {
45 reg = <0x0 0xffe05000 0x0 0x1000>;
46
47 /* NOR, NAND flash, L2 switch and CPLD */
48 ranges = <0x0 0x0 0x0 0xec000000 0x04000000
49 0x1 0x0 0x0 0xff800000 0x00040000
50 0x2 0x0 0x0 0xffa00000 0x00020000
51 0x3 0x0 0x0 0xffb00000 0x00020000>;
52
53 nor@0,0 {
54 #address-cells = <1>;
55 #size-cells = <1>;
56 compatible = "cfi-flash";
57 reg = <0x0 0x0 0x4000000>;
58 bank-width = <2>;
59 device-width = <1>;
60
61 partition@0 {
62 /* 128KB for DTB Image */
63 reg = <0x0 0x00020000>;
64 label = "NOR DTB Image";
65 };
66
67 partition@20000 {
68 /* 3.875 MB for Linux Kernel Image */
69 reg = <0x00020000 0x003e0000>;
70 label = "NOR Linux Kernel Image";
71 };
72
73 partition@400000 {
74 /* 58MB for Root file System */
75 reg = <0x00400000 0x03a00000>;
76 label = "NOR Root File System";
77 };
78
79 partition@3e00000 {
80 /* This location must not be altered */
81 /* 1M for Vitesse 7385 Switch firmware */
82 reg = <0x3e00000 0x00100000>;
83 label = "NOR Vitesse-7385 Firmware";
84 read-only;
85 };
86
87 partition@3f00000 {
88 /* This location must not be altered */
89 /* 512KB for u-boot Bootloader Image */
90 /* 512KB for u-boot Environment Variables */
91 reg = <0x03f00000 0x00100000>;
92 label = "NOR U-Boot Image";
93 read-only;
94 };
95 };
96
97 nand@1,0 {
98 #address-cells = <1>;
99 #size-cells = <1>;
100 compatible = "fsl,p1020-fcm-nand",
101 "fsl,elbc-fcm-nand";
102 reg = <0x1 0x0 0x40000>;
103
104 partition@0 {
105 /* This location must not be altered */
106 /* 1MB for u-boot Bootloader Image */
107 reg = <0x0 0x00100000>;
108 label = "NAND U-Boot Image";
109 read-only;
110 };
111
112 partition@100000 {
113 /* 1MB for DTB Image */
114 reg = <0x00100000 0x00100000>;
115 label = "NAND DTB Image";
116 };
117
118 partition@200000 {
119 /* 4MB for Linux Kernel Image */
120 reg = <0x00200000 0x00400000>;
121 label = "NAND Linux Kernel Image";
122 };
123
124 partition@600000 {
125 /* 122MB for File System Image */
126 reg = <0x00600000 0x07a00000>;
127 label = "NAND File System Image";
128 };
129 };
130
131 cpld@2,0 {
132 compatible = "fsl,p1020rdb-pd-cpld";
133 reg = <0x2 0x0 0x20000>;
134 };
135
136 L2switch@3,0 {
137 #address-cells = <1>;
138 #size-cells = <1>;
139 compatible = "vitesse-7385";
140 reg = <0x3 0x0 0x20000>;
141 };
142 };
143
144 soc: soc@ffe00000 {
145 ranges = <0x0 0x0 0xffe00000 0x100000>;
146
147 i2c@3000 {
148 rtc@68 {
149 compatible = "dallas,ds1339";
150 reg = <0x68>;
151 };
152 };
153
154 spi@7000 {
155 flash@0 {
156 #address-cells = <1>;
157 #size-cells = <1>;
158 compatible = "spansion,s25sl12801";
159 reg = <0>;
160 /* input clock */
161 spi-max-frequency = <40000000>;
162
163 partition@0 {
164 /* 512KB for u-boot Bootloader Image */
165 reg = <0x0 0x00080000>;
166 label = "SPI U-Boot Image";
167 read-only;
168 };
169
170 partition@80000 {
171 /* 512KB for DTB Image*/
172 reg = <0x00080000 0x00080000>;
173 label = "SPI DTB Image";
174 };
175
176 partition@100000 {
177 /* 4MB for Linux Kernel Image */
178 reg = <0x00100000 0x00400000>;
179 label = "SPI Linux Kernel Image";
180 };
181
182 partition@500000 {
183 /* 11MB for FS System Image */
184 reg = <0x00500000 0x00b00000>;
185 label = "SPI File System Image";
186 };
187 };
188
189 slic@0 {
190 compatible = "zarlink,le88266";
191 reg = <1>;
192 spi-max-frequency = <8000000>;
193 };
194
195 slic@1 {
196 compatible = "zarlink,le88266";
197 reg = <2>;
198 spi-max-frequency = <8000000>;
199 };
200 };
201
202 mdio@24000 {
203 phy0: ethernet-phy@0 {
204 interrupts = <3 1 0 0>;
205 reg = <0x0>;
206 };
207
208 phy1: ethernet-phy@1 {
209 interrupts = <2 1 0 0>;
210 reg = <0x1>;
211 };
212 };
213
214 mdio@25000 {
215 tbi1: tbi-phy@11 {
216 reg = <0x11>;
217 device_type = "tbi-phy";
218 };
219 };
220
221 mdio@26000 {
222 tbi2: tbi-phy@11 {
223 reg = <0x11>;
224 device_type = "tbi-phy";
225 };
226 };
227
228 enet0: ethernet@b0000 {
229 fixed-link = <1 1 1000 0 0>;
230 phy-connection-type = "rgmii-id";
231 };
232
233 enet1: ethernet@b1000 {
234 phy-handle = <&phy0>;
235 tbi-handle = <&tbi1>;
236 phy-connection-type = "sgmii";
237 };
238
239 enet2: ethernet@b2000 {
240 phy-handle = <&phy1>;
241 phy-connection-type = "rgmii-id";
242 };
243
244 usb@22000 {
245 phy_type = "ulpi";
246 };
247 };
248
249 pci0: pcie@ffe09000 {
250 reg = <0x0 0xffe09000 0x0 0x1000>;
251 ranges = <0x2000000 0x0 0xa0000000 0x0 0xa0000000 0x0 0x20000000
252 0x1000000 0x0 0x00000000 0x0 0xffc10000 0x0 0x10000>;
253 pcie@0 {
254 ranges = <0x2000000 0x0 0xa0000000
255 0x2000000 0x0 0xa0000000
256 0x0 0x20000000
257
258 0x1000000 0x0 0x0
259 0x1000000 0x0 0x0
260 0x0 0x100000>;
261 };
262 };
263
264 pci1: pcie@ffe0a000 {
265 reg = <0x0 0xffe0a000 0x0 0x1000>;
266 ranges = <0x2000000 0x0 0x80000000 0x0 0x80000000 0x0 0x20000000
267 0x1000000 0x0 0x00000000 0x0 0xffc00000 0x0 0x10000>;
268 pcie@0 {
269 ranges = <0x2000000 0x0 0x80000000
270 0x2000000 0x0 0x80000000
271 0x0 0x20000000
272
273 0x1000000 0x0 0x0
274 0x1000000 0x0 0x0
275 0x0 0x100000>;
276 };
277 };
278};
279
280/include/ "fsl/p1020si-post.dtsi"
diff --git a/arch/powerpc/boot/dts/p1023rdb.dts b/arch/powerpc/boot/dts/p1023rdb.dts
new file mode 100644
index 000000000000..0a06a88ddbd5
--- /dev/null
+++ b/arch/powerpc/boot/dts/p1023rdb.dts
@@ -0,0 +1,234 @@
1/*
2 * P1023 RDB Device Tree Source
3 *
4 * Copyright 2013 Freescale Semiconductor Inc.
5 *
6 * Author: Chunhe Lan <Chunhe.Lan@freescale.com>
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * * Neither the name of Freescale Semiconductor nor the
16 * names of its contributors may be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 *
20 * ALTERNATIVELY, this software may be distributed under the terms of the
21 * GNU General Public License ("GPL") as published by the Free Software
22 * Foundation, either version 2 of that License or (at your option) any
23 * later version.
24 *
25 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
26 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
29 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36
37/include/ "fsl/p1023si-pre.dtsi"
38
39/ {
40 model = "fsl,P1023";
41 compatible = "fsl,P1023RDB";
42 #address-cells = <2>;
43 #size-cells = <2>;
44 interrupt-parent = <&mpic>;
45
46 memory {
47 device_type = "memory";
48 };
49
50 soc: soc@ff600000 {
51 ranges = <0x0 0x0 0xff600000 0x200000>;
52
53 i2c@3000 {
54 eeprom@53 {
55 compatible = "at24,24c04";
56 reg = <0x53>;
57 };
58
59 rtc@6f {
60 compatible = "microchip,mcp7941x";
61 reg = <0x6f>;
62 };
63 };
64
65 usb@22000 {
66 dr_mode = "host";
67 phy_type = "ulpi";
68 };
69 };
70
71 lbc: localbus@ff605000 {
72 reg = <0 0xff605000 0 0x1000>;
73
74 /* NOR, NAND Flashes */
75 ranges = <0x0 0x0 0x0 0xec000000 0x04000000
76 0x1 0x0 0x0 0xffa00000 0x08000000>;
77
78 nor@0,0 {
79 #address-cells = <1>;
80 #size-cells = <1>;
81 compatible = "cfi-flash";
82 reg = <0x0 0x0 0x04000000>;
83 bank-width = <2>;
84 device-width = <1>;
85
86 partition@0 {
87 /* 48MB for Root File System */
88 reg = <0x00000000 0x03000000>;
89 label = "NOR Root File System";
90 };
91
92 partition@3000000 {
93 /* 1MB for DTB Image */
94 reg = <0x03000000 0x00100000>;
95 label = "NOR DTB Image";
96 };
97
98 partition@3100000 {
99 /* 14MB for Linux Kernel Image */
100 reg = <0x03100000 0x00e00000>;
101 label = "NOR Linux Kernel Image";
102 };
103
104 partition@3f00000 {
105 /* This location must not be altered */
106 /* 512KB for u-boot Bootloader Image */
107 /* 512KB for u-boot Environment Variables */
108 reg = <0x03f00000 0x00100000>;
109 label = "NOR U-Boot Image";
110 read-only;
111 };
112 };
113
114 nand@1,0 {
115 #address-cells = <1>;
116 #size-cells = <1>;
117 compatible = "fsl,elbc-fcm-nand";
118 reg = <0x1 0x0 0x40000>;
119
120 partition@0 {
121 /* This location must not be altered */
122 /* 1MB for u-boot Bootloader Image */
123 reg = <0x0 0x00100000>;
124 label = "NAND U-Boot Image";
125 read-only;
126 };
127
128 partition@100000 {
129 /* 1MB for DTB Image */
130 reg = <0x00100000 0x00100000>;
131 label = "NAND DTB Image";
132 };
133
134 partition@200000 {
135 /* 14MB for Linux Kernel Image */
136 reg = <0x00200000 0x00e00000>;
137 label = "NAND Linux Kernel Image";
138 };
139
140 partition@1000000 {
141 /* 96MB for Root File System Image */
142 reg = <0x01000000 0x06000000>;
143 label = "NAND Root File System";
144 };
145
146 partition@7000000 {
147 /* 16MB for User Writable Area */
148 reg = <0x07000000 0x01000000>;
149 label = "NAND Writable User area";
150 };
151 };
152 };
153
154 pci0: pcie@ff60a000 {
155 reg = <0 0xff60a000 0 0x1000>;
156 ranges = <0x2000000 0x0 0xc0000000 0 0xc0000000 0x0 0x20000000
157 0x1000000 0x0 0x00000000 0 0xffc20000 0x0 0x10000>;
158 pcie@0 {
159 /* IRQ[0:3] are pulled up on board, set to active-low */
160 interrupt-map-mask = <0xf800 0 0 7>;
161 interrupt-map = <
162 /* IDSEL 0x0 */
163 0000 0 0 1 &mpic 0 1 0 0
164 0000 0 0 2 &mpic 1 1 0 0
165 0000 0 0 3 &mpic 2 1 0 0
166 0000 0 0 4 &mpic 3 1 0 0
167 >;
168 ranges = <0x2000000 0x0 0xc0000000
169 0x2000000 0x0 0xc0000000
170 0x0 0x20000000
171
172 0x1000000 0x0 0x0
173 0x1000000 0x0 0x0
174 0x0 0x100000>;
175 };
176 };
177
178 board_pci1: pci1: pcie@ff609000 {
179 reg = <0 0xff609000 0 0x1000>;
180 ranges = <0x2000000 0x0 0xa0000000 0 0xa0000000 0x0 0x20000000
181 0x1000000 0x0 0x00000000 0 0xffc10000 0x0 0x10000>;
182 pcie@0 {
183 /*
184 * IRQ[4:6] only for PCIe, set to active-high,
185 * IRQ[7] is pulled up on board, set to active-low
186 */
187 interrupt-map-mask = <0xf800 0 0 7>;
188 interrupt-map = <
189 /* IDSEL 0x0 */
190 0000 0 0 1 &mpic 4 2 0 0
191 0000 0 0 2 &mpic 5 2 0 0
192 0000 0 0 3 &mpic 6 2 0 0
193 0000 0 0 4 &mpic 7 1 0 0
194 >;
195 ranges = <0x2000000 0x0 0xa0000000
196 0x2000000 0x0 0xa0000000
197 0x0 0x20000000
198
199 0x1000000 0x0 0x0
200 0x1000000 0x0 0x0
201 0x0 0x100000>;
202 };
203 };
204
205 pci2: pcie@ff60b000 {
206 reg = <0 0xff60b000 0 0x1000>;
207 ranges = <0x2000000 0x0 0x80000000 0 0x80000000 0x0 0x20000000
208 0x1000000 0x0 0x00000000 0 0xffc00000 0x0 0x10000>;
209 pcie@0 {
210 /*
211 * IRQ[8:10] are pulled up on board, set to active-low
212 * IRQ[11] only for PCIe, set to active-high,
213 */
214 interrupt-map-mask = <0xf800 0 0 7>;
215 interrupt-map = <
216 /* IDSEL 0x0 */
217 0000 0 0 1 &mpic 8 1 0 0
218 0000 0 0 2 &mpic 9 1 0 0
219 0000 0 0 3 &mpic 10 1 0 0
220 0000 0 0 4 &mpic 11 2 0 0
221 >;
222 ranges = <0x2000000 0x0 0x80000000
223 0x2000000 0x0 0x80000000
224 0x0 0x20000000
225
226 0x1000000 0x0 0x0
227 0x1000000 0x0 0x0
228 0x0 0x100000>;
229 };
230 };
231
232};
233
234/include/ "fsl/p1023si-post.dtsi"
diff --git a/arch/powerpc/boot/dts/pdm360ng.dts b/arch/powerpc/boot/dts/pdm360ng.dts
index 74337403faee..871c16d1ad5e 100644
--- a/arch/powerpc/boot/dts/pdm360ng.dts
+++ b/arch/powerpc/boot/dts/pdm360ng.dts
@@ -13,7 +13,7 @@
13 * option) any later version. 13 * option) any later version.
14 */ 14 */
15 15
16/include/ "mpc5121.dtsi" 16#include <mpc5121.dtsi>
17 17
18/ { 18/ {
19 model = "pdm360ng"; 19 model = "pdm360ng";
diff --git a/arch/powerpc/boot/ppc_asm.h b/arch/powerpc/boot/ppc_asm.h
index 1c2c2817f9b7..eb0e98be69e0 100644
--- a/arch/powerpc/boot/ppc_asm.h
+++ b/arch/powerpc/boot/ppc_asm.h
@@ -59,4 +59,7 @@
59#define r30 30 59#define r30 30
60#define r31 31 60#define r31 31
61 61
62#define SPRN_TBRL 268
63#define SPRN_TBRU 269
64
62#endif /* _PPC64_PPC_ASM_H */ 65#endif /* _PPC64_PPC_ASM_H */
diff --git a/arch/powerpc/boot/util.S b/arch/powerpc/boot/util.S
index 427ddfc11991..5143228e3e5f 100644
--- a/arch/powerpc/boot/util.S
+++ b/arch/powerpc/boot/util.S
@@ -71,18 +71,18 @@ udelay:
71 add r4,r4,r5 71 add r4,r4,r5
72 addi r4,r4,-1 72 addi r4,r4,-1
73 divw r4,r4,r5 /* BUS ticks */ 73 divw r4,r4,r5 /* BUS ticks */
741: mftbu r5 741: mfspr r5, SPRN_TBRU
75 mftb r6 75 mfspr r6, SPRN_TBRL
76 mftbu r7 76 mfspr r7, SPRN_TBRU
77 cmpw 0,r5,r7 77 cmpw 0,r5,r7
78 bne 1b /* Get [synced] base time */ 78 bne 1b /* Get [synced] base time */
79 addc r9,r6,r4 /* Compute end time */ 79 addc r9,r6,r4 /* Compute end time */
80 addze r8,r5 80 addze r8,r5
812: mftbu r5 812: mfspr r5, SPRN_TBRU
82 cmpw 0,r5,r8 82 cmpw 0,r5,r8
83 blt 2b 83 blt 2b
84 bgt 3f 84 bgt 3f
85 mftb r6 85 mfspr r6, SPRN_TBRL
86 cmpw 0,r6,r9 86 cmpw 0,r6,r9
87 blt 2b 87 blt 2b
883: blr 883: blr
diff --git a/arch/powerpc/configs/85xx/p1023rds_defconfig b/arch/powerpc/configs/85xx/p1023_defconfig
index b80bcc69d1f7..b06d37da44f4 100644
--- a/arch/powerpc/configs/85xx/p1023rds_defconfig
+++ b/arch/powerpc/configs/85xx/p1023_defconfig
@@ -1,14 +1,13 @@
1CONFIG_PPC_85xx=y 1CONFIG_PPC_85xx=y
2CONFIG_SMP=y 2CONFIG_SMP=y
3CONFIG_NR_CPUS=2 3CONFIG_NR_CPUS=2
4CONFIG_EXPERIMENTAL=y
5CONFIG_SYSVIPC=y 4CONFIG_SYSVIPC=y
6CONFIG_POSIX_MQUEUE=y 5CONFIG_POSIX_MQUEUE=y
7CONFIG_BSD_PROCESS_ACCT=y 6CONFIG_BSD_PROCESS_ACCT=y
8CONFIG_AUDIT=y 7CONFIG_AUDIT=y
9CONFIG_IRQ_DOMAIN_DEBUG=y
10CONFIG_NO_HZ=y 8CONFIG_NO_HZ=y
11CONFIG_HIGH_RES_TIMERS=y 9CONFIG_HIGH_RES_TIMERS=y
10CONFIG_RCU_FANOUT=32
12CONFIG_IKCONFIG=y 11CONFIG_IKCONFIG=y
13CONFIG_IKCONFIG_PROC=y 12CONFIG_IKCONFIG_PROC=y
14CONFIG_LOG_BUF_SHIFT=14 13CONFIG_LOG_BUF_SHIFT=14
@@ -22,6 +21,8 @@ CONFIG_MODVERSIONS=y
22# CONFIG_BLK_DEV_BSG is not set 21# CONFIG_BLK_DEV_BSG is not set
23CONFIG_PARTITION_ADVANCED=y 22CONFIG_PARTITION_ADVANCED=y
24CONFIG_MAC_PARTITION=y 23CONFIG_MAC_PARTITION=y
24CONFIG_PHYSICAL_START=0x00000000
25CONFIG_P1023_RDB=y
25CONFIG_P1023_RDS=y 26CONFIG_P1023_RDS=y
26CONFIG_QUICC_ENGINE=y 27CONFIG_QUICC_ENGINE=y
27CONFIG_QE_GPIO=y 28CONFIG_QE_GPIO=y
@@ -63,10 +64,21 @@ CONFIG_IPV6=y
63CONFIG_IP_SCTP=m 64CONFIG_IP_SCTP=m
64CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 65CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
65CONFIG_DEVTMPFS=y 66CONFIG_DEVTMPFS=y
67CONFIG_DEVTMPFS_MOUNT=y
68CONFIG_MTD=y
69CONFIG_MTD_CMDLINE_PARTS=y
70CONFIG_MTD_CHAR=y
71CONFIG_MTD_BLOCK=y
72CONFIG_MTD_CFI=y
73CONFIG_MTD_CFI_AMDSTD=y
74CONFIG_MTD_PHYSMAP_OF=y
75CONFIG_MTD_NAND=y
76CONFIG_MTD_NAND_FSL_ELBC=y
66CONFIG_PROC_DEVICETREE=y 77CONFIG_PROC_DEVICETREE=y
67CONFIG_BLK_DEV_LOOP=y 78CONFIG_BLK_DEV_LOOP=y
68CONFIG_BLK_DEV_RAM=y 79CONFIG_BLK_DEV_RAM=y
69CONFIG_BLK_DEV_RAM_SIZE=131072 80CONFIG_BLK_DEV_RAM_SIZE=131072
81CONFIG_EEPROM_AT24=y
70CONFIG_EEPROM_LEGACY=y 82CONFIG_EEPROM_LEGACY=y
71CONFIG_BLK_DEV_SD=y 83CONFIG_BLK_DEV_SD=y
72CONFIG_CHR_DEV_ST=y 84CONFIG_CHR_DEV_ST=y
@@ -82,6 +94,8 @@ CONFIG_DUMMY=y
82CONFIG_FS_ENET=y 94CONFIG_FS_ENET=y
83CONFIG_FSL_PQ_MDIO=y 95CONFIG_FSL_PQ_MDIO=y
84CONFIG_E1000E=y 96CONFIG_E1000E=y
97CONFIG_PHYLIB=y
98CONFIG_AT803X_PHY=y
85CONFIG_MARVELL_PHY=y 99CONFIG_MARVELL_PHY=y
86CONFIG_DAVICOM_PHY=y 100CONFIG_DAVICOM_PHY=y
87CONFIG_CICADA_PHY=y 101CONFIG_CICADA_PHY=y
@@ -96,12 +110,15 @@ CONFIG_SERIAL_8250=y
96CONFIG_SERIAL_8250_CONSOLE=y 110CONFIG_SERIAL_8250_CONSOLE=y
97CONFIG_SERIAL_8250_NR_UARTS=2 111CONFIG_SERIAL_8250_NR_UARTS=2
98CONFIG_SERIAL_8250_RUNTIME_UARTS=2 112CONFIG_SERIAL_8250_RUNTIME_UARTS=2
113CONFIG_SERIAL_8250_EXTENDED=y
99CONFIG_SERIAL_8250_MANY_PORTS=y 114CONFIG_SERIAL_8250_MANY_PORTS=y
115CONFIG_SERIAL_8250_SHARE_IRQ=y
100CONFIG_SERIAL_8250_DETECT_IRQ=y 116CONFIG_SERIAL_8250_DETECT_IRQ=y
101CONFIG_SERIAL_8250_RSA=y 117CONFIG_SERIAL_8250_RSA=y
102CONFIG_SERIAL_QE=m 118CONFIG_HW_RANDOM=y
103CONFIG_NVRAM=y 119CONFIG_NVRAM=y
104CONFIG_I2C=y 120CONFIG_I2C=y
121CONFIG_I2C_CHARDEV=y
105CONFIG_I2C_CPM=m 122CONFIG_I2C_CPM=m
106CONFIG_I2C_MPC=y 123CONFIG_I2C_MPC=y
107CONFIG_GPIO_MPC8XXX=y 124CONFIG_GPIO_MPC8XXX=y
@@ -121,6 +138,7 @@ CONFIG_USB_STORAGE=y
121CONFIG_EDAC=y 138CONFIG_EDAC=y
122CONFIG_EDAC_MM_EDAC=y 139CONFIG_EDAC_MM_EDAC=y
123CONFIG_RTC_CLASS=y 140CONFIG_RTC_CLASS=y
141CONFIG_RTC_DRV_DS1307=y
124CONFIG_RTC_DRV_CMOS=y 142CONFIG_RTC_DRV_CMOS=y
125CONFIG_DMADEVICES=y 143CONFIG_DMADEVICES=y
126CONFIG_FSL_DMA=y 144CONFIG_FSL_DMA=y
@@ -161,6 +179,7 @@ CONFIG_DEBUG_FS=y
161CONFIG_DETECT_HUNG_TASK=y 179CONFIG_DETECT_HUNG_TASK=y
162# CONFIG_DEBUG_BUGVERBOSE is not set 180# CONFIG_DEBUG_BUGVERBOSE is not set
163CONFIG_DEBUG_INFO=y 181CONFIG_DEBUG_INFO=y
182CONFIG_STRICT_DEVMEM=y
164CONFIG_CRYPTO_PCBC=m 183CONFIG_CRYPTO_PCBC=m
165CONFIG_CRYPTO_SHA256=y 184CONFIG_CRYPTO_SHA256=y
166CONFIG_CRYPTO_SHA512=y 185CONFIG_CRYPTO_SHA512=y
diff --git a/arch/powerpc/configs/corenet32_smp_defconfig b/arch/powerpc/configs/corenet32_smp_defconfig
index 60027c2a7034..3dfab4c40c76 100644
--- a/arch/powerpc/configs/corenet32_smp_defconfig
+++ b/arch/powerpc/configs/corenet32_smp_defconfig
@@ -70,6 +70,7 @@ CONFIG_IPV6=y
70CONFIG_IP_SCTP=m 70CONFIG_IP_SCTP=m
71CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 71CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
72CONFIG_DEVTMPFS=y 72CONFIG_DEVTMPFS=y
73CONFIG_DEVTMPFS_MOUNT=y
73CONFIG_MTD=y 74CONFIG_MTD=y
74CONFIG_MTD_CMDLINE_PARTS=y 75CONFIG_MTD_CMDLINE_PARTS=y
75CONFIG_MTD_CHAR=y 76CONFIG_MTD_CHAR=y
diff --git a/arch/powerpc/configs/corenet64_smp_defconfig b/arch/powerpc/configs/corenet64_smp_defconfig
index 6c8b020806ff..fa94fb3bb44d 100644
--- a/arch/powerpc/configs/corenet64_smp_defconfig
+++ b/arch/powerpc/configs/corenet64_smp_defconfig
@@ -27,6 +27,8 @@ CONFIG_P5040_DS=y
27CONFIG_T4240_QDS=y 27CONFIG_T4240_QDS=y
28# CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set 28# CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
29CONFIG_BINFMT_MISC=m 29CONFIG_BINFMT_MISC=m
30CONFIG_MATH_EMULATION=y
31CONFIG_MATH_EMULATION_HW_UNIMPLEMENTED=y
30CONFIG_FSL_IFC=y 32CONFIG_FSL_IFC=y
31CONFIG_PCIEPORTBUS=y 33CONFIG_PCIEPORTBUS=y
32CONFIG_PCI_MSI=y 34CONFIG_PCI_MSI=y
@@ -59,6 +61,7 @@ CONFIG_IPV6=y
59CONFIG_IP_SCTP=m 61CONFIG_IP_SCTP=m
60CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 62CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
61CONFIG_DEVTMPFS=y 63CONFIG_DEVTMPFS=y
64CONFIG_DEVTMPFS_MOUNT=y
62CONFIG_MTD=y 65CONFIG_MTD=y
63CONFIG_MTD_PARTITIONS=y 66CONFIG_MTD_PARTITIONS=y
64CONFIG_MTD_OF_PARTS=y 67CONFIG_MTD_OF_PARTS=y
diff --git a/arch/powerpc/configs/mpc83xx_defconfig b/arch/powerpc/configs/mpc83xx_defconfig
index 09116c6a6719..23fec79964cf 100644
--- a/arch/powerpc/configs/mpc83xx_defconfig
+++ b/arch/powerpc/configs/mpc83xx_defconfig
@@ -42,6 +42,7 @@ CONFIG_INET_ESP=y
42# CONFIG_IPV6 is not set 42# CONFIG_IPV6 is not set
43CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 43CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
44CONFIG_DEVTMPFS=y 44CONFIG_DEVTMPFS=y
45CONFIG_DEVTMPFS_MOUNT=y
45# CONFIG_FW_LOADER is not set 46# CONFIG_FW_LOADER is not set
46CONFIG_MTD=y 47CONFIG_MTD=y
47CONFIG_MTD_CHAR=y 48CONFIG_MTD_CHAR=y
diff --git a/arch/powerpc/configs/mpc85xx_defconfig b/arch/powerpc/configs/mpc85xx_defconfig
index 5a58882e351e..dc098d988211 100644
--- a/arch/powerpc/configs/mpc85xx_defconfig
+++ b/arch/powerpc/configs/mpc85xx_defconfig
@@ -27,6 +27,7 @@ CONFIG_MPC85xx_MDS=y
27CONFIG_MPC8536_DS=y 27CONFIG_MPC8536_DS=y
28CONFIG_MPC85xx_DS=y 28CONFIG_MPC85xx_DS=y
29CONFIG_MPC85xx_RDB=y 29CONFIG_MPC85xx_RDB=y
30CONFIG_C293_PCIE=y
30CONFIG_P1010_RDB=y 31CONFIG_P1010_RDB=y
31CONFIG_P1022_DS=y 32CONFIG_P1022_DS=y
32CONFIG_P1022_RDK=y 33CONFIG_P1022_RDK=y
@@ -78,6 +79,7 @@ CONFIG_IPV6=y
78CONFIG_IP_SCTP=m 79CONFIG_IP_SCTP=m
79CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 80CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
80CONFIG_DEVTMPFS=y 81CONFIG_DEVTMPFS=y
82CONFIG_DEVTMPFS_MOUNT=y
81CONFIG_MTD=y 83CONFIG_MTD=y
82CONFIG_MTD_PARTITIONS=y 84CONFIG_MTD_PARTITIONS=y
83CONFIG_MTD_OF_PARTS=y 85CONFIG_MTD_OF_PARTS=y
diff --git a/arch/powerpc/configs/mpc85xx_smp_defconfig b/arch/powerpc/configs/mpc85xx_smp_defconfig
index 152fa05b15e4..5bca60161bb3 100644
--- a/arch/powerpc/configs/mpc85xx_smp_defconfig
+++ b/arch/powerpc/configs/mpc85xx_smp_defconfig
@@ -30,6 +30,7 @@ CONFIG_MPC85xx_MDS=y
30CONFIG_MPC8536_DS=y 30CONFIG_MPC8536_DS=y
31CONFIG_MPC85xx_DS=y 31CONFIG_MPC85xx_DS=y
32CONFIG_MPC85xx_RDB=y 32CONFIG_MPC85xx_RDB=y
33CONFIG_C293_PCIE=y
33CONFIG_P1010_RDB=y 34CONFIG_P1010_RDB=y
34CONFIG_P1022_DS=y 35CONFIG_P1022_DS=y
35CONFIG_P1022_RDK=y 36CONFIG_P1022_RDK=y
@@ -81,6 +82,7 @@ CONFIG_IPV6=y
81CONFIG_IP_SCTP=m 82CONFIG_IP_SCTP=m
82CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 83CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
83CONFIG_DEVTMPFS=y 84CONFIG_DEVTMPFS=y
85CONFIG_DEVTMPFS_MOUNT=y
84CONFIG_MTD=y 86CONFIG_MTD=y
85CONFIG_MTD_PARTITIONS=y 87CONFIG_MTD_PARTITIONS=y
86CONFIG_MTD_OF_PARTS=y 88CONFIG_MTD_OF_PARTS=y
diff --git a/arch/powerpc/include/asm/asm-compat.h b/arch/powerpc/include/asm/asm-compat.h
index 6e82f5f9a6fd..4b237aa35660 100644
--- a/arch/powerpc/include/asm/asm-compat.h
+++ b/arch/powerpc/include/asm/asm-compat.h
@@ -32,6 +32,15 @@
32#define PPC_MTOCRF(FXM, RS) MTOCRF((FXM), RS) 32#define PPC_MTOCRF(FXM, RS) MTOCRF((FXM), RS)
33#define PPC_LR_STKOFF 16 33#define PPC_LR_STKOFF 16
34#define PPC_MIN_STKFRM 112 34#define PPC_MIN_STKFRM 112
35
36#ifdef __BIG_ENDIAN__
37#define LDX_BE stringify_in_c(ldx)
38#define STDX_BE stringify_in_c(stdx)
39#else
40#define LDX_BE stringify_in_c(ldbrx)
41#define STDX_BE stringify_in_c(stdbrx)
42#endif
43
35#else /* 32-bit */ 44#else /* 32-bit */
36 45
37/* operations for longs and pointers */ 46/* operations for longs and pointers */
diff --git a/arch/powerpc/include/asm/btext.h b/arch/powerpc/include/asm/btext.h
index 906f46e31006..89fc382648bc 100644
--- a/arch/powerpc/include/asm/btext.h
+++ b/arch/powerpc/include/asm/btext.h
@@ -13,6 +13,7 @@ extern void btext_update_display(unsigned long phys, int width, int height,
13extern void btext_setup_display(int width, int height, int depth, int pitch, 13extern void btext_setup_display(int width, int height, int depth, int pitch,
14 unsigned long address); 14 unsigned long address);
15extern void btext_prepare_BAT(void); 15extern void btext_prepare_BAT(void);
16extern void btext_map(void);
16extern void btext_unmap(void); 17extern void btext_unmap(void);
17 18
18extern void btext_drawchar(char c); 19extern void btext_drawchar(char c);
diff --git a/arch/powerpc/include/asm/cacheflush.h b/arch/powerpc/include/asm/cacheflush.h
index b843e35122e8..5b9312220e84 100644
--- a/arch/powerpc/include/asm/cacheflush.h
+++ b/arch/powerpc/include/asm/cacheflush.h
@@ -32,13 +32,7 @@ extern void flush_dcache_page(struct page *page);
32 32
33extern void __flush_disable_L1(void); 33extern void __flush_disable_L1(void);
34 34
35extern void __flush_icache_range(unsigned long, unsigned long); 35extern void flush_icache_range(unsigned long, unsigned long);
36static inline void flush_icache_range(unsigned long start, unsigned long stop)
37{
38 if (!cpu_has_feature(CPU_FTR_COHERENT_ICACHE))
39 __flush_icache_range(start, stop);
40}
41
42extern void flush_icache_user_range(struct vm_area_struct *vma, 36extern void flush_icache_user_range(struct vm_area_struct *vma,
43 struct page *page, unsigned long addr, 37 struct page *page, unsigned long addr,
44 int len); 38 int len);
diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h
index 6f3887d884d2..0d4939ba48e7 100644
--- a/arch/powerpc/include/asm/cputable.h
+++ b/arch/powerpc/include/asm/cputable.h
@@ -371,14 +371,19 @@ extern const char *powerpc_base_platform;
371#define CPU_FTRS_E500MC (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | \ 371#define CPU_FTRS_E500MC (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | \
372 CPU_FTR_L2CSR | CPU_FTR_LWSYNC | CPU_FTR_NOEXECUTE | \ 372 CPU_FTR_L2CSR | CPU_FTR_LWSYNC | CPU_FTR_NOEXECUTE | \
373 CPU_FTR_DBELL | CPU_FTR_DEBUG_LVL_EXC | CPU_FTR_EMB_HV) 373 CPU_FTR_DBELL | CPU_FTR_DEBUG_LVL_EXC | CPU_FTR_EMB_HV)
374/*
375 * e5500/e6500 erratum A-006958 is a timebase bug that can use the
376 * same workaround as CPU_FTR_CELL_TB_BUG.
377 */
374#define CPU_FTRS_E5500 (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | \ 378#define CPU_FTRS_E5500 (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | \
375 CPU_FTR_L2CSR | CPU_FTR_LWSYNC | CPU_FTR_NOEXECUTE | \ 379 CPU_FTR_L2CSR | CPU_FTR_LWSYNC | CPU_FTR_NOEXECUTE | \
376 CPU_FTR_DBELL | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \ 380 CPU_FTR_DBELL | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
377 CPU_FTR_DEBUG_LVL_EXC | CPU_FTR_EMB_HV) 381 CPU_FTR_DEBUG_LVL_EXC | CPU_FTR_EMB_HV | CPU_FTR_CELL_TB_BUG)
378#define CPU_FTRS_E6500 (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | \ 382#define CPU_FTRS_E6500 (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | \
379 CPU_FTR_L2CSR | CPU_FTR_LWSYNC | CPU_FTR_NOEXECUTE | \ 383 CPU_FTR_L2CSR | CPU_FTR_LWSYNC | CPU_FTR_NOEXECUTE | \
380 CPU_FTR_DBELL | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \ 384 CPU_FTR_DBELL | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
381 CPU_FTR_DEBUG_LVL_EXC | CPU_FTR_EMB_HV | CPU_FTR_ALTIVEC_COMP) 385 CPU_FTR_DEBUG_LVL_EXC | CPU_FTR_EMB_HV | CPU_FTR_ALTIVEC_COMP | \
386 CPU_FTR_CELL_TB_BUG)
382#define CPU_FTRS_GENERIC_32 (CPU_FTR_COMMON | CPU_FTR_NODSISRALIGN) 387#define CPU_FTRS_GENERIC_32 (CPU_FTR_COMMON | CPU_FTR_NODSISRALIGN)
383 388
384/* 64-bit CPUs */ 389/* 64-bit CPUs */
diff --git a/arch/powerpc/include/asm/emulated_ops.h b/arch/powerpc/include/asm/emulated_ops.h
index 63f2a22e9954..5a8b82aa7241 100644
--- a/arch/powerpc/include/asm/emulated_ops.h
+++ b/arch/powerpc/include/asm/emulated_ops.h
@@ -46,8 +46,6 @@ extern struct ppc_emulated {
46 struct ppc_emulated_entry unaligned; 46 struct ppc_emulated_entry unaligned;
47#ifdef CONFIG_MATH_EMULATION 47#ifdef CONFIG_MATH_EMULATION
48 struct ppc_emulated_entry math; 48 struct ppc_emulated_entry math;
49#elif defined(CONFIG_8XX_MINIMAL_FPEMU)
50 struct ppc_emulated_entry 8xx;
51#endif 49#endif
52#ifdef CONFIG_VSX 50#ifdef CONFIG_VSX
53 struct ppc_emulated_entry vsx; 51 struct ppc_emulated_entry vsx;
diff --git a/arch/powerpc/include/asm/epapr_hcalls.h b/arch/powerpc/include/asm/epapr_hcalls.h
index d3d634274d2c..86b0ac79990c 100644
--- a/arch/powerpc/include/asm/epapr_hcalls.h
+++ b/arch/powerpc/include/asm/epapr_hcalls.h
@@ -105,6 +105,12 @@
105extern bool epapr_paravirt_enabled; 105extern bool epapr_paravirt_enabled;
106extern u32 epapr_hypercall_start[]; 106extern u32 epapr_hypercall_start[];
107 107
108#ifdef CONFIG_EPAPR_PARAVIRT
109int __init epapr_paravirt_early_init(void);
110#else
111static inline int epapr_paravirt_early_init(void) { return 0; }
112#endif
113
108/* 114/*
109 * We use "uintptr_t" to define a register because it's guaranteed to be a 115 * We use "uintptr_t" to define a register because it's guaranteed to be a
110 * 32-bit integer on a 32-bit platform, and a 64-bit integer on a 64-bit 116 * 32-bit integer on a 32-bit platform, and a 64-bit integer on a 64-bit
diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h
index 07ca627e52c0..cca12f084842 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -48,17 +48,18 @@
48#define EX_LR 72 48#define EX_LR 72
49#define EX_CFAR 80 49#define EX_CFAR 80
50#define EX_PPR 88 /* SMT thread status register (priority) */ 50#define EX_PPR 88 /* SMT thread status register (priority) */
51#define EX_CTR 96
51 52
52#ifdef CONFIG_RELOCATABLE 53#ifdef CONFIG_RELOCATABLE
53#define __EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \ 54#define __EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \
54 ld r12,PACAKBASE(r13); /* get high part of &label */ \ 55 ld r12,PACAKBASE(r13); /* get high part of &label */ \
55 mfspr r11,SPRN_##h##SRR0; /* save SRR0 */ \ 56 mfspr r11,SPRN_##h##SRR0; /* save SRR0 */ \
56 LOAD_HANDLER(r12,label); \ 57 LOAD_HANDLER(r12,label); \
57 mtlr r12; \ 58 mtctr r12; \
58 mfspr r12,SPRN_##h##SRR1; /* and SRR1 */ \ 59 mfspr r12,SPRN_##h##SRR1; /* and SRR1 */ \
59 li r10,MSR_RI; \ 60 li r10,MSR_RI; \
60 mtmsrd r10,1; /* Set RI (EE=0) */ \ 61 mtmsrd r10,1; /* Set RI (EE=0) */ \
61 blr; 62 bctr;
62#else 63#else
63/* If not relocatable, we can jump directly -- and save messing with LR */ 64/* If not relocatable, we can jump directly -- and save messing with LR */
64#define __EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \ 65#define __EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \
@@ -97,18 +98,18 @@
97 98
98#if defined(CONFIG_RELOCATABLE) 99#if defined(CONFIG_RELOCATABLE)
99/* 100/*
100 * If we support interrupts with relocation on AND we're a relocatable 101 * If we support interrupts with relocation on AND we're a relocatable kernel,
101 * kernel, we need to use LR to get to the 2nd level handler. So, save/restore 102 * we need to use CTR to get to the 2nd level handler. So, save/restore it
102 * it when required. 103 * when required.
103 */ 104 */
104#define SAVE_LR(reg, area) mflr reg ; std reg,area+EX_LR(r13) 105#define SAVE_CTR(reg, area) mfctr reg ; std reg,area+EX_CTR(r13)
105#define GET_LR(reg, area) ld reg,area+EX_LR(r13) 106#define GET_CTR(reg, area) ld reg,area+EX_CTR(r13)
106#define RESTORE_LR(reg, area) ld reg,area+EX_LR(r13) ; mtlr reg 107#define RESTORE_CTR(reg, area) ld reg,area+EX_CTR(r13) ; mtctr reg
107#else 108#else
108/* ...else LR is unused and in register. */ 109/* ...else CTR is unused and in register. */
109#define SAVE_LR(reg, area) 110#define SAVE_CTR(reg, area)
110#define GET_LR(reg, area) mflr reg 111#define GET_CTR(reg, area) mfctr reg
111#define RESTORE_LR(reg, area) 112#define RESTORE_CTR(reg, area)
112#endif 113#endif
113 114
114/* 115/*
@@ -164,7 +165,7 @@ END_FTR_SECTION_NESTED(ftr,ftr,943)
164#define __EXCEPTION_PROLOG_1(area, extra, vec) \ 165#define __EXCEPTION_PROLOG_1(area, extra, vec) \
165 OPT_SAVE_REG_TO_PACA(area+EX_PPR, r9, CPU_FTR_HAS_PPR); \ 166 OPT_SAVE_REG_TO_PACA(area+EX_PPR, r9, CPU_FTR_HAS_PPR); \
166 OPT_SAVE_REG_TO_PACA(area+EX_CFAR, r10, CPU_FTR_CFAR); \ 167 OPT_SAVE_REG_TO_PACA(area+EX_CFAR, r10, CPU_FTR_CFAR); \
167 SAVE_LR(r10, area); \ 168 SAVE_CTR(r10, area); \
168 mfcr r9; \ 169 mfcr r9; \
169 extra(vec); \ 170 extra(vec); \
170 std r11,area+EX_R11(r13); \ 171 std r11,area+EX_R11(r13); \
@@ -270,7 +271,7 @@ do_kvm_##n: \
270 sth r1,PACA_TRAP_SAVE(r13); \ 271 sth r1,PACA_TRAP_SAVE(r13); \
271 std r3,area+EX_R3(r13); \ 272 std r3,area+EX_R3(r13); \
272 addi r3,r13,area; /* r3 -> where regs are saved*/ \ 273 addi r3,r13,area; /* r3 -> where regs are saved*/ \
273 RESTORE_LR(r1, area); \ 274 RESTORE_CTR(r1, area); \
274 b bad_stack; \ 275 b bad_stack; \
2753: std r9,_CCR(r1); /* save CR in stackframe */ \ 2763: std r9,_CCR(r1); /* save CR in stackframe */ \
276 std r11,_NIP(r1); /* save SRR0 in stackframe */ \ 277 std r11,_NIP(r1); /* save SRR0 in stackframe */ \
@@ -298,10 +299,10 @@ do_kvm_##n: \
298 ld r10,area+EX_CFAR(r13); \ 299 ld r10,area+EX_CFAR(r13); \
299 std r10,ORIG_GPR3(r1); \ 300 std r10,ORIG_GPR3(r1); \
300 END_FTR_SECTION_NESTED(CPU_FTR_CFAR, CPU_FTR_CFAR, 66); \ 301 END_FTR_SECTION_NESTED(CPU_FTR_CFAR, CPU_FTR_CFAR, 66); \
301 GET_LR(r9,area); /* Get LR, later save to stack */ \ 302 mflr r9; /* Get LR, later save to stack */ \
302 ld r2,PACATOC(r13); /* get kernel TOC into r2 */ \ 303 ld r2,PACATOC(r13); /* get kernel TOC into r2 */ \
303 std r9,_LINK(r1); \ 304 std r9,_LINK(r1); \
304 mfctr r10; /* save CTR in stackframe */ \ 305 GET_CTR(r10, area); \
305 std r10,_CTR(r1); \ 306 std r10,_CTR(r1); \
306 lbz r10,PACASOFTIRQEN(r13); \ 307 lbz r10,PACASOFTIRQEN(r13); \
307 mfspr r11,SPRN_XER; /* save XER in stackframe */ \ 308 mfspr r11,SPRN_XER; /* save XER in stackframe */ \
@@ -479,7 +480,7 @@ label##_relon_hv: \
479 */ 480 */
480 481
481/* Exception addition: Hard disable interrupts */ 482/* Exception addition: Hard disable interrupts */
482#define DISABLE_INTS SOFT_DISABLE_INTS(r10,r11) 483#define DISABLE_INTS RECONCILE_IRQ_STATE(r10,r11)
483 484
484#define ADD_NVGPRS \ 485#define ADD_NVGPRS \
485 bl .save_nvgprs 486 bl .save_nvgprs
diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index dd15e5e37d6d..5a64757dc0d1 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -69,8 +69,18 @@ extern unsigned long pci_dram_offset;
69 69
70extern resource_size_t isa_mem_base; 70extern resource_size_t isa_mem_base;
71 71
72#if defined(CONFIG_PPC32) && defined(CONFIG_PPC_INDIRECT_IO) 72/* Boolean set by platform if PIO accesses are suppored while _IO_BASE
73#error CONFIG_PPC_INDIRECT_IO is not yet supported on 32 bits 73 * is not set or addresses cannot be translated to MMIO. This is typically
74 * set when the platform supports "special" PIO accesses via a non memory
75 * mapped mechanism, and allows things like the early udbg UART code to
76 * function.
77 */
78extern bool isa_io_special;
79
80#ifdef CONFIG_PPC32
81#if defined(CONFIG_PPC_INDIRECT_PIO) || defined(CONFIG_PPC_INDIRECT_MMIO)
82#error CONFIG_PPC_INDIRECT_{PIO,MMIO} are not yet supported on 32 bits
83#endif
74#endif 84#endif
75 85
76/* 86/*
@@ -222,9 +232,9 @@ extern void _memcpy_toio(volatile void __iomem *dest, const void *src,
222 * for PowerPC is as close as possible to the x86 version of these, and thus 232 * for PowerPC is as close as possible to the x86 version of these, and thus
223 * provides fairly heavy weight barriers for the non-raw versions 233 * provides fairly heavy weight barriers for the non-raw versions
224 * 234 *
225 * In addition, they support a hook mechanism when CONFIG_PPC_INDIRECT_IO 235 * In addition, they support a hook mechanism when CONFIG_PPC_INDIRECT_MMIO
226 * allowing the platform to provide its own implementation of some or all 236 * or CONFIG_PPC_INDIRECT_PIO are set allowing the platform to provide its
227 * of the accessors. 237 * own implementation of some or all of the accessors.
228 */ 238 */
229 239
230/* 240/*
@@ -240,8 +250,8 @@ extern void _memcpy_toio(volatile void __iomem *dest, const void *src,
240 250
241/* Indirect IO address tokens: 251/* Indirect IO address tokens:
242 * 252 *
243 * When CONFIG_PPC_INDIRECT_IO is set, the platform can provide hooks 253 * When CONFIG_PPC_INDIRECT_MMIO is set, the platform can provide hooks
244 * on all IOs. (Note that this is all 64 bits only for now) 254 * on all MMIOs. (Note that this is all 64 bits only for now)
245 * 255 *
246 * To help platforms who may need to differenciate MMIO addresses in 256 * To help platforms who may need to differenciate MMIO addresses in
247 * their hooks, a bitfield is reserved for use by the platform near the 257 * their hooks, a bitfield is reserved for use by the platform near the
@@ -263,11 +273,14 @@ extern void _memcpy_toio(volatile void __iomem *dest, const void *src,
263 * 273 *
264 * The direct IO mapping operations will then mask off those bits 274 * The direct IO mapping operations will then mask off those bits
265 * before doing the actual access, though that only happen when 275 * before doing the actual access, though that only happen when
266 * CONFIG_PPC_INDIRECT_IO is set, thus be careful when you use that 276 * CONFIG_PPC_INDIRECT_MMIO is set, thus be careful when you use that
267 * mechanism 277 * mechanism
278 *
279 * For PIO, there is a separate CONFIG_PPC_INDIRECT_PIO which makes
280 * all PIO functions call through a hook.
268 */ 281 */
269 282
270#ifdef CONFIG_PPC_INDIRECT_IO 283#ifdef CONFIG_PPC_INDIRECT_MMIO
271#define PCI_IO_IND_TOKEN_MASK 0x0fff000000000000ul 284#define PCI_IO_IND_TOKEN_MASK 0x0fff000000000000ul
272#define PCI_IO_IND_TOKEN_SHIFT 48 285#define PCI_IO_IND_TOKEN_SHIFT 48
273#define PCI_FIX_ADDR(addr) \ 286#define PCI_FIX_ADDR(addr) \
@@ -672,7 +685,7 @@ extern void __iomem * __ioremap_at(phys_addr_t pa, void *ea,
672extern void __iounmap_at(void *ea, unsigned long size); 685extern void __iounmap_at(void *ea, unsigned long size);
673 686
674/* 687/*
675 * When CONFIG_PPC_INDIRECT_IO is set, we use the generic iomap implementation 688 * When CONFIG_PPC_INDIRECT_PIO is set, we use the generic iomap implementation
676 * which needs some additional definitions here. They basically allow PIO 689 * which needs some additional definitions here. They basically allow PIO
677 * space overall to be 1GB. This will work as long as we never try to use 690 * space overall to be 1GB. This will work as long as we never try to use
678 * iomap to map MMIO below 1GB which should be fine on ppc64 691 * iomap to map MMIO below 1GB which should be fine on ppc64
diff --git a/arch/powerpc/include/asm/irqflags.h b/arch/powerpc/include/asm/irqflags.h
index 6f9b6e23dc5a..f51a5580bfd0 100644
--- a/arch/powerpc/include/asm/irqflags.h
+++ b/arch/powerpc/include/asm/irqflags.h
@@ -40,9 +40,10 @@
40#define TRACE_DISABLE_INTS TRACE_WITH_FRAME_BUFFER(.trace_hardirqs_off) 40#define TRACE_DISABLE_INTS TRACE_WITH_FRAME_BUFFER(.trace_hardirqs_off)
41 41
42/* 42/*
43 * This is used by assembly code to soft-disable interrupts 43 * This is used by assembly code to soft-disable interrupts first and
44 * reconcile irq state.
44 */ 45 */
45#define SOFT_DISABLE_INTS(__rA, __rB) \ 46#define RECONCILE_IRQ_STATE(__rA, __rB) \
46 lbz __rA,PACASOFTIRQEN(r13); \ 47 lbz __rA,PACASOFTIRQEN(r13); \
47 lbz __rB,PACAIRQHAPPENED(r13); \ 48 lbz __rB,PACAIRQHAPPENED(r13); \
48 cmpwi cr0,__rA,0; \ 49 cmpwi cr0,__rA,0; \
@@ -58,7 +59,7 @@
58#define TRACE_ENABLE_INTS 59#define TRACE_ENABLE_INTS
59#define TRACE_DISABLE_INTS 60#define TRACE_DISABLE_INTS
60 61
61#define SOFT_DISABLE_INTS(__rA, __rB) \ 62#define RECONCILE_IRQ_STATE(__rA, __rB) \
62 lbz __rA,PACAIRQHAPPENED(r13); \ 63 lbz __rA,PACAIRQHAPPENED(r13); \
63 li __rB,0; \ 64 li __rB,0; \
64 ori __rA,__rA,PACA_IRQ_HARD_DIS; \ 65 ori __rA,__rA,PACA_IRQ_HARD_DIS; \
diff --git a/arch/powerpc/include/asm/lppaca.h b/arch/powerpc/include/asm/lppaca.h
index 9b12f88d4adb..4470d1e34d23 100644
--- a/arch/powerpc/include/asm/lppaca.h
+++ b/arch/powerpc/include/asm/lppaca.h
@@ -48,15 +48,13 @@
48struct lppaca { 48struct lppaca {
49 /* cacheline 1 contains read-only data */ 49 /* cacheline 1 contains read-only data */
50 50
51 u32 desc; /* Eye catcher 0xD397D781 */ 51 __be32 desc; /* Eye catcher 0xD397D781 */
52 u16 size; /* Size of this struct */ 52 __be16 size; /* Size of this struct */
53 u16 reserved1; 53 u8 reserved1[3];
54 u16 reserved2:14; 54 u8 __old_status; /* Old status, including shared proc */
55 u8 shared_proc:1; /* Shared processor indicator */
56 u8 secondary_thread:1; /* Secondary thread indicator */
57 u8 reserved3[14]; 55 u8 reserved3[14];
58 volatile u32 dyn_hw_node_id; /* Dynamic hardware node id */ 56 volatile __be32 dyn_hw_node_id; /* Dynamic hardware node id */
59 volatile u32 dyn_hw_proc_id; /* Dynamic hardware proc id */ 57 volatile __be32 dyn_hw_proc_id; /* Dynamic hardware proc id */
60 u8 reserved4[56]; 58 u8 reserved4[56];
61 volatile u8 vphn_assoc_counts[8]; /* Virtual processor home node */ 59 volatile u8 vphn_assoc_counts[8]; /* Virtual processor home node */
62 /* associativity change counters */ 60 /* associativity change counters */
@@ -73,9 +71,9 @@ struct lppaca {
73 u8 fpregs_in_use; 71 u8 fpregs_in_use;
74 u8 pmcregs_in_use; 72 u8 pmcregs_in_use;
75 u8 reserved8[28]; 73 u8 reserved8[28];
76 u64 wait_state_cycles; /* Wait cycles for this proc */ 74 __be64 wait_state_cycles; /* Wait cycles for this proc */
77 u8 reserved9[28]; 75 u8 reserved9[28];
78 u16 slb_count; /* # of SLBs to maintain */ 76 __be16 slb_count; /* # of SLBs to maintain */
79 u8 idle; /* Indicate OS is idle */ 77 u8 idle; /* Indicate OS is idle */
80 u8 vmxregs_in_use; 78 u8 vmxregs_in_use;
81 79
@@ -89,17 +87,17 @@ struct lppaca {
89 * NOTE: This value will ALWAYS be zero for dedicated processors and 87 * NOTE: This value will ALWAYS be zero for dedicated processors and
90 * will NEVER be zero for shared processors (ie, initialized to a 1). 88 * will NEVER be zero for shared processors (ie, initialized to a 1).
91 */ 89 */
92 volatile u32 yield_count; 90 volatile __be32 yield_count;
93 volatile u32 dispersion_count; /* dispatch changed physical cpu */ 91 volatile __be32 dispersion_count; /* dispatch changed physical cpu */
94 volatile u64 cmo_faults; /* CMO page fault count */ 92 volatile __be64 cmo_faults; /* CMO page fault count */
95 volatile u64 cmo_fault_time; /* CMO page fault time */ 93 volatile __be64 cmo_fault_time; /* CMO page fault time */
96 u8 reserved10[104]; 94 u8 reserved10[104];
97 95
98 /* cacheline 4-5 */ 96 /* cacheline 4-5 */
99 97
100 u32 page_ins; /* CMO Hint - # page ins by OS */ 98 __be32 page_ins; /* CMO Hint - # page ins by OS */
101 u8 reserved11[148]; 99 u8 reserved11[148];
102 volatile u64 dtl_idx; /* Dispatch Trace Log head index */ 100 volatile __be64 dtl_idx; /* Dispatch Trace Log head index */
103 u8 reserved12[96]; 101 u8 reserved12[96];
104} __attribute__((__aligned__(0x400))); 102} __attribute__((__aligned__(0x400)));
105 103
@@ -108,17 +106,29 @@ extern struct lppaca lppaca[];
108#define lppaca_of(cpu) (*paca[cpu].lppaca_ptr) 106#define lppaca_of(cpu) (*paca[cpu].lppaca_ptr)
109 107
110/* 108/*
109 * Old kernels used a reserved bit in the VPA to determine if it was running
110 * in shared processor mode. New kernels look for a non zero yield count
111 * but KVM still needs to set the bit to keep the old stuff happy.
112 */
113#define LPPACA_OLD_SHARED_PROC 2
114
115static inline bool lppaca_shared_proc(struct lppaca *l)
116{
117 return l->yield_count != 0;
118}
119
120/*
111 * SLB shadow buffer structure as defined in the PAPR. The save_area 121 * SLB shadow buffer structure as defined in the PAPR. The save_area
112 * contains adjacent ESID and VSID pairs for each shadowed SLB. The 122 * contains adjacent ESID and VSID pairs for each shadowed SLB. The
113 * ESID is stored in the lower 64bits, then the VSID. 123 * ESID is stored in the lower 64bits, then the VSID.
114 */ 124 */
115struct slb_shadow { 125struct slb_shadow {
116 u32 persistent; /* Number of persistent SLBs */ 126 __be32 persistent; /* Number of persistent SLBs */
117 u32 buffer_length; /* Total shadow buffer length */ 127 __be32 buffer_length; /* Total shadow buffer length */
118 u64 reserved; 128 __be64 reserved;
119 struct { 129 struct {
120 u64 esid; 130 __be64 esid;
121 u64 vsid; 131 __be64 vsid;
122 } save_area[SLB_NUM_BOLTED]; 132 } save_area[SLB_NUM_BOLTED];
123} ____cacheline_aligned; 133} ____cacheline_aligned;
124 134
@@ -130,14 +140,14 @@ extern struct slb_shadow slb_shadow[];
130struct dtl_entry { 140struct dtl_entry {
131 u8 dispatch_reason; 141 u8 dispatch_reason;
132 u8 preempt_reason; 142 u8 preempt_reason;
133 u16 processor_id; 143 __be16 processor_id;
134 u32 enqueue_to_dispatch_time; 144 __be32 enqueue_to_dispatch_time;
135 u32 ready_to_enqueue_time; 145 __be32 ready_to_enqueue_time;
136 u32 waiting_to_ready_time; 146 __be32 waiting_to_ready_time;
137 u64 timebase; 147 __be64 timebase;
138 u64 fault_addr; 148 __be64 fault_addr;
139 u64 srr0; 149 __be64 srr0;
140 u64 srr1; 150 __be64 srr1;
141}; 151};
142 152
143#define DISPATCH_LOG_BYTES 4096 /* bytes per cpu */ 153#define DISPATCH_LOG_BYTES 4096 /* bytes per cpu */
diff --git a/arch/powerpc/include/asm/mpc5121.h b/arch/powerpc/include/asm/mpc5121.h
index 8ae133eaf9fa..887d3d6133e3 100644
--- a/arch/powerpc/include/asm/mpc5121.h
+++ b/arch/powerpc/include/asm/mpc5121.h
@@ -32,25 +32,11 @@ struct mpc512x_ccm {
32 u32 scfr2; /* System Clock Frequency Register 2 */ 32 u32 scfr2; /* System Clock Frequency Register 2 */
33 u32 scfr2s; /* System Clock Frequency Shadow Register 2 */ 33 u32 scfr2s; /* System Clock Frequency Shadow Register 2 */
34 u32 bcr; /* Bread Crumb Register */ 34 u32 bcr; /* Bread Crumb Register */
35 u32 p0ccr; /* PSC0 Clock Control Register */ 35 u32 psc_ccr[12]; /* PSC Clock Control Registers */
36 u32 p1ccr; /* PSC1 CCR */
37 u32 p2ccr; /* PSC2 CCR */
38 u32 p3ccr; /* PSC3 CCR */
39 u32 p4ccr; /* PSC4 CCR */
40 u32 p5ccr; /* PSC5 CCR */
41 u32 p6ccr; /* PSC6 CCR */
42 u32 p7ccr; /* PSC7 CCR */
43 u32 p8ccr; /* PSC8 CCR */
44 u32 p9ccr; /* PSC9 CCR */
45 u32 p10ccr; /* PSC10 CCR */
46 u32 p11ccr; /* PSC11 CCR */
47 u32 spccr; /* SPDIF Clock Control Register */ 36 u32 spccr; /* SPDIF Clock Control Register */
48 u32 cccr; /* CFM Clock Control Register */ 37 u32 cccr; /* CFM Clock Control Register */
49 u32 dccr; /* DIU Clock Control Register */ 38 u32 dccr; /* DIU Clock Control Register */
50 u32 m1ccr; /* MSCAN1 CCR */ 39 u32 mscan_ccr[4]; /* MSCAN Clock Control Registers */
51 u32 m2ccr; /* MSCAN2 CCR */
52 u32 m3ccr; /* MSCAN3 CCR */
53 u32 m4ccr; /* MSCAN4 CCR */
54 u8 res[0x98]; /* Reserved */ 40 u8 res[0x98]; /* Reserved */
55}; 41};
56 42
diff --git a/arch/powerpc/include/asm/mpc85xx.h b/arch/powerpc/include/asm/mpc85xx.h
new file mode 100644
index 000000000000..736d4acc05a8
--- /dev/null
+++ b/arch/powerpc/include/asm/mpc85xx.h
@@ -0,0 +1,92 @@
1/*
2 * MPC85xx cpu type detection
3 *
4 * Copyright 2011-2012 Freescale Semiconductor, Inc.
5 *
6 * This 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
12#ifndef __ASM_PPC_MPC85XX_H
13#define __ASM_PPC_MPC85XX_H
14
15#define SVR_REV(svr) ((svr) & 0xFF) /* SOC design resision */
16#define SVR_MAJ(svr) (((svr) >> 4) & 0xF) /* Major revision field*/
17#define SVR_MIN(svr) (((svr) >> 0) & 0xF) /* Minor revision field*/
18
19/* Some parts define SVR[0:23] as the SOC version */
20#define SVR_SOC_VER(svr) (((svr) >> 8) & 0xFFF7FF) /* SOC Version fields */
21
22#define SVR_8533 0x803400
23#define SVR_8535 0x803701
24#define SVR_8536 0x803700
25#define SVR_8540 0x803000
26#define SVR_8541 0x807200
27#define SVR_8543 0x803200
28#define SVR_8544 0x803401
29#define SVR_8545 0x803102
30#define SVR_8547 0x803101
31#define SVR_8548 0x803100
32#define SVR_8555 0x807100
33#define SVR_8560 0x807000
34#define SVR_8567 0x807501
35#define SVR_8568 0x807500
36#define SVR_8569 0x808000
37#define SVR_8572 0x80E000
38#define SVR_P1010 0x80F100
39#define SVR_P1011 0x80E500
40#define SVR_P1012 0x80E501
41#define SVR_P1013 0x80E700
42#define SVR_P1014 0x80F101
43#define SVR_P1017 0x80F700
44#define SVR_P1020 0x80E400
45#define SVR_P1021 0x80E401
46#define SVR_P1022 0x80E600
47#define SVR_P1023 0x80F600
48#define SVR_P1024 0x80E402
49#define SVR_P1025 0x80E403
50#define SVR_P2010 0x80E300
51#define SVR_P2020 0x80E200
52#define SVR_P2040 0x821000
53#define SVR_P2041 0x821001
54#define SVR_P3041 0x821103
55#define SVR_P4040 0x820100
56#define SVR_P4080 0x820000
57#define SVR_P5010 0x822100
58#define SVR_P5020 0x822000
59#define SVR_P5021 0X820500
60#define SVR_P5040 0x820400
61#define SVR_T4240 0x824000
62#define SVR_T4120 0x824001
63#define SVR_T4160 0x824100
64#define SVR_C291 0x850000
65#define SVR_C292 0x850020
66#define SVR_C293 0x850030
67#define SVR_B4860 0X868000
68#define SVR_G4860 0x868001
69#define SVR_G4060 0x868003
70#define SVR_B4440 0x868100
71#define SVR_G4440 0x868101
72#define SVR_B4420 0x868102
73#define SVR_B4220 0x868103
74#define SVR_T1040 0x852000
75#define SVR_T1041 0x852001
76#define SVR_T1042 0x852002
77#define SVR_T1020 0x852100
78#define SVR_T1021 0x852101
79#define SVR_T1022 0x852102
80
81#define SVR_8610 0x80A000
82#define SVR_8641 0x809000
83#define SVR_8641D 0x809001
84
85#define SVR_9130 0x860001
86#define SVR_9131 0x860000
87#define SVR_9132 0x861000
88#define SVR_9232 0x861400
89
90#define SVR_Unknown 0xFFFFFF
91
92#endif
diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
index 4a1ac9fbf186..754f93d208fa 100644
--- a/arch/powerpc/include/asm/mpic.h
+++ b/arch/powerpc/include/asm/mpic.h
@@ -396,7 +396,14 @@ extern struct bus_type mpic_subsys;
396#define MPIC_REGSET_TSI108 MPIC_REGSET(1) /* Tsi108/109 PIC */ 396#define MPIC_REGSET_TSI108 MPIC_REGSET(1) /* Tsi108/109 PIC */
397 397
398/* Get the version of primary MPIC */ 398/* Get the version of primary MPIC */
399#ifdef CONFIG_MPIC
399extern u32 fsl_mpic_primary_get_version(void); 400extern u32 fsl_mpic_primary_get_version(void);
401#else
402static inline u32 fsl_mpic_primary_get_version(void)
403{
404 return 0;
405}
406#endif
400 407
401/* Allocate the controller structure and setup the linux irq descs 408/* Allocate the controller structure and setup the linux irq descs
402 * for the range if interrupts passed in. No HW initialization is 409 * for the range if interrupts passed in. No HW initialization is
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 029fe85722aa..c5cd72833d6e 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -124,6 +124,11 @@ extern int opal_enter_rtas(struct rtas_args *args,
124#define OPAL_PCI_POLL 62 124#define OPAL_PCI_POLL 62
125#define OPAL_PCI_MSI_EOI 63 125#define OPAL_PCI_MSI_EOI 63
126#define OPAL_PCI_GET_PHB_DIAG_DATA2 64 126#define OPAL_PCI_GET_PHB_DIAG_DATA2 64
127#define OPAL_XSCOM_READ 65
128#define OPAL_XSCOM_WRITE 66
129#define OPAL_LPC_READ 67
130#define OPAL_LPC_WRITE 68
131#define OPAL_RETURN_CPU 69
127 132
128#ifndef __ASSEMBLY__ 133#ifndef __ASSEMBLY__
129 134
@@ -337,6 +342,17 @@ enum OpalEpowStatus {
337 OPAL_EPOW_OVER_INTERNAL_TEMP = 3 342 OPAL_EPOW_OVER_INTERNAL_TEMP = 3
338}; 343};
339 344
345/*
346 * Address cycle types for LPC accesses. These also correspond
347 * to the content of the first cell of the "reg" property for
348 * device nodes on the LPC bus
349 */
350enum OpalLPCAddressType {
351 OPAL_LPC_MEM = 0,
352 OPAL_LPC_IO = 1,
353 OPAL_LPC_FW = 2,
354};
355
340struct opal_machine_check_event { 356struct opal_machine_check_event {
341 enum OpalMCE_Version version:8; /* 0x00 */ 357 enum OpalMCE_Version version:8; /* 0x00 */
342 uint8_t in_use; /* 0x01 */ 358 uint8_t in_use; /* 0x01 */
@@ -631,6 +647,15 @@ int64_t opal_set_system_attention_led(uint8_t led_action);
631int64_t opal_pci_next_error(uint64_t phb_id, uint64_t *first_frozen_pe, 647int64_t opal_pci_next_error(uint64_t phb_id, uint64_t *first_frozen_pe,
632 uint16_t *pci_error_type, uint16_t *severity); 648 uint16_t *pci_error_type, uint16_t *severity);
633int64_t opal_pci_poll(uint64_t phb_id); 649int64_t opal_pci_poll(uint64_t phb_id);
650int64_t opal_return_cpu(void);
651
652int64_t opal_xscom_read(uint32_t gcid, uint32_t pcb_addr, uint64_t *val);
653int64_t opal_xscom_write(uint32_t gcid, uint32_t pcb_addr, uint64_t val);
654
655int64_t opal_lpc_write(uint32_t chip_id, enum OpalLPCAddressType addr_type,
656 uint32_t addr, uint32_t data, uint32_t sz);
657int64_t opal_lpc_read(uint32_t chip_id, enum OpalLPCAddressType addr_type,
658 uint32_t addr, uint32_t *data, uint32_t sz);
634 659
635/* Internal functions */ 660/* Internal functions */
636extern int early_init_dt_scan_opal(unsigned long node, const char *uname, int depth, void *data); 661extern int early_init_dt_scan_opal(unsigned long node, const char *uname, int depth, void *data);
@@ -664,6 +689,8 @@ extern int opal_machine_check(struct pt_regs *regs);
664 689
665extern void opal_shutdown(void); 690extern void opal_shutdown(void);
666 691
692extern void opal_lpc_init(void);
693
667#endif /* __ASSEMBLY__ */ 694#endif /* __ASSEMBLY__ */
668 695
669#endif /* __OPAL_H */ 696#endif /* __OPAL_H */
diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
index 77c91e74b612..a5954cebbc55 100644
--- a/arch/powerpc/include/asm/paca.h
+++ b/arch/powerpc/include/asm/paca.h
@@ -68,8 +68,13 @@ struct paca_struct {
68 * instruction. They must travel together and be properly 68 * instruction. They must travel together and be properly
69 * aligned. 69 * aligned.
70 */ 70 */
71#ifdef __BIG_ENDIAN__
71 u16 lock_token; /* Constant 0x8000, used in locks */ 72 u16 lock_token; /* Constant 0x8000, used in locks */
72 u16 paca_index; /* Logical processor number */ 73 u16 paca_index; /* Logical processor number */
74#else
75 u16 paca_index; /* Logical processor number */
76 u16 lock_token; /* Constant 0x8000, used in locks */
77#endif
73 78
74 u64 kernel_toc; /* Kernel TOC address */ 79 u64 kernel_toc; /* Kernel TOC address */
75 u64 kernelbase; /* Base address of kernel */ 80 u64 kernelbase; /* Base address of kernel */
@@ -93,9 +98,9 @@ struct paca_struct {
93 * Now, starting in cacheline 2, the exception save areas 98 * Now, starting in cacheline 2, the exception save areas
94 */ 99 */
95 /* used for most interrupts/exceptions */ 100 /* used for most interrupts/exceptions */
96 u64 exgen[12] __attribute__((aligned(0x80))); 101 u64 exgen[13] __attribute__((aligned(0x80)));
97 u64 exmc[12]; /* used for machine checks */ 102 u64 exmc[13]; /* used for machine checks */
98 u64 exslb[12]; /* used for SLB/segment table misses 103 u64 exslb[13]; /* used for SLB/segment table misses
99 * on the linear mapping */ 104 * on the linear mapping */
100 /* SLB related definitions */ 105 /* SLB related definitions */
101 u16 vmalloc_sllp; 106 u16 vmalloc_sllp;
diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index 32d0d2018faf..4ca90a39d6d0 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -159,7 +159,7 @@ struct pci_dn {
159 159
160 int pci_ext_config_space; /* for pci devices */ 160 int pci_ext_config_space; /* for pci devices */
161 161
162 int force_32bit_msi:1; 162 bool force_32bit_msi;
163 163
164 struct pci_dev *pcidev; /* back-pointer to the pci device */ 164 struct pci_dev *pcidev; /* back-pointer to the pci device */
165#ifdef CONFIG_EEH 165#ifdef CONFIG_EEH
diff --git a/arch/powerpc/include/asm/perf_event_fsl_emb.h b/arch/powerpc/include/asm/perf_event_fsl_emb.h
index 718a9fa94e68..a58165450f6f 100644
--- a/arch/powerpc/include/asm/perf_event_fsl_emb.h
+++ b/arch/powerpc/include/asm/perf_event_fsl_emb.h
@@ -13,7 +13,7 @@
13#include <linux/types.h> 13#include <linux/types.h>
14#include <asm/hw_irq.h> 14#include <asm/hw_irq.h>
15 15
16#define MAX_HWEVENTS 4 16#define MAX_HWEVENTS 6
17 17
18/* event flags */ 18/* event flags */
19#define FSL_EMB_EVENT_VALID 1 19#define FSL_EMB_EVENT_VALID 1
diff --git a/arch/powerpc/platforms/pseries/plpar_wrappers.h b/arch/powerpc/include/asm/plpar_wrappers.h
index f35787b6a5e0..a63b045e707c 100644
--- a/arch/powerpc/platforms/pseries/plpar_wrappers.h
+++ b/arch/powerpc/include/asm/plpar_wrappers.h
@@ -1,5 +1,5 @@
1#ifndef _PSERIES_PLPAR_WRAPPERS_H 1#ifndef _ASM_POWERPC_PLPAR_WRAPPERS_H
2#define _PSERIES_PLPAR_WRAPPERS_H 2#define _ASM_POWERPC_PLPAR_WRAPPERS_H
3 3
4#include <linux/string.h> 4#include <linux/string.h>
5#include <linux/irqflags.h> 5#include <linux/irqflags.h>
@@ -256,30 +256,6 @@ static inline long plpar_tce_stuff(unsigned long liobn, unsigned long ioba,
256 return plpar_hcall_norets(H_STUFF_TCE, liobn, ioba, tceval, count); 256 return plpar_hcall_norets(H_STUFF_TCE, liobn, ioba, tceval, count);
257} 257}
258 258
259static inline long plpar_get_term_char(unsigned long termno,
260 unsigned long *len_ret, char *buf_ret)
261{
262 long rc;
263 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
264 unsigned long *lbuf = (unsigned long *)buf_ret; /* TODO: alignment? */
265
266 rc = plpar_hcall(H_GET_TERM_CHAR, retbuf, termno);
267
268 *len_ret = retbuf[0];
269 lbuf[0] = retbuf[1];
270 lbuf[1] = retbuf[2];
271
272 return rc;
273}
274
275static inline long plpar_put_term_char(unsigned long termno, unsigned long len,
276 const char *buffer)
277{
278 unsigned long *lbuf = (unsigned long *)buffer; /* TODO: alignment? */
279 return plpar_hcall_norets(H_PUT_TERM_CHAR, termno, len, lbuf[0],
280 lbuf[1]);
281}
282
283/* Set various resource mode parameters */ 259/* Set various resource mode parameters */
284static inline long plpar_set_mode(unsigned long mflags, unsigned long resource, 260static inline long plpar_set_mode(unsigned long mflags, unsigned long resource,
285 unsigned long value1, unsigned long value2) 261 unsigned long value1, unsigned long value2)
@@ -321,4 +297,4 @@ static inline long plapr_set_watchpoint0(unsigned long dawr0, unsigned long dawr
321 return plpar_set_mode(0, 2, dawr0, dawrx0); 297 return plpar_set_mode(0, 2, dawr0, dawrx0);
322} 298}
323 299
324#endif /* _PSERIES_PLPAR_WRAPPERS_H */ 300#endif /* _ASM_POWERPC_PLPAR_WRAPPERS_H */
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index eccfc161e58e..d7fe9f5b46d4 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -81,6 +81,53 @@
81#define __REGA0_R30 30 81#define __REGA0_R30 30
82#define __REGA0_R31 31 82#define __REGA0_R31 31
83 83
84/* opcode and xopcode for instructions */
85#define OP_TRAP 3
86#define OP_TRAP_64 2
87
88#define OP_31_XOP_TRAP 4
89#define OP_31_XOP_LWZX 23
90#define OP_31_XOP_DCBST 54
91#define OP_31_XOP_LWZUX 55
92#define OP_31_XOP_TRAP_64 68
93#define OP_31_XOP_DCBF 86
94#define OP_31_XOP_LBZX 87
95#define OP_31_XOP_STWX 151
96#define OP_31_XOP_STBX 215
97#define OP_31_XOP_LBZUX 119
98#define OP_31_XOP_STBUX 247
99#define OP_31_XOP_LHZX 279
100#define OP_31_XOP_LHZUX 311
101#define OP_31_XOP_MFSPR 339
102#define OP_31_XOP_LHAX 343
103#define OP_31_XOP_LHAUX 375
104#define OP_31_XOP_STHX 407
105#define OP_31_XOP_STHUX 439
106#define OP_31_XOP_MTSPR 467
107#define OP_31_XOP_DCBI 470
108#define OP_31_XOP_LWBRX 534
109#define OP_31_XOP_TLBSYNC 566
110#define OP_31_XOP_STWBRX 662
111#define OP_31_XOP_LHBRX 790
112#define OP_31_XOP_STHBRX 918
113
114#define OP_LWZ 32
115#define OP_LD 58
116#define OP_LWZU 33
117#define OP_LBZ 34
118#define OP_LBZU 35
119#define OP_STW 36
120#define OP_STWU 37
121#define OP_STD 62
122#define OP_STB 38
123#define OP_STBU 39
124#define OP_LHZ 40
125#define OP_LHZU 41
126#define OP_LHA 42
127#define OP_LHAU 43
128#define OP_STH 44
129#define OP_STHU 45
130
84/* sorted alphabetically */ 131/* sorted alphabetically */
85#define PPC_INST_BHRBE 0x7c00025c 132#define PPC_INST_BHRBE 0x7c00025c
86#define PPC_INST_CLRBHRB 0x7c00035c 133#define PPC_INST_CLRBHRB 0x7c00035c
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 2f1b6c5f8174..599545738af3 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -54,7 +54,8 @@ BEGIN_FW_FTR_SECTION; \
54 /* from user - see if there are any DTL entries to process */ \ 54 /* from user - see if there are any DTL entries to process */ \
55 ld r10,PACALPPACAPTR(r13); /* get ptr to VPA */ \ 55 ld r10,PACALPPACAPTR(r13); /* get ptr to VPA */ \
56 ld r11,PACA_DTL_RIDX(r13); /* get log read index */ \ 56 ld r11,PACA_DTL_RIDX(r13); /* get log read index */ \
57 ld r10,LPPACA_DTLIDX(r10); /* get log write index */ \ 57 addi r10,r10,LPPACA_DTLIDX; \
58 LDX_BE r10,0,r10; /* get log write index */ \
58 cmpd cr1,r11,r10; \ 59 cmpd cr1,r11,r10; \
59 beq+ cr1,33f; \ 60 beq+ cr1,33f; \
60 bl .accumulate_stolen_time; \ 61 bl .accumulate_stolen_time; \
@@ -219,19 +220,6 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
219#define REST_8VSRS(n,b,base) REST_4VSRS(n,b,base); REST_4VSRS(n+4,b,base) 220#define REST_8VSRS(n,b,base) REST_4VSRS(n,b,base); REST_4VSRS(n+4,b,base)
220#define REST_16VSRS(n,b,base) REST_8VSRS(n,b,base); REST_8VSRS(n+8,b,base) 221#define REST_16VSRS(n,b,base) REST_8VSRS(n,b,base); REST_8VSRS(n+8,b,base)
221#define REST_32VSRS(n,b,base) REST_16VSRS(n,b,base); REST_16VSRS(n+16,b,base) 222#define REST_32VSRS(n,b,base) REST_16VSRS(n,b,base); REST_16VSRS(n+16,b,base)
222/* Save the upper 32 VSRs (32-63) in the thread VSX region (0-31) */
223#define SAVE_VSRU(n,b,base) li b,THREAD_VR0+(16*(n)); STXVD2X(n+32,R##base,R##b)
224#define SAVE_2VSRSU(n,b,base) SAVE_VSRU(n,b,base); SAVE_VSRU(n+1,b,base)
225#define SAVE_4VSRSU(n,b,base) SAVE_2VSRSU(n,b,base); SAVE_2VSRSU(n+2,b,base)
226#define SAVE_8VSRSU(n,b,base) SAVE_4VSRSU(n,b,base); SAVE_4VSRSU(n+4,b,base)
227#define SAVE_16VSRSU(n,b,base) SAVE_8VSRSU(n,b,base); SAVE_8VSRSU(n+8,b,base)
228#define SAVE_32VSRSU(n,b,base) SAVE_16VSRSU(n,b,base); SAVE_16VSRSU(n+16,b,base)
229#define REST_VSRU(n,b,base) li b,THREAD_VR0+(16*(n)); LXVD2X(n+32,R##base,R##b)
230#define REST_2VSRSU(n,b,base) REST_VSRU(n,b,base); REST_VSRU(n+1,b,base)
231#define REST_4VSRSU(n,b,base) REST_2VSRSU(n,b,base); REST_2VSRSU(n+2,b,base)
232#define REST_8VSRSU(n,b,base) REST_4VSRSU(n,b,base); REST_4VSRSU(n+4,b,base)
233#define REST_16VSRSU(n,b,base) REST_8VSRSU(n,b,base); REST_8VSRSU(n+8,b,base)
234#define REST_32VSRSU(n,b,base) REST_16VSRSU(n,b,base); REST_16VSRSU(n+16,b,base)
235 223
236/* 224/*
237 * b = base register for addressing, o = base offset from register of 1st EVR 225 * b = base register for addressing, o = base offset from register of 1st EVR
@@ -443,15 +431,15 @@ END_FTR_SECTION_IFSET(CPU_FTR_601)
443#define ISYNC_601 431#define ISYNC_601
444#endif 432#endif
445 433
446#ifdef CONFIG_PPC_CELL 434#if defined(CONFIG_PPC_CELL) || defined(CONFIG_PPC_FSL_BOOK3E)
447#define MFTB(dest) \ 435#define MFTB(dest) \
44890: mftb dest; \ 43690: mfspr dest, SPRN_TBRL; \
449BEGIN_FTR_SECTION_NESTED(96); \ 437BEGIN_FTR_SECTION_NESTED(96); \
450 cmpwi dest,0; \ 438 cmpwi dest,0; \
451 beq- 90b; \ 439 beq- 90b; \
452END_FTR_SECTION_NESTED(CPU_FTR_CELL_TB_BUG, CPU_FTR_CELL_TB_BUG, 96) 440END_FTR_SECTION_NESTED(CPU_FTR_CELL_TB_BUG, CPU_FTR_CELL_TB_BUG, 96)
453#else 441#else
454#define MFTB(dest) mftb dest 442#define MFTB(dest) mfspr dest, SPRN_TBRL
455#endif 443#endif
456 444
457#ifndef CONFIG_SMP 445#ifndef CONFIG_SMP
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index ac204e022922..7d0c7f3a7171 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -38,8 +38,9 @@ extern unsigned long pci_address_to_pio(phys_addr_t address);
38/* Parse the ibm,dma-window property of an OF node into the busno, phys and 38/* Parse the ibm,dma-window property of an OF node into the busno, phys and
39 * size parameters. 39 * size parameters.
40 */ 40 */
41void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, 41void of_parse_dma_window(struct device_node *dn, const __be32 *dma_window,
42 unsigned long *busno, unsigned long *phys, unsigned long *size); 42 unsigned long *busno, unsigned long *phys,
43 unsigned long *size);
43 44
44extern void kdump_move_device_tree(void); 45extern void kdump_move_device_tree(void);
45 46
@@ -55,6 +56,8 @@ static inline int of_node_to_nid(struct device_node *device) { return 0; }
55 56
56extern void of_instantiate_rtc(void); 57extern void of_instantiate_rtc(void);
57 58
59extern int of_get_ibm_chip_id(struct device_node *np);
60
58/* The of_drconf_cell struct defines the layout of the LMB array 61/* The of_drconf_cell struct defines the layout of the LMB array
59 * specified in the device tree property 62 * specified in the device tree property
60 * ibm,dynamic-reconfiguration-memory/ibm,dynamic-memory 63 * ibm,dynamic-reconfiguration-memory/ibm,dynamic-memory
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 99222e27f173..10d1ef016bf1 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -115,10 +115,10 @@
115#define MSR_64BIT MSR_SF 115#define MSR_64BIT MSR_SF
116 116
117/* Server variant */ 117/* Server variant */
118#define MSR_ MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_ISF |MSR_HV 118#define MSR_ (MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_ISF |MSR_HV)
119#define MSR_KERNEL MSR_ | MSR_64BIT 119#define MSR_KERNEL (MSR_ | MSR_64BIT)
120#define MSR_USER32 MSR_ | MSR_PR | MSR_EE 120#define MSR_USER32 (MSR_ | MSR_PR | MSR_EE)
121#define MSR_USER64 MSR_USER32 | MSR_64BIT 121#define MSR_USER64 (MSR_USER32 | MSR_64BIT)
122#elif defined(CONFIG_PPC_BOOK3S_32) || defined(CONFIG_8xx) 122#elif defined(CONFIG_PPC_BOOK3S_32) || defined(CONFIG_8xx)
123/* Default MSR for kernel mode. */ 123/* Default MSR for kernel mode. */
124#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR) 124#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR)
@@ -258,8 +258,8 @@
258#define FSCR_TAR_LG 8 /* Enable Target Address Register */ 258#define FSCR_TAR_LG 8 /* Enable Target Address Register */
259#define FSCR_EBB_LG 7 /* Enable Event Based Branching */ 259#define FSCR_EBB_LG 7 /* Enable Event Based Branching */
260#define FSCR_TM_LG 5 /* Enable Transactional Memory */ 260#define FSCR_TM_LG 5 /* Enable Transactional Memory */
261#define FSCR_PM_LG 4 /* Enable prob/priv access to PMU SPRs */ 261#define FSCR_BHRB_LG 4 /* Enable Branch History Rolling Buffer*/
262#define FSCR_BHRB_LG 3 /* Enable Branch History Rolling Buffer*/ 262#define FSCR_PM_LG 3 /* Enable prob/priv access to PMU SPRs */
263#define FSCR_DSCR_LG 2 /* Enable Data Stream Control Register */ 263#define FSCR_DSCR_LG 2 /* Enable Data Stream Control Register */
264#define FSCR_VECVSX_LG 1 /* Enable VMX/VSX */ 264#define FSCR_VECVSX_LG 1 /* Enable VMX/VSX */
265#define FSCR_FP_LG 0 /* Enable Floating Point */ 265#define FSCR_FP_LG 0 /* Enable Floating Point */
@@ -1126,10 +1126,10 @@
1126 : "memory") 1126 : "memory")
1127 1127
1128#ifdef __powerpc64__ 1128#ifdef __powerpc64__
1129#ifdef CONFIG_PPC_CELL 1129#if defined(CONFIG_PPC_CELL) || defined(CONFIG_PPC_FSL_BOOK3E)
1130#define mftb() ({unsigned long rval; \ 1130#define mftb() ({unsigned long rval; \
1131 asm volatile( \ 1131 asm volatile( \
1132 "90: mftb %0;\n" \ 1132 "90: mfspr %0, %2;\n" \
1133 "97: cmpwi %0,0;\n" \ 1133 "97: cmpwi %0,0;\n" \
1134 " beq- 90b;\n" \ 1134 " beq- 90b;\n" \
1135 "99:\n" \ 1135 "99:\n" \
@@ -1143,18 +1143,23 @@
1143 " .llong 0\n" \ 1143 " .llong 0\n" \
1144 " .llong 0\n" \ 1144 " .llong 0\n" \
1145 ".previous" \ 1145 ".previous" \
1146 : "=r" (rval) : "i" (CPU_FTR_CELL_TB_BUG)); rval;}) 1146 : "=r" (rval) \
1147 : "i" (CPU_FTR_CELL_TB_BUG), "i" (SPRN_TBRL)); \
1148 rval;})
1147#else 1149#else
1148#define mftb() ({unsigned long rval; \ 1150#define mftb() ({unsigned long rval; \
1149 asm volatile("mftb %0" : "=r" (rval)); rval;}) 1151 asm volatile("mfspr %0, %1" : \
1152 "=r" (rval) : "i" (SPRN_TBRL)); rval;})
1150#endif /* !CONFIG_PPC_CELL */ 1153#endif /* !CONFIG_PPC_CELL */
1151 1154
1152#else /* __powerpc64__ */ 1155#else /* __powerpc64__ */
1153 1156
1154#define mftbl() ({unsigned long rval; \ 1157#define mftbl() ({unsigned long rval; \
1155 asm volatile("mftbl %0" : "=r" (rval)); rval;}) 1158 asm volatile("mfspr %0, %1" : "=r" (rval) : \
1159 "i" (SPRN_TBRL)); rval;})
1156#define mftbu() ({unsigned long rval; \ 1160#define mftbu() ({unsigned long rval; \
1157 asm volatile("mftbu %0" : "=r" (rval)); rval;}) 1161 asm volatile("mfspr %0, %1" : "=r" (rval) : \
1162 "i" (SPRN_TBRU)); rval;})
1158#endif /* !__powerpc64__ */ 1163#endif /* !__powerpc64__ */
1159 1164
1160#define mttbl(v) asm volatile("mttbl %0":: "r"(v)) 1165#define mttbl(v) asm volatile("mttbl %0":: "r"(v))
diff --git a/arch/powerpc/include/asm/reg_booke.h b/arch/powerpc/include/asm/reg_booke.h
index b417de3cc2c4..ed8f836da094 100644
--- a/arch/powerpc/include/asm/reg_booke.h
+++ b/arch/powerpc/include/asm/reg_booke.h
@@ -29,10 +29,10 @@
29#if defined(CONFIG_PPC_BOOK3E_64) 29#if defined(CONFIG_PPC_BOOK3E_64)
30#define MSR_64BIT MSR_CM 30#define MSR_64BIT MSR_CM
31 31
32#define MSR_ MSR_ME | MSR_CE 32#define MSR_ (MSR_ME | MSR_CE)
33#define MSR_KERNEL MSR_ | MSR_64BIT 33#define MSR_KERNEL (MSR_ | MSR_64BIT)
34#define MSR_USER32 MSR_ | MSR_PR | MSR_EE 34#define MSR_USER32 (MSR_ | MSR_PR | MSR_EE)
35#define MSR_USER64 MSR_USER32 | MSR_64BIT 35#define MSR_USER64 (MSR_USER32 | MSR_64BIT)
36#elif defined (CONFIG_40x) 36#elif defined (CONFIG_40x)
37#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR|MSR_CE) 37#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR|MSR_CE)
38#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE) 38#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE)
diff --git a/arch/powerpc/include/asm/reg_fsl_emb.h b/arch/powerpc/include/asm/reg_fsl_emb.h
index 77bb71cfd991..0e3ddf5177f6 100644
--- a/arch/powerpc/include/asm/reg_fsl_emb.h
+++ b/arch/powerpc/include/asm/reg_fsl_emb.h
@@ -17,12 +17,16 @@
17/* Freescale Book E Performance Monitor APU Registers */ 17/* Freescale Book E Performance Monitor APU Registers */
18#define PMRN_PMC0 0x010 /* Performance Monitor Counter 0 */ 18#define PMRN_PMC0 0x010 /* Performance Monitor Counter 0 */
19#define PMRN_PMC1 0x011 /* Performance Monitor Counter 1 */ 19#define PMRN_PMC1 0x011 /* Performance Monitor Counter 1 */
20#define PMRN_PMC2 0x012 /* Performance Monitor Counter 1 */ 20#define PMRN_PMC2 0x012 /* Performance Monitor Counter 2 */
21#define PMRN_PMC3 0x013 /* Performance Monitor Counter 1 */ 21#define PMRN_PMC3 0x013 /* Performance Monitor Counter 3 */
22#define PMRN_PMC4 0x014 /* Performance Monitor Counter 4 */
23#define PMRN_PMC5 0x015 /* Performance Monitor Counter 5 */
22#define PMRN_PMLCA0 0x090 /* PM Local Control A0 */ 24#define PMRN_PMLCA0 0x090 /* PM Local Control A0 */
23#define PMRN_PMLCA1 0x091 /* PM Local Control A1 */ 25#define PMRN_PMLCA1 0x091 /* PM Local Control A1 */
24#define PMRN_PMLCA2 0x092 /* PM Local Control A2 */ 26#define PMRN_PMLCA2 0x092 /* PM Local Control A2 */
25#define PMRN_PMLCA3 0x093 /* PM Local Control A3 */ 27#define PMRN_PMLCA3 0x093 /* PM Local Control A3 */
28#define PMRN_PMLCA4 0x094 /* PM Local Control A4 */
29#define PMRN_PMLCA5 0x095 /* PM Local Control A5 */
26 30
27#define PMLCA_FC 0x80000000 /* Freeze Counter */ 31#define PMLCA_FC 0x80000000 /* Freeze Counter */
28#define PMLCA_FCS 0x40000000 /* Freeze in Supervisor */ 32#define PMLCA_FCS 0x40000000 /* Freeze in Supervisor */
@@ -30,14 +34,18 @@
30#define PMLCA_FCM1 0x10000000 /* Freeze when PMM==1 */ 34#define PMLCA_FCM1 0x10000000 /* Freeze when PMM==1 */
31#define PMLCA_FCM0 0x08000000 /* Freeze when PMM==0 */ 35#define PMLCA_FCM0 0x08000000 /* Freeze when PMM==0 */
32#define PMLCA_CE 0x04000000 /* Condition Enable */ 36#define PMLCA_CE 0x04000000 /* Condition Enable */
37#define PMLCA_FGCS1 0x00000002 /* Freeze in guest state */
38#define PMLCA_FGCS0 0x00000001 /* Freeze in hypervisor state */
33 39
34#define PMLCA_EVENT_MASK 0x00ff0000 /* Event field */ 40#define PMLCA_EVENT_MASK 0x01ff0000 /* Event field */
35#define PMLCA_EVENT_SHIFT 16 41#define PMLCA_EVENT_SHIFT 16
36 42
37#define PMRN_PMLCB0 0x110 /* PM Local Control B0 */ 43#define PMRN_PMLCB0 0x110 /* PM Local Control B0 */
38#define PMRN_PMLCB1 0x111 /* PM Local Control B1 */ 44#define PMRN_PMLCB1 0x111 /* PM Local Control B1 */
39#define PMRN_PMLCB2 0x112 /* PM Local Control B2 */ 45#define PMRN_PMLCB2 0x112 /* PM Local Control B2 */
40#define PMRN_PMLCB3 0x113 /* PM Local Control B3 */ 46#define PMRN_PMLCB3 0x113 /* PM Local Control B3 */
47#define PMRN_PMLCB4 0x114 /* PM Local Control B4 */
48#define PMRN_PMLCB5 0x115 /* PM Local Control B5 */
41 49
42#define PMLCB_THRESHMUL_MASK 0x0700 /* Threshold Multiple Field */ 50#define PMLCB_THRESHMUL_MASK 0x0700 /* Threshold Multiple Field */
43#define PMLCB_THRESHMUL_SHIFT 8 51#define PMLCB_THRESHMUL_SHIFT 8
@@ -55,16 +63,22 @@
55 63
56#define PMRN_UPMC0 0x000 /* User Performance Monitor Counter 0 */ 64#define PMRN_UPMC0 0x000 /* User Performance Monitor Counter 0 */
57#define PMRN_UPMC1 0x001 /* User Performance Monitor Counter 1 */ 65#define PMRN_UPMC1 0x001 /* User Performance Monitor Counter 1 */
58#define PMRN_UPMC2 0x002 /* User Performance Monitor Counter 1 */ 66#define PMRN_UPMC2 0x002 /* User Performance Monitor Counter 2 */
59#define PMRN_UPMC3 0x003 /* User Performance Monitor Counter 1 */ 67#define PMRN_UPMC3 0x003 /* User Performance Monitor Counter 3 */
68#define PMRN_UPMC4 0x004 /* User Performance Monitor Counter 4 */
69#define PMRN_UPMC5 0x005 /* User Performance Monitor Counter 5 */
60#define PMRN_UPMLCA0 0x080 /* User PM Local Control A0 */ 70#define PMRN_UPMLCA0 0x080 /* User PM Local Control A0 */
61#define PMRN_UPMLCA1 0x081 /* User PM Local Control A1 */ 71#define PMRN_UPMLCA1 0x081 /* User PM Local Control A1 */
62#define PMRN_UPMLCA2 0x082 /* User PM Local Control A2 */ 72#define PMRN_UPMLCA2 0x082 /* User PM Local Control A2 */
63#define PMRN_UPMLCA3 0x083 /* User PM Local Control A3 */ 73#define PMRN_UPMLCA3 0x083 /* User PM Local Control A3 */
74#define PMRN_UPMLCA4 0x084 /* User PM Local Control A4 */
75#define PMRN_UPMLCA5 0x085 /* User PM Local Control A5 */
64#define PMRN_UPMLCB0 0x100 /* User PM Local Control B0 */ 76#define PMRN_UPMLCB0 0x100 /* User PM Local Control B0 */
65#define PMRN_UPMLCB1 0x101 /* User PM Local Control B1 */ 77#define PMRN_UPMLCB1 0x101 /* User PM Local Control B1 */
66#define PMRN_UPMLCB2 0x102 /* User PM Local Control B2 */ 78#define PMRN_UPMLCB2 0x102 /* User PM Local Control B2 */
67#define PMRN_UPMLCB3 0x103 /* User PM Local Control B3 */ 79#define PMRN_UPMLCB3 0x103 /* User PM Local Control B3 */
80#define PMRN_UPMLCB4 0x104 /* User PM Local Control B4 */
81#define PMRN_UPMLCB5 0x105 /* User PM Local Control B5 */
68#define PMRN_UPMGC0 0x180 /* User PM Global Control 0 */ 82#define PMRN_UPMGC0 0x180 /* User PM Global Control 0 */
69 83
70 84
diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index c7a8bfc9f6f5..9bd52c65e66f 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -44,12 +44,12 @@
44 * 44 *
45 */ 45 */
46 46
47typedef u32 rtas_arg_t; 47typedef __be32 rtas_arg_t;
48 48
49struct rtas_args { 49struct rtas_args {
50 u32 token; 50 __be32 token;
51 u32 nargs; 51 __be32 nargs;
52 u32 nret; 52 __be32 nret;
53 rtas_arg_t args[16]; 53 rtas_arg_t args[16];
54 rtas_arg_t *rets; /* Pointer to return values in args[]. */ 54 rtas_arg_t *rets; /* Pointer to return values in args[]. */
55}; 55};
diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
index 48cfc858abd6..98da78e0c2c0 100644
--- a/arch/powerpc/include/asm/smp.h
+++ b/arch/powerpc/include/asm/smp.h
@@ -112,6 +112,7 @@ static inline struct cpumask *cpu_core_mask(int cpu)
112} 112}
113 113
114extern int cpu_to_core_id(int cpu); 114extern int cpu_to_core_id(int cpu);
115extern int cpu_to_chip_id(int cpu);
115 116
116/* Since OpenPIC has only 4 IPIs, we use slightly different message numbers. 117/* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
117 * 118 *
@@ -186,6 +187,8 @@ extern int smt_enabled_at_boot;
186extern int smp_mpic_probe(void); 187extern int smp_mpic_probe(void);
187extern void smp_mpic_setup_cpu(int cpu); 188extern void smp_mpic_setup_cpu(int cpu);
188extern int smp_generic_kick_cpu(int nr); 189extern int smp_generic_kick_cpu(int nr);
190extern int smp_generic_cpu_bootable(unsigned int nr);
191
189 192
190extern void smp_generic_give_timebase(void); 193extern void smp_generic_give_timebase(void);
191extern void smp_generic_take_timebase(void); 194extern void smp_generic_take_timebase(void);
diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
index 5b23f910ee57..5f54a744dcc5 100644
--- a/arch/powerpc/include/asm/spinlock.h
+++ b/arch/powerpc/include/asm/spinlock.h
@@ -32,8 +32,12 @@
32 32
33#ifdef CONFIG_PPC64 33#ifdef CONFIG_PPC64
34/* use 0x800000yy when locked, where yy == CPU number */ 34/* use 0x800000yy when locked, where yy == CPU number */
35#ifdef __BIG_ENDIAN__
35#define LOCK_TOKEN (*(u32 *)(&get_paca()->lock_token)) 36#define LOCK_TOKEN (*(u32 *)(&get_paca()->lock_token))
36#else 37#else
38#define LOCK_TOKEN (*(u32 *)(&get_paca()->paca_index))
39#endif
40#else
37#define LOCK_TOKEN 1 41#define LOCK_TOKEN 1
38#endif 42#endif
39 43
@@ -96,7 +100,7 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)
96 100
97#if defined(CONFIG_PPC_SPLPAR) 101#if defined(CONFIG_PPC_SPLPAR)
98/* We only yield to the hypervisor if we are in shared processor mode */ 102/* We only yield to the hypervisor if we are in shared processor mode */
99#define SHARED_PROCESSOR (local_paca->lppaca_ptr->shared_proc) 103#define SHARED_PROCESSOR (lppaca_shared_proc(local_paca->lppaca_ptr))
100extern void __spin_yield(arch_spinlock_t *lock); 104extern void __spin_yield(arch_spinlock_t *lock);
101extern void __rw_yield(arch_rwlock_t *lock); 105extern void __rw_yield(arch_rwlock_t *lock);
102#else /* SPLPAR */ 106#else /* SPLPAR */
diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h
index 294c2cedcf7a..2be5618cdec6 100644
--- a/arch/powerpc/include/asm/switch_to.h
+++ b/arch/powerpc/include/asm/switch_to.h
@@ -25,11 +25,8 @@ static inline void save_tar(struct thread_struct *prev)
25static inline void save_tar(struct thread_struct *prev) {} 25static inline void save_tar(struct thread_struct *prev) {}
26#endif 26#endif
27 27
28extern void giveup_fpu(struct task_struct *);
29extern void load_up_fpu(void); 28extern void load_up_fpu(void);
30extern void disable_kernel_fp(void);
31extern void enable_kernel_fp(void); 29extern void enable_kernel_fp(void);
32extern void flush_fp_to_thread(struct task_struct *);
33extern void enable_kernel_altivec(void); 30extern void enable_kernel_altivec(void);
34extern void load_up_altivec(struct task_struct *); 31extern void load_up_altivec(struct task_struct *);
35extern int emulate_altivec(struct pt_regs *); 32extern int emulate_altivec(struct pt_regs *);
@@ -47,6 +44,14 @@ static inline void discard_lazy_cpu_state(void)
47} 44}
48#endif 45#endif
49 46
47#ifdef CONFIG_PPC_FPU
48extern void flush_fp_to_thread(struct task_struct *);
49extern void giveup_fpu(struct task_struct *);
50#else
51static inline void flush_fp_to_thread(struct task_struct *t) { }
52static inline void giveup_fpu(struct task_struct *t) { }
53#endif
54
50#ifdef CONFIG_ALTIVEC 55#ifdef CONFIG_ALTIVEC
51extern void flush_altivec_to_thread(struct task_struct *); 56extern void flush_altivec_to_thread(struct task_struct *);
52extern void giveup_altivec(struct task_struct *); 57extern void giveup_altivec(struct task_struct *);
diff --git a/arch/powerpc/include/asm/timex.h b/arch/powerpc/include/asm/timex.h
index c55e14f7ef44..18908caa1f3b 100644
--- a/arch/powerpc/include/asm/timex.h
+++ b/arch/powerpc/include/asm/timex.h
@@ -29,7 +29,7 @@ static inline cycles_t get_cycles(void)
29 ret = 0; 29 ret = 0;
30 30
31 __asm__ __volatile__( 31 __asm__ __volatile__(
32 "97: mftb %0\n" 32 "97: mfspr %0, %2\n"
33 "99:\n" 33 "99:\n"
34 ".section __ftr_fixup,\"a\"\n" 34 ".section __ftr_fixup,\"a\"\n"
35 ".align 2\n" 35 ".align 2\n"
@@ -41,7 +41,7 @@ static inline cycles_t get_cycles(void)
41 " .long 0\n" 41 " .long 0\n"
42 " .long 0\n" 42 " .long 0\n"
43 ".previous" 43 ".previous"
44 : "=r" (ret) : "i" (CPU_FTR_601)); 44 : "=r" (ret) : "i" (CPU_FTR_601), "i" (SPRN_TBRL));
45 return ret; 45 return ret;
46#endif 46#endif
47} 47}
diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
index 161ab662843b..89e3ef2496ac 100644
--- a/arch/powerpc/include/asm/topology.h
+++ b/arch/powerpc/include/asm/topology.h
@@ -96,6 +96,7 @@ static inline int prrn_is_enabled(void)
96#ifdef CONFIG_PPC64 96#ifdef CONFIG_PPC64
97#include <asm/smp.h> 97#include <asm/smp.h>
98 98
99#define topology_physical_package_id(cpu) (cpu_to_chip_id(cpu))
99#define topology_thread_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu)) 100#define topology_thread_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu))
100#define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu)) 101#define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu))
101#define topology_core_id(cpu) (cpu_to_core_id(cpu)) 102#define topology_core_id(cpu) (cpu_to_core_id(cpu))
diff --git a/arch/powerpc/include/asm/udbg.h b/arch/powerpc/include/asm/udbg.h
index dc590919f8eb..b51fba10e733 100644
--- a/arch/powerpc/include/asm/udbg.h
+++ b/arch/powerpc/include/asm/udbg.h
@@ -27,10 +27,11 @@ extern void udbg_printf(const char *fmt, ...)
27 __attribute__ ((format (printf, 1, 2))); 27 __attribute__ ((format (printf, 1, 2)));
28extern void udbg_progress(char *s, unsigned short hex); 28extern void udbg_progress(char *s, unsigned short hex);
29 29
30extern void udbg_init_uart(void __iomem *comport, unsigned int speed, 30extern void udbg_uart_init_mmio(void __iomem *addr, unsigned int stride);
31 unsigned int clock); 31extern void udbg_uart_init_pio(unsigned long port, unsigned int stride);
32extern unsigned int udbg_probe_uart_speed(void __iomem *comport, 32
33 unsigned int clock); 33extern void udbg_uart_setup(unsigned int speed, unsigned int clock);
34extern unsigned int udbg_probe_uart_speed(unsigned int clock);
34 35
35struct device_node; 36struct device_node;
36extern void udbg_scc_init(int force_scc); 37extern void udbg_scc_init(int force_scc);
diff --git a/arch/powerpc/include/uapi/asm/elf.h b/arch/powerpc/include/uapi/asm/elf.h
index 05b8d560cfba..7e39c9146a71 100644
--- a/arch/powerpc/include/uapi/asm/elf.h
+++ b/arch/powerpc/include/uapi/asm/elf.h
@@ -107,26 +107,25 @@ typedef elf_gregset_t32 compat_elf_gregset_t;
107# define ELF_NVRREG 34 /* includes vscr & vrsave in split vectors */ 107# define ELF_NVRREG 34 /* includes vscr & vrsave in split vectors */
108# define ELF_NVSRHALFREG 32 /* Half the vsx registers */ 108# define ELF_NVSRHALFREG 32 /* Half the vsx registers */
109# define ELF_GREG_TYPE elf_greg_t64 109# define ELF_GREG_TYPE elf_greg_t64
110# define ELF_ARCH EM_PPC64
111# define ELF_CLASS ELFCLASS64
112typedef elf_greg_t64 elf_greg_t;
113typedef elf_gregset_t64 elf_gregset_t;
110#else 114#else
111# define ELF_NEVRREG 34 /* includes acc (as 2) */ 115# define ELF_NEVRREG 34 /* includes acc (as 2) */
112# define ELF_NVRREG 33 /* includes vscr */ 116# define ELF_NVRREG 33 /* includes vscr */
113# define ELF_GREG_TYPE elf_greg_t32 117# define ELF_GREG_TYPE elf_greg_t32
114# define ELF_ARCH EM_PPC 118# define ELF_ARCH EM_PPC
115# define ELF_CLASS ELFCLASS32 119# define ELF_CLASS ELFCLASS32
116# define ELF_DATA ELFDATA2MSB 120typedef elf_greg_t32 elf_greg_t;
121typedef elf_gregset_t32 elf_gregset_t;
117#endif /* __powerpc64__ */ 122#endif /* __powerpc64__ */
118 123
119#ifndef ELF_ARCH 124#ifdef __BIG_ENDIAN__
120# define ELF_ARCH EM_PPC64 125#define ELF_DATA ELFDATA2MSB
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#else 126#else
126 /* Assumption: ELF_ARCH == EM_PPC and ELF_CLASS == ELFCLASS32 */ 127#define ELF_DATA ELFDATA2LSB
127 typedef elf_greg_t32 elf_greg_t; 128#endif
128 typedef elf_gregset_t32 elf_gregset_t;
129#endif /* ELF_ARCH */
130 129
131/* Floating point registers */ 130/* Floating point registers */
132typedef double elf_fpreg_t; 131typedef double elf_fpreg_t;
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index a8619bfe879e..445cb6e39d5b 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -55,7 +55,6 @@ obj-$(CONFIG_PPC_RTAS) += rtas.o rtas-rtc.o $(rtaspci-y-y)
55obj-$(CONFIG_PPC_RTAS_DAEMON) += rtasd.o 55obj-$(CONFIG_PPC_RTAS_DAEMON) += rtasd.o
56obj-$(CONFIG_RTAS_FLASH) += rtas_flash.o 56obj-$(CONFIG_RTAS_FLASH) += rtas_flash.o
57obj-$(CONFIG_RTAS_PROC) += rtas-proc.o 57obj-$(CONFIG_RTAS_PROC) += rtas-proc.o
58obj-$(CONFIG_LPARCFG) += lparcfg.o
59obj-$(CONFIG_IBMVIO) += vio.o 58obj-$(CONFIG_IBMVIO) += vio.o
60obj-$(CONFIG_IBMEBUS) += ibmebus.o 59obj-$(CONFIG_IBMEBUS) += ibmebus.o
61obj-$(CONFIG_EEH) += eeh.o eeh_pe.o eeh_dev.o eeh_cache.o \ 60obj-$(CONFIG_EEH) += eeh.o eeh_pe.o eeh_dev.o eeh_cache.o \
@@ -117,9 +116,7 @@ obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o
117obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o 116obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
118obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o 117obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o
119 118
120obj-$(CONFIG_8XX_MINIMAL_FPEMU) += softemu8xx.o 119ifneq ($(CONFIG_PPC_INDIRECT_PIO),y)
121
122ifneq ($(CONFIG_PPC_INDIRECT_IO),y)
123obj-y += iomap.o 120obj-y += iomap.o
124endif 121endif
125 122
diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c
index ee5b690a0bed..a27ccd5dc6b9 100644
--- a/arch/powerpc/kernel/align.c
+++ b/arch/powerpc/kernel/align.c
@@ -651,6 +651,10 @@ static int emulate_vsx(unsigned char __user *addr, unsigned int reg,
651 int sw = 0; 651 int sw = 0;
652 int i, j; 652 int i, j;
653 653
654 /* userland only */
655 if (unlikely(!user_mode(regs)))
656 return 0;
657
654 flush_vsx_to_thread(current); 658 flush_vsx_to_thread(current);
655 659
656 if (reg < 32) 660 if (reg < 32)
@@ -764,6 +768,16 @@ int fix_alignment(struct pt_regs *regs)
764 nb = aligninfo[instr].len; 768 nb = aligninfo[instr].len;
765 flags = aligninfo[instr].flags; 769 flags = aligninfo[instr].flags;
766 770
771 /* ldbrx/stdbrx overlap lfs/stfs in the DSISR unfortunately */
772 if (IS_XFORM(instruction) && ((instruction >> 1) & 0x3ff) == 532) {
773 nb = 8;
774 flags = LD+SW;
775 } else if (IS_XFORM(instruction) &&
776 ((instruction >> 1) & 0x3ff) == 660) {
777 nb = 8;
778 flags = ST+SW;
779 }
780
767 /* Byteswap little endian loads and stores */ 781 /* Byteswap little endian loads and stores */
768 swiz = 0; 782 swiz = 0;
769 if (regs->msr & MSR_LE) { 783 if (regs->msr & MSR_LE) {
diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c
index ac8f52732fde..41c011cb6070 100644
--- a/arch/powerpc/kernel/btext.c
+++ b/arch/powerpc/kernel/btext.c
@@ -25,11 +25,6 @@
25static void scrollscreen(void); 25static void scrollscreen(void);
26#endif 26#endif
27 27
28static void draw_byte(unsigned char c, long locX, long locY);
29static void draw_byte_32(unsigned char *bits, unsigned int *base, int rb);
30static void draw_byte_16(unsigned char *bits, unsigned int *base, int rb);
31static void draw_byte_8(unsigned char *bits, unsigned int *base, int rb);
32
33#define __force_data __attribute__((__section__(".data"))) 28#define __force_data __attribute__((__section__(".data")))
34 29
35static int g_loc_X __force_data; 30static int g_loc_X __force_data;
@@ -52,6 +47,26 @@ static unsigned char vga_font[cmapsz];
52int boot_text_mapped __force_data = 0; 47int boot_text_mapped __force_data = 0;
53int force_printk_to_btext = 0; 48int force_printk_to_btext = 0;
54 49
50extern void rmci_on(void);
51extern void rmci_off(void);
52
53static inline void rmci_maybe_on(void)
54{
55#if defined(CONFIG_PPC_EARLY_DEBUG_BOOTX) && defined(CONFIG_PPC64)
56 if (!(mfmsr() & MSR_DR))
57 rmci_on();
58#endif
59}
60
61static inline void rmci_maybe_off(void)
62{
63#if defined(CONFIG_PPC_EARLY_DEBUG_BOOTX) && defined(CONFIG_PPC64)
64 if (!(mfmsr() & MSR_DR))
65 rmci_off();
66#endif
67}
68
69
55#ifdef CONFIG_PPC32 70#ifdef CONFIG_PPC32
56/* Calc BAT values for mapping the display and store them 71/* Calc BAT values for mapping the display and store them
57 * in disp_BAT. Those values are then used from head.S to map 72 * in disp_BAT. Those values are then used from head.S to map
@@ -134,7 +149,7 @@ void __init btext_unmap(void)
134 * changes. 149 * changes.
135 */ 150 */
136 151
137static void map_boot_text(void) 152void btext_map(void)
138{ 153{
139 unsigned long base, offset, size; 154 unsigned long base, offset, size;
140 unsigned char *vbase; 155 unsigned char *vbase;
@@ -209,7 +224,7 @@ int btext_initialize(struct device_node *np)
209 dispDeviceRect[2] = width; 224 dispDeviceRect[2] = width;
210 dispDeviceRect[3] = height; 225 dispDeviceRect[3] = height;
211 226
212 map_boot_text(); 227 btext_map();
213 228
214 return 0; 229 return 0;
215} 230}
@@ -283,7 +298,7 @@ void btext_update_display(unsigned long phys, int width, int height,
283 iounmap(logicalDisplayBase); 298 iounmap(logicalDisplayBase);
284 boot_text_mapped = 0; 299 boot_text_mapped = 0;
285 } 300 }
286 map_boot_text(); 301 btext_map();
287 g_loc_X = 0; 302 g_loc_X = 0;
288 g_loc_Y = 0; 303 g_loc_Y = 0;
289 g_max_loc_X = width / 8; 304 g_max_loc_X = width / 8;
@@ -298,6 +313,7 @@ void btext_clearscreen(void)
298 (dispDeviceDepth >> 3)) >> 2; 313 (dispDeviceDepth >> 3)) >> 2;
299 int i,j; 314 int i,j;
300 315
316 rmci_maybe_on();
301 for (i=0; i<(dispDeviceRect[3] - dispDeviceRect[1]); i++) 317 for (i=0; i<(dispDeviceRect[3] - dispDeviceRect[1]); i++)
302 { 318 {
303 unsigned int *ptr = base; 319 unsigned int *ptr = base;
@@ -305,6 +321,7 @@ void btext_clearscreen(void)
305 *(ptr++) = 0; 321 *(ptr++) = 0;
306 base += (dispDeviceRowBytes >> 2); 322 base += (dispDeviceRowBytes >> 2);
307 } 323 }
324 rmci_maybe_off();
308} 325}
309 326
310void btext_flushscreen(void) 327void btext_flushscreen(void)
@@ -355,6 +372,8 @@ static void scrollscreen(void)
355 (dispDeviceDepth >> 3)) >> 2; 372 (dispDeviceDepth >> 3)) >> 2;
356 int i,j; 373 int i,j;
357 374
375 rmci_maybe_on();
376
358 for (i=0; i<(dispDeviceRect[3] - dispDeviceRect[1] - 16); i++) 377 for (i=0; i<(dispDeviceRect[3] - dispDeviceRect[1] - 16); i++)
359 { 378 {
360 unsigned int *src_ptr = src; 379 unsigned int *src_ptr = src;
@@ -371,9 +390,116 @@ static void scrollscreen(void)
371 *(dst_ptr++) = 0; 390 *(dst_ptr++) = 0;
372 dst += (dispDeviceRowBytes >> 2); 391 dst += (dispDeviceRowBytes >> 2);
373 } 392 }
393
394 rmci_maybe_off();
374} 395}
375#endif /* ndef NO_SCROLL */ 396#endif /* ndef NO_SCROLL */
376 397
398static unsigned int expand_bits_8[16] = {
399 0x00000000,
400 0x000000ff,
401 0x0000ff00,
402 0x0000ffff,
403 0x00ff0000,
404 0x00ff00ff,
405 0x00ffff00,
406 0x00ffffff,
407 0xff000000,
408 0xff0000ff,
409 0xff00ff00,
410 0xff00ffff,
411 0xffff0000,
412 0xffff00ff,
413 0xffffff00,
414 0xffffffff
415};
416
417static unsigned int expand_bits_16[4] = {
418 0x00000000,
419 0x0000ffff,
420 0xffff0000,
421 0xffffffff
422};
423
424
425static void draw_byte_32(unsigned char *font, unsigned int *base, int rb)
426{
427 int l, bits;
428 int fg = 0xFFFFFFFFUL;
429 int bg = 0x00000000UL;
430
431 for (l = 0; l < 16; ++l)
432 {
433 bits = *font++;
434 base[0] = (-(bits >> 7) & fg) ^ bg;
435 base[1] = (-((bits >> 6) & 1) & fg) ^ bg;
436 base[2] = (-((bits >> 5) & 1) & fg) ^ bg;
437 base[3] = (-((bits >> 4) & 1) & fg) ^ bg;
438 base[4] = (-((bits >> 3) & 1) & fg) ^ bg;
439 base[5] = (-((bits >> 2) & 1) & fg) ^ bg;
440 base[6] = (-((bits >> 1) & 1) & fg) ^ bg;
441 base[7] = (-(bits & 1) & fg) ^ bg;
442 base = (unsigned int *) ((char *)base + rb);
443 }
444}
445
446static inline void draw_byte_16(unsigned char *font, unsigned int *base, int rb)
447{
448 int l, bits;
449 int fg = 0xFFFFFFFFUL;
450 int bg = 0x00000000UL;
451 unsigned int *eb = (int *)expand_bits_16;
452
453 for (l = 0; l < 16; ++l)
454 {
455 bits = *font++;
456 base[0] = (eb[bits >> 6] & fg) ^ bg;
457 base[1] = (eb[(bits >> 4) & 3] & fg) ^ bg;
458 base[2] = (eb[(bits >> 2) & 3] & fg) ^ bg;
459 base[3] = (eb[bits & 3] & fg) ^ bg;
460 base = (unsigned int *) ((char *)base + rb);
461 }
462}
463
464static inline void draw_byte_8(unsigned char *font, unsigned int *base, int rb)
465{
466 int l, bits;
467 int fg = 0x0F0F0F0FUL;
468 int bg = 0x00000000UL;
469 unsigned int *eb = (int *)expand_bits_8;
470
471 for (l = 0; l < 16; ++l)
472 {
473 bits = *font++;
474 base[0] = (eb[bits >> 4] & fg) ^ bg;
475 base[1] = (eb[bits & 0xf] & fg) ^ bg;
476 base = (unsigned int *) ((char *)base + rb);
477 }
478}
479
480static noinline void draw_byte(unsigned char c, long locX, long locY)
481{
482 unsigned char *base = calc_base(locX << 3, locY << 4);
483 unsigned char *font = &vga_font[((unsigned int)c) * 16];
484 int rb = dispDeviceRowBytes;
485
486 rmci_maybe_on();
487 switch(dispDeviceDepth) {
488 case 24:
489 case 32:
490 draw_byte_32(font, (unsigned int *)base, rb);
491 break;
492 case 15:
493 case 16:
494 draw_byte_16(font, (unsigned int *)base, rb);
495 break;
496 case 8:
497 draw_byte_8(font, (unsigned int *)base, rb);
498 break;
499 }
500 rmci_maybe_off();
501}
502
377void btext_drawchar(char c) 503void btext_drawchar(char c)
378{ 504{
379 int cline = 0; 505 int cline = 0;
@@ -465,107 +591,12 @@ void btext_drawhex(unsigned long v)
465 btext_drawchar(' '); 591 btext_drawchar(' ');
466} 592}
467 593
468static void draw_byte(unsigned char c, long locX, long locY) 594void __init udbg_init_btext(void)
469{
470 unsigned char *base = calc_base(locX << 3, locY << 4);
471 unsigned char *font = &vga_font[((unsigned int)c) * 16];
472 int rb = dispDeviceRowBytes;
473
474 switch(dispDeviceDepth) {
475 case 24:
476 case 32:
477 draw_byte_32(font, (unsigned int *)base, rb);
478 break;
479 case 15:
480 case 16:
481 draw_byte_16(font, (unsigned int *)base, rb);
482 break;
483 case 8:
484 draw_byte_8(font, (unsigned int *)base, rb);
485 break;
486 }
487}
488
489static unsigned int expand_bits_8[16] = {
490 0x00000000,
491 0x000000ff,
492 0x0000ff00,
493 0x0000ffff,
494 0x00ff0000,
495 0x00ff00ff,
496 0x00ffff00,
497 0x00ffffff,
498 0xff000000,
499 0xff0000ff,
500 0xff00ff00,
501 0xff00ffff,
502 0xffff0000,
503 0xffff00ff,
504 0xffffff00,
505 0xffffffff
506};
507
508static unsigned int expand_bits_16[4] = {
509 0x00000000,
510 0x0000ffff,
511 0xffff0000,
512 0xffffffff
513};
514
515
516static void draw_byte_32(unsigned char *font, unsigned int *base, int rb)
517{
518 int l, bits;
519 int fg = 0xFFFFFFFFUL;
520 int bg = 0x00000000UL;
521
522 for (l = 0; l < 16; ++l)
523 {
524 bits = *font++;
525 base[0] = (-(bits >> 7) & fg) ^ bg;
526 base[1] = (-((bits >> 6) & 1) & fg) ^ bg;
527 base[2] = (-((bits >> 5) & 1) & fg) ^ bg;
528 base[3] = (-((bits >> 4) & 1) & fg) ^ bg;
529 base[4] = (-((bits >> 3) & 1) & fg) ^ bg;
530 base[5] = (-((bits >> 2) & 1) & fg) ^ bg;
531 base[6] = (-((bits >> 1) & 1) & fg) ^ bg;
532 base[7] = (-(bits & 1) & fg) ^ bg;
533 base = (unsigned int *) ((char *)base + rb);
534 }
535}
536
537static void draw_byte_16(unsigned char *font, unsigned int *base, int rb)
538{
539 int l, bits;
540 int fg = 0xFFFFFFFFUL;
541 int bg = 0x00000000UL;
542 unsigned int *eb = (int *)expand_bits_16;
543
544 for (l = 0; l < 16; ++l)
545 {
546 bits = *font++;
547 base[0] = (eb[bits >> 6] & fg) ^ bg;
548 base[1] = (eb[(bits >> 4) & 3] & fg) ^ bg;
549 base[2] = (eb[(bits >> 2) & 3] & fg) ^ bg;
550 base[3] = (eb[bits & 3] & fg) ^ bg;
551 base = (unsigned int *) ((char *)base + rb);
552 }
553}
554
555static void draw_byte_8(unsigned char *font, unsigned int *base, int rb)
556{ 595{
557 int l, bits; 596 /* If btext is enabled, we might have a BAT setup for early display,
558 int fg = 0x0F0F0F0FUL; 597 * thus we do enable some very basic udbg output
559 int bg = 0x00000000UL; 598 */
560 unsigned int *eb = (int *)expand_bits_8; 599 udbg_putc = btext_drawchar;
561
562 for (l = 0; l < 16; ++l)
563 {
564 bits = *font++;
565 base[0] = (eb[bits >> 4] & fg) ^ bg;
566 base[1] = (eb[bits & 0xf] & fg) ^ bg;
567 base = (unsigned int *) ((char *)base + rb);
568 }
569} 600}
570 601
571static unsigned char vga_font[cmapsz] = { 602static unsigned char vga_font[cmapsz] = {
@@ -913,10 +944,3 @@ static unsigned char vga_font[cmapsz] = {
9130x00, 0x00, 0x00, 0x00, 9440x00, 0x00, 0x00, 0x00,
914}; 945};
915 946
916void __init udbg_init_btext(void)
917{
918 /* If btext is enabled, we might have a BAT setup for early display,
919 * thus we do enable some very basic udbg output
920 */
921 udbg_putc = btext_drawchar;
922}
diff --git a/arch/powerpc/kernel/cacheinfo.c b/arch/powerpc/kernel/cacheinfo.c
index 9262cf2bec4b..654932727873 100644
--- a/arch/powerpc/kernel/cacheinfo.c
+++ b/arch/powerpc/kernel/cacheinfo.c
@@ -196,7 +196,7 @@ static void cache_cpu_set(struct cache *cache, int cpu)
196static int cache_size(const struct cache *cache, unsigned int *ret) 196static int cache_size(const struct cache *cache, unsigned int *ret)
197{ 197{
198 const char *propname; 198 const char *propname;
199 const u32 *cache_size; 199 const __be32 *cache_size;
200 200
201 propname = cache_type_info[cache->type].size_prop; 201 propname = cache_type_info[cache->type].size_prop;
202 202
@@ -204,7 +204,7 @@ static int cache_size(const struct cache *cache, unsigned int *ret)
204 if (!cache_size) 204 if (!cache_size)
205 return -ENODEV; 205 return -ENODEV;
206 206
207 *ret = *cache_size; 207 *ret = of_read_number(cache_size, 1);
208 return 0; 208 return 0;
209} 209}
210 210
@@ -222,7 +222,7 @@ static int cache_size_kb(const struct cache *cache, unsigned int *ret)
222/* not cache_line_size() because that's a macro in include/linux/cache.h */ 222/* not cache_line_size() because that's a macro in include/linux/cache.h */
223static int cache_get_line_size(const struct cache *cache, unsigned int *ret) 223static int cache_get_line_size(const struct cache *cache, unsigned int *ret)
224{ 224{
225 const u32 *line_size; 225 const __be32 *line_size;
226 int i, lim; 226 int i, lim;
227 227
228 lim = ARRAY_SIZE(cache_type_info[cache->type].line_size_props); 228 lim = ARRAY_SIZE(cache_type_info[cache->type].line_size_props);
@@ -239,14 +239,14 @@ static int cache_get_line_size(const struct cache *cache, unsigned int *ret)
239 if (!line_size) 239 if (!line_size)
240 return -ENODEV; 240 return -ENODEV;
241 241
242 *ret = *line_size; 242 *ret = of_read_number(line_size, 1);
243 return 0; 243 return 0;
244} 244}
245 245
246static int cache_nr_sets(const struct cache *cache, unsigned int *ret) 246static int cache_nr_sets(const struct cache *cache, unsigned int *ret)
247{ 247{
248 const char *propname; 248 const char *propname;
249 const u32 *nr_sets; 249 const __be32 *nr_sets;
250 250
251 propname = cache_type_info[cache->type].nr_sets_prop; 251 propname = cache_type_info[cache->type].nr_sets_prop;
252 252
@@ -254,7 +254,7 @@ static int cache_nr_sets(const struct cache *cache, unsigned int *ret)
254 if (!nr_sets) 254 if (!nr_sets)
255 return -ENODEV; 255 return -ENODEV;
256 256
257 *ret = *nr_sets; 257 *ret = of_read_number(nr_sets, 1);
258 return 0; 258 return 0;
259} 259}
260 260
diff --git a/arch/powerpc/kernel/cpu_setup_fsl_booke.S b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
index 0b9af015bedc..bfb18c7290b7 100644
--- a/arch/powerpc/kernel/cpu_setup_fsl_booke.S
+++ b/arch/powerpc/kernel/cpu_setup_fsl_booke.S
@@ -75,7 +75,7 @@ _GLOBAL(__setup_cpu_e500v2)
75 bl __e500_icache_setup 75 bl __e500_icache_setup
76 bl __e500_dcache_setup 76 bl __e500_dcache_setup
77 bl __setup_e500_ivors 77 bl __setup_e500_ivors
78#ifdef CONFIG_FSL_RIO 78#if defined(CONFIG_FSL_RIO) || defined(CONFIG_FSL_PCI)
79 /* Ensure that RFXE is set */ 79 /* Ensure that RFXE is set */
80 mfspr r3,SPRN_HID1 80 mfspr r3,SPRN_HID1
81 oris r3,r3,HID1_RFXE@h 81 oris r3,r3,HID1_RFXE@h
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 22973a74df73..597d954e5860 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -2105,7 +2105,7 @@ static struct cpu_spec __initdata cpu_specs[] = {
2105 MMU_FTR_USE_TLBILX, 2105 MMU_FTR_USE_TLBILX,
2106 .icache_bsize = 64, 2106 .icache_bsize = 64,
2107 .dcache_bsize = 64, 2107 .dcache_bsize = 64,
2108 .num_pmcs = 4, 2108 .num_pmcs = 6,
2109 .oprofile_cpu_type = "ppc/e6500", 2109 .oprofile_cpu_type = "ppc/e6500",
2110 .oprofile_type = PPC_OPROFILE_FSL_EMB, 2110 .oprofile_type = PPC_OPROFILE_FSL_EMB,
2111 .cpu_setup = __setup_cpu_e6500, 2111 .cpu_setup = __setup_cpu_e6500,
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 2bd0b885b0fe..c04cdf70d487 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -102,7 +102,8 @@ BEGIN_FW_FTR_SECTION
102 /* if from user, see if there are any DTL entries to process */ 102 /* if from user, see if there are any DTL entries to process */
103 ld r10,PACALPPACAPTR(r13) /* get ptr to VPA */ 103 ld r10,PACALPPACAPTR(r13) /* get ptr to VPA */
104 ld r11,PACA_DTL_RIDX(r13) /* get log read index */ 104 ld r11,PACA_DTL_RIDX(r13) /* get log read index */
105 ld r10,LPPACA_DTLIDX(r10) /* get log write index */ 105 addi r10,r10,LPPACA_DTLIDX
106 LDX_BE r10,0,r10 /* get log write index */
106 cmpd cr1,r11,r10 107 cmpd cr1,r11,r10
107 beq+ cr1,33f 108 beq+ cr1,33f
108 bl .accumulate_stolen_time 109 bl .accumulate_stolen_time
@@ -522,9 +523,11 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_1T_SEGMENT)
522 */ 523 */
523 ld r9,PACA_SLBSHADOWPTR(r13) 524 ld r9,PACA_SLBSHADOWPTR(r13)
524 li r12,0 525 li r12,0
525 std r12,SLBSHADOW_STACKESID(r9) /* Clear ESID */ 526 std r12,SLBSHADOW_STACKESID(r9) /* Clear ESID */
526 std r7,SLBSHADOW_STACKVSID(r9) /* Save VSID */ 527 li r12,SLBSHADOW_STACKVSID
527 std r0,SLBSHADOW_STACKESID(r9) /* Save ESID */ 528 STDX_BE r7,r12,r9 /* Save VSID */
529 li r12,SLBSHADOW_STACKESID
530 STDX_BE r0,r12,r9 /* Save ESID */
528 531
529 /* No need to check for MMU_FTR_NO_SLBIE_B here, since when 532 /* No need to check for MMU_FTR_NO_SLBIE_B here, since when
530 * we have 1TB segments, the only CPUs known to have the errata 533 * we have 1TB segments, the only CPUs known to have the errata
@@ -575,34 +578,15 @@ BEGIN_FTR_SECTION
575 ld r7,DSCR_DEFAULT@toc(2) 578 ld r7,DSCR_DEFAULT@toc(2)
576 ld r0,THREAD_DSCR(r4) 579 ld r0,THREAD_DSCR(r4)
577 cmpwi r6,0 580 cmpwi r6,0
578 li r8, FSCR_DSCR
579 bne 1f 581 bne 1f
580 ld r0,0(r7) 582 ld r0,0(r7)
581 b 3f
5821: 5831:
583 BEGIN_FTR_SECTION_NESTED(70) 584BEGIN_FTR_SECTION_NESTED(70)
584 mfspr r6, SPRN_FSCR 585 mfspr r8, SPRN_FSCR
585 or r6, r6, r8 586 rldimi r8, r6, FSCR_DSCR_LG, (63 - FSCR_DSCR_LG)
586 mtspr SPRN_FSCR, r6 587 mtspr SPRN_FSCR, r8
587 BEGIN_FTR_SECTION_NESTED(69) 588END_FTR_SECTION_NESTED(CPU_FTR_ARCH_207S, CPU_FTR_ARCH_207S, 70)
588 mfspr r6, SPRN_HFSCR 589 cmpd r0,r25
589 or r6, r6, r8
590 mtspr SPRN_HFSCR, r6
591 END_FTR_SECTION_NESTED(CPU_FTR_HVMODE, CPU_FTR_HVMODE, 69)
592 b 4f
593 END_FTR_SECTION_NESTED(CPU_FTR_ARCH_207S, CPU_FTR_ARCH_207S, 70)
5943:
595 BEGIN_FTR_SECTION_NESTED(70)
596 mfspr r6, SPRN_FSCR
597 andc r6, r6, r8
598 mtspr SPRN_FSCR, r6
599 BEGIN_FTR_SECTION_NESTED(69)
600 mfspr r6, SPRN_HFSCR
601 andc r6, r6, r8
602 mtspr SPRN_HFSCR, r6
603 END_FTR_SECTION_NESTED(CPU_FTR_HVMODE, CPU_FTR_HVMODE, 69)
604 END_FTR_SECTION_NESTED(CPU_FTR_ARCH_207S, CPU_FTR_ARCH_207S, 70)
6054: cmpd r0,r25
606 beq 2f 590 beq 2f
607 mtspr SPRN_DSCR,r0 591 mtspr SPRN_DSCR,r0
6082: 5922:
@@ -737,9 +721,9 @@ resume_kernel:
737 721
738 /* 722 /*
739 * Here we are preempting the current task. We want to make 723 * Here we are preempting the current task. We want to make
740 * sure we are soft-disabled first 724 * sure we are soft-disabled first and reconcile irq state.
741 */ 725 */
742 SOFT_DISABLE_INTS(r3,r4) 726 RECONCILE_IRQ_STATE(r3,r4)
7431: bl .preempt_schedule_irq 7271: bl .preempt_schedule_irq
744 728
745 /* Re-test flags and eventually loop */ 729 /* Re-test flags and eventually loop */
diff --git a/arch/powerpc/kernel/epapr_paravirt.c b/arch/powerpc/kernel/epapr_paravirt.c
index d44a571e45a7..6300c13bbde4 100644
--- a/arch/powerpc/kernel/epapr_paravirt.c
+++ b/arch/powerpc/kernel/epapr_paravirt.c
@@ -30,22 +30,20 @@ extern u32 epapr_ev_idle_start[];
30 30
31bool epapr_paravirt_enabled; 31bool epapr_paravirt_enabled;
32 32
33static int __init epapr_paravirt_init(void) 33static int __init early_init_dt_scan_epapr(unsigned long node,
34 const char *uname,
35 int depth, void *data)
34{ 36{
35 struct device_node *hyper_node;
36 const u32 *insts; 37 const u32 *insts;
37 int len, i; 38 unsigned long len;
39 int i;
38 40
39 hyper_node = of_find_node_by_path("/hypervisor"); 41 insts = of_get_flat_dt_prop(node, "hcall-instructions", &len);
40 if (!hyper_node)
41 return -ENODEV;
42
43 insts = of_get_property(hyper_node, "hcall-instructions", &len);
44 if (!insts) 42 if (!insts)
45 return -ENODEV; 43 return 0;
46 44
47 if (len % 4 || len > (4 * 4)) 45 if (len % 4 || len > (4 * 4))
48 return -ENODEV; 46 return -1;
49 47
50 for (i = 0; i < (len / 4); i++) { 48 for (i = 0; i < (len / 4); i++) {
51 patch_instruction(epapr_hypercall_start + i, insts[i]); 49 patch_instruction(epapr_hypercall_start + i, insts[i]);
@@ -55,13 +53,19 @@ static int __init epapr_paravirt_init(void)
55 } 53 }
56 54
57#if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64) 55#if !defined(CONFIG_64BIT) || defined(CONFIG_PPC_BOOK3E_64)
58 if (of_get_property(hyper_node, "has-idle", NULL)) 56 if (of_get_flat_dt_prop(node, "has-idle", NULL))
59 ppc_md.power_save = epapr_ev_idle; 57 ppc_md.power_save = epapr_ev_idle;
60#endif 58#endif
61 59
62 epapr_paravirt_enabled = true; 60 epapr_paravirt_enabled = true;
63 61
62 return 1;
63}
64
65int __init epapr_paravirt_early_init(void)
66{
67 of_scan_flat_dt(early_init_dt_scan_epapr, NULL);
68
64 return 0; 69 return 0;
65} 70}
66 71
67early_initcall(epapr_paravirt_init);
diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
index 645170a07ada..2d067049db27 100644
--- a/arch/powerpc/kernel/exceptions-64e.S
+++ b/arch/powerpc/kernel/exceptions-64e.S
@@ -198,9 +198,9 @@ exc_##n##_common: \
198/* This second version is meant for exceptions that don't immediately 198/* This second version is meant for exceptions that don't immediately
199 * hard-enable. We set a bit in paca->irq_happened to ensure that 199 * hard-enable. We set a bit in paca->irq_happened to ensure that
200 * a subsequent call to arch_local_irq_restore() will properly 200 * a subsequent call to arch_local_irq_restore() will properly
201 * hard-enable and avoid the fast-path 201 * hard-enable and avoid the fast-path, and then reconcile irq state.
202 */ 202 */
203#define INTS_DISABLE SOFT_DISABLE_INTS(r3,r4) 203#define INTS_DISABLE RECONCILE_IRQ_STATE(r3,r4)
204 204
205/* This is called by exceptions that used INTS_KEEP (that did not touch 205/* This is called by exceptions that used INTS_KEEP (that did not touch
206 * irq indicators in the PACA). This will restore MSR:EE to it's previous 206 * irq indicators in the PACA). This will restore MSR:EE to it's previous
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 902ca3c6b4b6..3a9ed6ac224b 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -293,27 +293,31 @@ system_call_pSeries:
293 * out of line to handle them 293 * out of line to handle them
294 */ 294 */
295 . = 0xe00 295 . = 0xe00
296hv_exception_trampoline: 296hv_data_storage_trampoline:
297 SET_SCRATCH0(r13) 297 SET_SCRATCH0(r13)
298 EXCEPTION_PROLOG_0(PACA_EXGEN) 298 EXCEPTION_PROLOG_0(PACA_EXGEN)
299 b h_data_storage_hv 299 b h_data_storage_hv
300 300
301 . = 0xe20 301 . = 0xe20
302hv_instr_storage_trampoline:
302 SET_SCRATCH0(r13) 303 SET_SCRATCH0(r13)
303 EXCEPTION_PROLOG_0(PACA_EXGEN) 304 EXCEPTION_PROLOG_0(PACA_EXGEN)
304 b h_instr_storage_hv 305 b h_instr_storage_hv
305 306
306 . = 0xe40 307 . = 0xe40
308emulation_assist_trampoline:
307 SET_SCRATCH0(r13) 309 SET_SCRATCH0(r13)
308 EXCEPTION_PROLOG_0(PACA_EXGEN) 310 EXCEPTION_PROLOG_0(PACA_EXGEN)
309 b emulation_assist_hv 311 b emulation_assist_hv
310 312
311 . = 0xe60 313 . = 0xe60
314hv_exception_trampoline:
312 SET_SCRATCH0(r13) 315 SET_SCRATCH0(r13)
313 EXCEPTION_PROLOG_0(PACA_EXGEN) 316 EXCEPTION_PROLOG_0(PACA_EXGEN)
314 b hmi_exception_hv 317 b hmi_exception_hv
315 318
316 . = 0xe80 319 . = 0xe80
320hv_doorbell_trampoline:
317 SET_SCRATCH0(r13) 321 SET_SCRATCH0(r13)
318 EXCEPTION_PROLOG_0(PACA_EXGEN) 322 EXCEPTION_PROLOG_0(PACA_EXGEN)
319 b h_doorbell_hv 323 b h_doorbell_hv
@@ -323,32 +327,32 @@ hv_exception_trampoline:
323 * prolog code of the PerformanceMonitor one. A little 327 * prolog code of the PerformanceMonitor one. A little
324 * trickery is thus necessary 328 * trickery is thus necessary
325 */ 329 */
326performance_monitor_pSeries_1:
327 . = 0xf00 330 . = 0xf00
331performance_monitor_pseries_trampoline:
328 SET_SCRATCH0(r13) 332 SET_SCRATCH0(r13)
329 EXCEPTION_PROLOG_0(PACA_EXGEN) 333 EXCEPTION_PROLOG_0(PACA_EXGEN)
330 b performance_monitor_pSeries 334 b performance_monitor_pSeries
331 335
332altivec_unavailable_pSeries_1:
333 . = 0xf20 336 . = 0xf20
337altivec_unavailable_pseries_trampoline:
334 SET_SCRATCH0(r13) 338 SET_SCRATCH0(r13)
335 EXCEPTION_PROLOG_0(PACA_EXGEN) 339 EXCEPTION_PROLOG_0(PACA_EXGEN)
336 b altivec_unavailable_pSeries 340 b altivec_unavailable_pSeries
337 341
338vsx_unavailable_pSeries_1:
339 . = 0xf40 342 . = 0xf40
343vsx_unavailable_pseries_trampoline:
340 SET_SCRATCH0(r13) 344 SET_SCRATCH0(r13)
341 EXCEPTION_PROLOG_0(PACA_EXGEN) 345 EXCEPTION_PROLOG_0(PACA_EXGEN)
342 b vsx_unavailable_pSeries 346 b vsx_unavailable_pSeries
343 347
344facility_unavailable_trampoline:
345 . = 0xf60 348 . = 0xf60
349facility_unavailable_trampoline:
346 SET_SCRATCH0(r13) 350 SET_SCRATCH0(r13)
347 EXCEPTION_PROLOG_0(PACA_EXGEN) 351 EXCEPTION_PROLOG_0(PACA_EXGEN)
348 b facility_unavailable_pSeries 352 b facility_unavailable_pSeries
349 353
350hv_facility_unavailable_trampoline:
351 . = 0xf80 354 . = 0xf80
355hv_facility_unavailable_trampoline:
352 SET_SCRATCH0(r13) 356 SET_SCRATCH0(r13)
353 EXCEPTION_PROLOG_0(PACA_EXGEN) 357 EXCEPTION_PROLOG_0(PACA_EXGEN)
354 b facility_unavailable_hv 358 b facility_unavailable_hv
@@ -367,11 +371,7 @@ denorm_exception_hv:
367 HMT_MEDIUM_PPR_DISCARD 371 HMT_MEDIUM_PPR_DISCARD
368 mtspr SPRN_SPRG_HSCRATCH0,r13 372 mtspr SPRN_SPRG_HSCRATCH0,r13
369 EXCEPTION_PROLOG_0(PACA_EXGEN) 373 EXCEPTION_PROLOG_0(PACA_EXGEN)
370 std r11,PACA_EXGEN+EX_R11(r13) 374 EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, 0x1500)
371 std r12,PACA_EXGEN+EX_R12(r13)
372 mfspr r9,SPRN_SPRG_HSCRATCH0
373 std r9,PACA_EXGEN+EX_R13(r13)
374 mfcr r9
375 375
376#ifdef CONFIG_PPC_DENORMALISATION 376#ifdef CONFIG_PPC_DENORMALISATION
377 mfspr r10,SPRN_HSRR1 377 mfspr r10,SPRN_HSRR1
@@ -381,6 +381,7 @@ denorm_exception_hv:
381 bne+ denorm_assist 381 bne+ denorm_assist
382#endif 382#endif
383 383
384 KVMTEST(0x1500)
384 EXCEPTION_PROLOG_PSERIES_1(denorm_common, EXC_HV) 385 EXCEPTION_PROLOG_PSERIES_1(denorm_common, EXC_HV)
385 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x1500) 386 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x1500)
386 387
@@ -501,6 +502,10 @@ denorm_done:
501 mtcrf 0x80,r9 502 mtcrf 0x80,r9
502 ld r9,PACA_EXGEN+EX_R9(r13) 503 ld r9,PACA_EXGEN+EX_R9(r13)
503 RESTORE_PPR_PACA(PACA_EXGEN, r10) 504 RESTORE_PPR_PACA(PACA_EXGEN, r10)
505BEGIN_FTR_SECTION
506 ld r10,PACA_EXGEN+EX_CFAR(r13)
507 mtspr SPRN_CFAR,r10
508END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
504 ld r10,PACA_EXGEN+EX_R10(r13) 509 ld r10,PACA_EXGEN+EX_R10(r13)
505 ld r11,PACA_EXGEN+EX_R11(r13) 510 ld r11,PACA_EXGEN+EX_R11(r13)
506 ld r12,PACA_EXGEN+EX_R12(r13) 511 ld r12,PACA_EXGEN+EX_R12(r13)
@@ -808,6 +813,7 @@ system_call_relon_pSeries:
808 b . /* Can't happen, see v2.07 Book III-S section 6.5 */ 813 b . /* Can't happen, see v2.07 Book III-S section 6.5 */
809 814
810 . = 0x4e40 815 . = 0x4e40
816emulation_assist_relon_trampoline:
811 SET_SCRATCH0(r13) 817 SET_SCRATCH0(r13)
812 EXCEPTION_PROLOG_0(PACA_EXGEN) 818 EXCEPTION_PROLOG_0(PACA_EXGEN)
813 b emulation_assist_relon_hv 819 b emulation_assist_relon_hv
@@ -816,36 +822,37 @@ system_call_relon_pSeries:
816 b . /* Can't happen, see v2.07 Book III-S section 6.5 */ 822 b . /* Can't happen, see v2.07 Book III-S section 6.5 */
817 823
818 . = 0x4e80 824 . = 0x4e80
825h_doorbell_relon_trampoline:
819 SET_SCRATCH0(r13) 826 SET_SCRATCH0(r13)
820 EXCEPTION_PROLOG_0(PACA_EXGEN) 827 EXCEPTION_PROLOG_0(PACA_EXGEN)
821 b h_doorbell_relon_hv 828 b h_doorbell_relon_hv
822 829
823performance_monitor_relon_pSeries_1:
824 . = 0x4f00 830 . = 0x4f00
831performance_monitor_relon_pseries_trampoline:
825 SET_SCRATCH0(r13) 832 SET_SCRATCH0(r13)
826 EXCEPTION_PROLOG_0(PACA_EXGEN) 833 EXCEPTION_PROLOG_0(PACA_EXGEN)
827 b performance_monitor_relon_pSeries 834 b performance_monitor_relon_pSeries
828 835
829altivec_unavailable_relon_pSeries_1:
830 . = 0x4f20 836 . = 0x4f20
837altivec_unavailable_relon_pseries_trampoline:
831 SET_SCRATCH0(r13) 838 SET_SCRATCH0(r13)
832 EXCEPTION_PROLOG_0(PACA_EXGEN) 839 EXCEPTION_PROLOG_0(PACA_EXGEN)
833 b altivec_unavailable_relon_pSeries 840 b altivec_unavailable_relon_pSeries
834 841
835vsx_unavailable_relon_pSeries_1:
836 . = 0x4f40 842 . = 0x4f40
843vsx_unavailable_relon_pseries_trampoline:
837 SET_SCRATCH0(r13) 844 SET_SCRATCH0(r13)
838 EXCEPTION_PROLOG_0(PACA_EXGEN) 845 EXCEPTION_PROLOG_0(PACA_EXGEN)
839 b vsx_unavailable_relon_pSeries 846 b vsx_unavailable_relon_pSeries
840 847
841facility_unavailable_relon_trampoline:
842 . = 0x4f60 848 . = 0x4f60
849facility_unavailable_relon_trampoline:
843 SET_SCRATCH0(r13) 850 SET_SCRATCH0(r13)
844 EXCEPTION_PROLOG_0(PACA_EXGEN) 851 EXCEPTION_PROLOG_0(PACA_EXGEN)
845 b facility_unavailable_relon_pSeries 852 b facility_unavailable_relon_pSeries
846 853
847hv_facility_unavailable_relon_trampoline:
848 . = 0x4f80 854 . = 0x4f80
855hv_facility_unavailable_relon_trampoline:
849 SET_SCRATCH0(r13) 856 SET_SCRATCH0(r13)
850 EXCEPTION_PROLOG_0(PACA_EXGEN) 857 EXCEPTION_PROLOG_0(PACA_EXGEN)
851 b hv_facility_unavailable_relon_hv 858 b hv_facility_unavailable_relon_hv
diff --git a/arch/powerpc/kernel/head_40x.S b/arch/powerpc/kernel/head_40x.S
index 8a9b6f59822d..67ee0d6c1070 100644
--- a/arch/powerpc/kernel/head_40x.S
+++ b/arch/powerpc/kernel/head_40x.S
@@ -822,14 +822,6 @@ finish_tlb_load:
822 rfi /* Should sync shadow TLBs */ 822 rfi /* Should sync shadow TLBs */
823 b . /* prevent prefetch past rfi */ 823 b . /* prevent prefetch past rfi */
824 824
825/* extern void giveup_fpu(struct task_struct *prev)
826 *
827 * The PowerPC 4xx family of processors do not have an FPU, so this just
828 * returns.
829 */
830_ENTRY(giveup_fpu)
831 blr
832
833/* This is where the main kernel code starts. 825/* This is where the main kernel code starts.
834 */ 826 */
835start_here: 827start_here:
diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index 97e2671cde7f..c334f53453f7 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -784,16 +784,6 @@ _GLOBAL(__fixup_440A_mcheck)
784 sync 784 sync
785 blr 785 blr
786 786
787/*
788 * extern void giveup_fpu(struct task_struct *prev)
789 *
790 * The 44x core does not have an FPU.
791 */
792#ifndef CONFIG_PPC_FPU
793_GLOBAL(giveup_fpu)
794 blr
795#endif
796
797_GLOBAL(set_context) 787_GLOBAL(set_context)
798 788
799#ifdef CONFIG_BDI_SWITCH 789#ifdef CONFIG_BDI_SWITCH
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index b61363d557b5..3d11d8038dee 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -703,6 +703,7 @@ _GLOBAL(relative_toc)
703 mtlr r0 703 mtlr r0
704 blr 704 blr
705 705
706.balign 8
706p_toc: .llong __toc_start + 0x8000 - 0b 707p_toc: .llong __toc_start + 0x8000 - 0b
707 708
708/* 709/*
diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
index b2a5860accfb..1b92a97b1b04 100644
--- a/arch/powerpc/kernel/head_8xx.S
+++ b/arch/powerpc/kernel/head_8xx.S
@@ -691,10 +691,6 @@ modified_instr:
691 b 151b 691 b 151b
692#endif 692#endif
693 693
694 .globl giveup_fpu
695giveup_fpu:
696 blr
697
698/* 694/*
699 * This is where the main kernel code starts. 695 * This is where the main kernel code starts.
700 */ 696 */
diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S
index d10a7cacccd2..289afaffbbb5 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -948,16 +948,6 @@ _GLOBAL(giveup_spe)
948#endif /* CONFIG_SPE */ 948#endif /* CONFIG_SPE */
949 949
950/* 950/*
951 * extern void giveup_fpu(struct task_struct *prev)
952 *
953 * Not all FSL Book-E cores have an FPU
954 */
955#ifndef CONFIG_PPC_FPU
956_GLOBAL(giveup_fpu)
957 blr
958#endif
959
960/*
961 * extern void abort(void) 951 * extern void abort(void)
962 * 952 *
963 * At present, this routine just applies a system reset. 953 * At present, this routine just applies a system reset.
diff --git a/arch/powerpc/kernel/io-workarounds.c b/arch/powerpc/kernel/io-workarounds.c
index fa0b54b2a362..24b968f8e4d8 100644
--- a/arch/powerpc/kernel/io-workarounds.c
+++ b/arch/powerpc/kernel/io-workarounds.c
@@ -53,6 +53,7 @@ static struct iowa_bus *iowa_pci_find(unsigned long vaddr, unsigned long paddr)
53 return NULL; 53 return NULL;
54} 54}
55 55
56#ifdef CONFIG_PPC_INDIRECT_MMIO
56struct iowa_bus *iowa_mem_find_bus(const PCI_IO_ADDR addr) 57struct iowa_bus *iowa_mem_find_bus(const PCI_IO_ADDR addr)
57{ 58{
58 unsigned hugepage_shift; 59 unsigned hugepage_shift;
@@ -90,13 +91,25 @@ struct iowa_bus *iowa_mem_find_bus(const PCI_IO_ADDR addr)
90 91
91 return bus; 92 return bus;
92} 93}
94#else /* CONFIG_PPC_INDIRECT_MMIO */
95struct iowa_bus *iowa_mem_find_bus(const PCI_IO_ADDR addr)
96{
97 return NULL;
98}
99#endif /* !CONFIG_PPC_INDIRECT_MMIO */
93 100
101#ifdef CONFIG_PPC_INDIRECT_PIO
94struct iowa_bus *iowa_pio_find_bus(unsigned long port) 102struct iowa_bus *iowa_pio_find_bus(unsigned long port)
95{ 103{
96 unsigned long vaddr = (unsigned long)pci_io_base + port; 104 unsigned long vaddr = (unsigned long)pci_io_base + port;
97 return iowa_pci_find(vaddr, 0); 105 return iowa_pci_find(vaddr, 0);
98} 106}
99 107#else
108struct iowa_bus *iowa_pio_find_bus(unsigned long port)
109{
110 return NULL;
111}
112#endif
100 113
101#define DEF_PCI_AC_RET(name, ret, at, al, space, aa) \ 114#define DEF_PCI_AC_RET(name, ret, at, al, space, aa) \
102static ret iowa_##name at \ 115static ret iowa_##name at \
@@ -137,6 +150,7 @@ static const struct ppc_pci_io iowa_pci_io = {
137 150
138}; 151};
139 152
153#ifdef CONFIG_PPC_INDIRECT_MMIO
140static void __iomem *iowa_ioremap(phys_addr_t addr, unsigned long size, 154static void __iomem *iowa_ioremap(phys_addr_t addr, unsigned long size,
141 unsigned long flags, void *caller) 155 unsigned long flags, void *caller)
142{ 156{
@@ -151,6 +165,9 @@ static void __iomem *iowa_ioremap(phys_addr_t addr, unsigned long size,
151 } 165 }
152 return res; 166 return res;
153} 167}
168#else /* CONFIG_PPC_INDIRECT_MMIO */
169#define iowa_ioremap NULL
170#endif /* !CONFIG_PPC_INDIRECT_MMIO */
154 171
155/* Enable IO workaround */ 172/* Enable IO workaround */
156static void io_workaround_init(void) 173static void io_workaround_init(void)
diff --git a/arch/powerpc/kernel/io.c b/arch/powerpc/kernel/io.c
index 886381f32c3d..2a2b4aeab80f 100644
--- a/arch/powerpc/kernel/io.c
+++ b/arch/powerpc/kernel/io.c
@@ -25,6 +25,9 @@
25#include <asm/firmware.h> 25#include <asm/firmware.h>
26#include <asm/bug.h> 26#include <asm/bug.h>
27 27
28/* See definition in io.h */
29bool isa_io_special;
30
28void _insb(const volatile u8 __iomem *port, void *buf, long count) 31void _insb(const volatile u8 __iomem *port, void *buf, long count)
29{ 32{
30 u8 *tbuf = buf; 33 u8 *tbuf = buf;
diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index 0733b05eb856..22e88dd2f34a 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -99,7 +99,7 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
99 legacy_serial_count = index + 1; 99 legacy_serial_count = index + 1;
100 100
101 /* Check if there is a port who already claimed our slot */ 101 /* Check if there is a port who already claimed our slot */
102 if (legacy_serial_infos[index].np != 0) { 102 if (legacy_serial_infos[index].np != NULL) {
103 /* if we still have some room, move it, else override */ 103 /* if we still have some room, move it, else override */
104 if (legacy_serial_count < MAX_LEGACY_SERIAL_PORTS) { 104 if (legacy_serial_count < MAX_LEGACY_SERIAL_PORTS) {
105 printk(KERN_DEBUG "Moved legacy port %d -> %d\n", 105 printk(KERN_DEBUG "Moved legacy port %d -> %d\n",
@@ -152,7 +152,7 @@ static int __init add_legacy_soc_port(struct device_node *np,
152 struct device_node *soc_dev) 152 struct device_node *soc_dev)
153{ 153{
154 u64 addr; 154 u64 addr;
155 const u32 *addrp; 155 const __be32 *addrp;
156 upf_t flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_SHARE_IRQ 156 upf_t flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_SHARE_IRQ
157 | UPF_FIXED_PORT; 157 | UPF_FIXED_PORT;
158 struct device_node *tsi = of_get_parent(np); 158 struct device_node *tsi = of_get_parent(np);
@@ -221,14 +221,19 @@ static int __init add_legacy_isa_port(struct device_node *np,
221 /* Translate ISA address. If it fails, we still register the port 221 /* Translate ISA address. If it fails, we still register the port
222 * with no translated address so that it can be picked up as an IO 222 * with no translated address so that it can be picked up as an IO
223 * port later by the serial driver 223 * port later by the serial driver
224 *
225 * Note: Don't even try on P8 lpc, we know it's not directly mapped
224 */ 226 */
225 taddr = of_translate_address(np, reg); 227 if (!of_device_is_compatible(isa_brg, "ibm,power8-lpc")) {
226 if (taddr == OF_BAD_ADDR) 228 taddr = of_translate_address(np, reg);
229 if (taddr == OF_BAD_ADDR)
230 taddr = 0;
231 } else
227 taddr = 0; 232 taddr = 0;
228 233
229 /* Add port, irq will be dealt with later */ 234 /* Add port, irq will be dealt with later */
230 return add_legacy_port(np, index, UPIO_PORT, be32_to_cpu(reg[1]), taddr, 235 return add_legacy_port(np, index, UPIO_PORT, be32_to_cpu(reg[1]),
231 NO_IRQ, UPF_BOOT_AUTOCONF, 0); 236 taddr, NO_IRQ, UPF_BOOT_AUTOCONF, 0);
232 237
233} 238}
234 239
@@ -237,7 +242,7 @@ static int __init add_legacy_pci_port(struct device_node *np,
237 struct device_node *pci_dev) 242 struct device_node *pci_dev)
238{ 243{
239 u64 addr, base; 244 u64 addr, base;
240 const u32 *addrp; 245 const __be32 *addrp;
241 unsigned int flags; 246 unsigned int flags;
242 int iotype, index = -1, lindex = 0; 247 int iotype, index = -1, lindex = 0;
243 248
@@ -270,7 +275,7 @@ static int __init add_legacy_pci_port(struct device_node *np,
270 if (iotype == UPIO_MEM) 275 if (iotype == UPIO_MEM)
271 base = addr; 276 base = addr;
272 else 277 else
273 base = addrp[2]; 278 base = of_read_number(&addrp[2], 1);
274 279
275 /* Try to guess an index... If we have subdevices of the pci dev, 280 /* Try to guess an index... If we have subdevices of the pci dev,
276 * we get to their "reg" property 281 * we get to their "reg" property
@@ -307,19 +312,31 @@ static int __init add_legacy_pci_port(struct device_node *np,
307 312
308static void __init setup_legacy_serial_console(int console) 313static void __init setup_legacy_serial_console(int console)
309{ 314{
310 struct legacy_serial_info *info = 315 struct legacy_serial_info *info = &legacy_serial_infos[console];
311 &legacy_serial_infos[console]; 316 struct plat_serial8250_port *port = &legacy_serial_ports[console];
312 void __iomem *addr; 317 void __iomem *addr;
313 318
314 if (info->taddr == 0) 319 /* Check if a translated MMIO address has been found */
315 return; 320 if (info->taddr) {
316 addr = ioremap(info->taddr, 0x1000); 321 addr = ioremap(info->taddr, 0x1000);
317 if (addr == NULL) 322 if (addr == NULL)
318 return; 323 return;
324 udbg_uart_init_mmio(addr, 1);
325 } else {
326 /* Check if it's PIO and we support untranslated PIO */
327 if (port->iotype == UPIO_PORT && isa_io_special)
328 udbg_uart_init_pio(port->iobase, 1);
329 else
330 return;
331 }
332
333 /* Try to query the current speed */
319 if (info->speed == 0) 334 if (info->speed == 0)
320 info->speed = udbg_probe_uart_speed(addr, info->clock); 335 info->speed = udbg_probe_uart_speed(info->clock);
336
337 /* Set it up */
321 DBG("default console speed = %d\n", info->speed); 338 DBG("default console speed = %d\n", info->speed);
322 udbg_init_uart(addr, info->speed, info->clock); 339 udbg_uart_setup(info->speed, info->clock);
323} 340}
324 341
325/* 342/*
@@ -367,10 +384,13 @@ void __init find_legacy_serial_ports(void)
367 /* Next, fill our array with ISA ports */ 384 /* Next, fill our array with ISA ports */
368 for_each_node_by_type(np, "serial") { 385 for_each_node_by_type(np, "serial") {
369 struct device_node *isa = of_get_parent(np); 386 struct device_node *isa = of_get_parent(np);
370 if (isa && !strcmp(isa->name, "isa")) { 387 if (isa && (!strcmp(isa->name, "isa") ||
371 index = add_legacy_isa_port(np, isa); 388 !strcmp(isa->name, "lpc"))) {
372 if (index >= 0 && np == stdout) 389 if (of_device_is_available(np)) {
373 legacy_serial_console = index; 390 index = add_legacy_isa_port(np, isa);
391 if (index >= 0 && np == stdout)
392 legacy_serial_console = index;
393 }
374 } 394 }
375 of_node_put(isa); 395 of_node_put(isa);
376 } 396 }
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index e469f30e6eeb..777d999f563b 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -327,8 +327,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_UNIFIED_ID_CACHE)
327 * 327 *
328 * flush_icache_range(unsigned long start, unsigned long stop) 328 * flush_icache_range(unsigned long start, unsigned long stop)
329 */ 329 */
330_KPROBE(__flush_icache_range) 330_KPROBE(flush_icache_range)
331BEGIN_FTR_SECTION 331BEGIN_FTR_SECTION
332 isync
332 blr /* for 601, do nothing */ 333 blr /* for 601, do nothing */
333END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE) 334END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
334 li r5,L1_CACHE_BYTES-1 335 li r5,L1_CACHE_BYTES-1
diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
index 6820e45f557b..971d7e78aff2 100644
--- a/arch/powerpc/kernel/misc_64.S
+++ b/arch/powerpc/kernel/misc_64.S
@@ -67,8 +67,10 @@ PPC64_CACHES:
67 * flush all bytes from start through stop-1 inclusive 67 * flush all bytes from start through stop-1 inclusive
68 */ 68 */
69 69
70_KPROBE(__flush_icache_range) 70_KPROBE(flush_icache_range)
71 71BEGIN_FTR_SECTION
72 blr
73END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)
72/* 74/*
73 * Flush the data cache to memory 75 * Flush the data cache to memory
74 * 76 *
@@ -247,6 +249,37 @@ _GLOBAL(__bswapdi2)
247 blr 249 blr
248 250
249#if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE) 251#if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE)
252
253_GLOBAL(rmci_on)
254 sync
255 isync
256 li r3,0x100
257 rldicl r3,r3,32,0
258 mfspr r5,SPRN_HID4
259 or r5,r5,r3
260 sync
261 mtspr SPRN_HID4,r5
262 isync
263 slbia
264 isync
265 sync
266 blr
267
268_GLOBAL(rmci_off)
269 sync
270 isync
271 li r3,0x100
272 rldicl r3,r3,32,0
273 mfspr r5,SPRN_HID4
274 andc r5,r5,r3
275 sync
276 mtspr SPRN_HID4,r5
277 isync
278 slbia
279 isync
280 sync
281 blr
282
250/* 283/*
251 * Do an IO access in real mode 284 * Do an IO access in real mode
252 */ 285 */
@@ -416,19 +449,6 @@ _GLOBAL(scom970_write)
416 blr 449 blr
417#endif /* CONFIG_CPU_FREQ_PMAC64 || CONFIG_CPU_FREQ_MAPLE */ 450#endif /* CONFIG_CPU_FREQ_PMAC64 || CONFIG_CPU_FREQ_MAPLE */
418 451
419
420/*
421 * disable_kernel_fp()
422 * Disable the FPU.
423 */
424_GLOBAL(disable_kernel_fp)
425 mfmsr r3
426 rldicl r0,r3,(63-MSR_FP_LG),1
427 rldicl r3,r0,(MSR_FP_LG+1),0
428 mtmsrd r3 /* disable use of fpu now */
429 isync
430 blr
431
432/* kexec_wait(phys_cpu) 452/* kexec_wait(phys_cpu)
433 * 453 *
434 * wait for the flag to change, indicating this kernel is going away but 454 * wait for the flag to change, indicating this kernel is going away but
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c
index f8f24685f10a..3fc16e3beb9f 100644
--- a/arch/powerpc/kernel/paca.c
+++ b/arch/powerpc/kernel/paca.c
@@ -34,10 +34,10 @@ extern unsigned long __toc_start;
34 */ 34 */
35struct lppaca lppaca[] = { 35struct lppaca lppaca[] = {
36 [0 ... (NR_LPPACAS-1)] = { 36 [0 ... (NR_LPPACAS-1)] = {
37 .desc = 0xd397d781, /* "LpPa" */ 37 .desc = cpu_to_be32(0xd397d781), /* "LpPa" */
38 .size = sizeof(struct lppaca), 38 .size = cpu_to_be16(sizeof(struct lppaca)),
39 .fpregs_in_use = 1, 39 .fpregs_in_use = 1,
40 .slb_count = 64, 40 .slb_count = cpu_to_be16(64),
41 .vmxregs_in_use = 0, 41 .vmxregs_in_use = 0,
42 .page_ins = 0, 42 .page_ins = 0,
43 }, 43 },
@@ -101,8 +101,8 @@ static inline void free_lppacas(void) { }
101 */ 101 */
102struct slb_shadow slb_shadow[] __cacheline_aligned = { 102struct slb_shadow slb_shadow[] __cacheline_aligned = {
103 [0 ... (NR_CPUS-1)] = { 103 [0 ... (NR_CPUS-1)] = {
104 .persistent = SLB_NUM_BOLTED, 104 .persistent = cpu_to_be32(SLB_NUM_BOLTED),
105 .buffer_length = sizeof(struct slb_shadow), 105 .buffer_length = cpu_to_be32(sizeof(struct slb_shadow)),
106 }, 106 },
107}; 107};
108 108
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 2b4a9a4db7d9..905a24bb7acc 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -306,7 +306,7 @@ static struct resource *__pci_mmap_make_offset(struct pci_dev *dev,
306 unsigned long io_offset = 0; 306 unsigned long io_offset = 0;
307 int i, res_bit; 307 int i, res_bit;
308 308
309 if (hose == 0) 309 if (hose == NULL)
310 return NULL; /* should never happen */ 310 return NULL; /* should never happen */
311 311
312 /* If memory, add on the PCI bridge address offset */ 312 /* If memory, add on the PCI bridge address offset */
@@ -667,7 +667,7 @@ void pci_resource_to_user(const struct pci_dev *dev, int bar,
667void pci_process_bridge_OF_ranges(struct pci_controller *hose, 667void pci_process_bridge_OF_ranges(struct pci_controller *hose,
668 struct device_node *dev, int primary) 668 struct device_node *dev, int primary)
669{ 669{
670 const u32 *ranges; 670 const __be32 *ranges;
671 int rlen; 671 int rlen;
672 int pna = of_n_addr_cells(dev); 672 int pna = of_n_addr_cells(dev);
673 int np = pna + 5; 673 int np = pna + 5;
@@ -687,7 +687,7 @@ void pci_process_bridge_OF_ranges(struct pci_controller *hose,
687 /* Parse it */ 687 /* Parse it */
688 while ((rlen -= np * 4) >= 0) { 688 while ((rlen -= np * 4) >= 0) {
689 /* Read next ranges element */ 689 /* Read next ranges element */
690 pci_space = ranges[0]; 690 pci_space = of_read_number(ranges, 1);
691 pci_addr = of_read_number(ranges + 1, 2); 691 pci_addr = of_read_number(ranges + 1, 2);
692 cpu_addr = of_translate_address(dev, ranges + 3); 692 cpu_addr = of_translate_address(dev, ranges + 3);
693 size = of_read_number(ranges + pna + 3, 2); 693 size = of_read_number(ranges + pna + 3, 2);
@@ -704,7 +704,7 @@ void pci_process_bridge_OF_ranges(struct pci_controller *hose,
704 /* Now consume following elements while they are contiguous */ 704 /* Now consume following elements while they are contiguous */
705 for (; rlen >= np * sizeof(u32); 705 for (; rlen >= np * sizeof(u32);
706 ranges += np, rlen -= np * 4) { 706 ranges += np, rlen -= np * 4) {
707 if (ranges[0] != pci_space) 707 if (of_read_number(ranges, 1) != pci_space)
708 break; 708 break;
709 pci_next = of_read_number(ranges + 1, 2); 709 pci_next = of_read_number(ranges + 1, 2);
710 cpu_next = of_translate_address(dev, ranges + 3); 710 cpu_next = of_translate_address(dev, ranges + 3);
@@ -1055,8 +1055,7 @@ void pcibios_fixup_bus(struct pci_bus *bus)
1055 * bases. This is -not- called when generating the PCI tree from 1055 * bases. This is -not- called when generating the PCI tree from
1056 * the OF device-tree. 1056 * the OF device-tree.
1057 */ 1057 */
1058 if (bus->self != NULL) 1058 pci_read_bridge_bases(bus);
1059 pci_read_bridge_bases(bus);
1060 1059
1061 /* Now fixup the bus bus */ 1060 /* Now fixup the bus bus */
1062 pcibios_setup_bus_self(bus); 1061 pcibios_setup_bus_self(bus);
@@ -1578,7 +1577,7 @@ fake_pci_bus(struct pci_controller *hose, int busnr)
1578{ 1577{
1579 static struct pci_bus bus; 1578 static struct pci_bus bus;
1580 1579
1581 if (hose == 0) { 1580 if (hose == NULL) {
1582 printk(KERN_ERR "Can't find hose for PCI bus %d!\n", busnr); 1581 printk(KERN_ERR "Can't find hose for PCI bus %d!\n", busnr);
1583 } 1582 }
1584 bus.number = busnr; 1583 bus.number = busnr;
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 2e8629654ca8..a9e311f7a9dd 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -109,7 +109,7 @@ int pcibios_unmap_io_space(struct pci_bus *bus)
109 hose = pci_bus_to_host(bus); 109 hose = pci_bus_to_host(bus);
110 110
111 /* Check if we have IOs allocated */ 111 /* Check if we have IOs allocated */
112 if (hose->io_base_alloc == 0) 112 if (hose->io_base_alloc == NULL)
113 return 0; 113 return 0;
114 114
115 pr_debug("IO unmapping for PHB %s\n", hose->dn->full_name); 115 pr_debug("IO unmapping for PHB %s\n", hose->dn->full_name);
@@ -272,7 +272,7 @@ static void quirk_radeon_32bit_msi(struct pci_dev *dev)
272 struct pci_dn *pdn = pci_get_pdn(dev); 272 struct pci_dn *pdn = pci_get_pdn(dev);
273 273
274 if (pdn) 274 if (pdn)
275 pdn->force_32bit_msi = 1; 275 pdn->force_32bit_msi = true;
276} 276}
277DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x68f2, quirk_radeon_32bit_msi); 277DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x68f2, quirk_radeon_32bit_msi);
278DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0xaa68, quirk_radeon_32bit_msi); 278DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0xaa68, quirk_radeon_32bit_msi);
diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c
index df038442548a..1f61fab59d9b 100644
--- a/arch/powerpc/kernel/pci_dn.c
+++ b/arch/powerpc/kernel/pci_dn.c
@@ -47,9 +47,8 @@ struct pci_dn *pci_get_pdn(struct pci_dev *pdev)
47void *update_dn_pci_info(struct device_node *dn, void *data) 47void *update_dn_pci_info(struct device_node *dn, void *data)
48{ 48{
49 struct pci_controller *phb = data; 49 struct pci_controller *phb = data;
50 const int *type = 50 const __be32 *type = of_get_property(dn, "ibm,pci-config-space-type", NULL);
51 of_get_property(dn, "ibm,pci-config-space-type", NULL); 51 const __be32 *regs;
52 const u32 *regs;
53 struct pci_dn *pdn; 52 struct pci_dn *pdn;
54 53
55 pdn = zalloc_maybe_bootmem(sizeof(*pdn), GFP_KERNEL); 54 pdn = zalloc_maybe_bootmem(sizeof(*pdn), GFP_KERNEL);
@@ -63,12 +62,14 @@ void *update_dn_pci_info(struct device_node *dn, void *data)
63#endif 62#endif
64 regs = of_get_property(dn, "reg", NULL); 63 regs = of_get_property(dn, "reg", NULL);
65 if (regs) { 64 if (regs) {
65 u32 addr = of_read_number(regs, 1);
66
66 /* First register entry is addr (00BBSS00) */ 67 /* First register entry is addr (00BBSS00) */
67 pdn->busno = (regs[0] >> 16) & 0xff; 68 pdn->busno = (addr >> 16) & 0xff;
68 pdn->devfn = (regs[0] >> 8) & 0xff; 69 pdn->devfn = (addr >> 8) & 0xff;
69 } 70 }
70 71
71 pdn->pci_ext_config_space = (type && *type == 1); 72 pdn->pci_ext_config_space = (type && of_read_number(type, 1) == 1);
72 return NULL; 73 return NULL;
73} 74}
74 75
@@ -98,12 +99,13 @@ void *traverse_pci_devices(struct device_node *start, traverse_func pre,
98 99
99 /* We started with a phb, iterate all childs */ 100 /* We started with a phb, iterate all childs */
100 for (dn = start->child; dn; dn = nextdn) { 101 for (dn = start->child; dn; dn = nextdn) {
101 const u32 *classp; 102 const __be32 *classp;
102 u32 class; 103 u32 class = 0;
103 104
104 nextdn = NULL; 105 nextdn = NULL;
105 classp = of_get_property(dn, "class-code", NULL); 106 classp = of_get_property(dn, "class-code", NULL);
106 class = classp ? *classp : 0; 107 if (classp)
108 class = of_read_number(classp, 1);
107 109
108 if (pre && ((ret = pre(dn, data)) != NULL)) 110 if (pre && ((ret = pre(dn, data)) != NULL))
109 return ret; 111 return ret;
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
index 15d9105323bf..4368ec6fdc8c 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -24,12 +24,12 @@
24 */ 24 */
25static u32 get_int_prop(struct device_node *np, const char *name, u32 def) 25static u32 get_int_prop(struct device_node *np, const char *name, u32 def)
26{ 26{
27 const u32 *prop; 27 const __be32 *prop;
28 int len; 28 int len;
29 29
30 prop = of_get_property(np, name, &len); 30 prop = of_get_property(np, name, &len);
31 if (prop && len >= 4) 31 if (prop && len >= 4)
32 return *prop; 32 return of_read_number(prop, 1);
33 return def; 33 return def;
34} 34}
35 35
@@ -77,7 +77,7 @@ static void of_pci_parse_addrs(struct device_node *node, struct pci_dev *dev)
77 unsigned int flags; 77 unsigned int flags;
78 struct pci_bus_region region; 78 struct pci_bus_region region;
79 struct resource *res; 79 struct resource *res;
80 const u32 *addrs; 80 const __be32 *addrs;
81 u32 i; 81 u32 i;
82 int proplen; 82 int proplen;
83 83
@@ -86,14 +86,14 @@ static void of_pci_parse_addrs(struct device_node *node, struct pci_dev *dev)
86 return; 86 return;
87 pr_debug(" parse addresses (%d bytes) @ %p\n", proplen, addrs); 87 pr_debug(" parse addresses (%d bytes) @ %p\n", proplen, addrs);
88 for (; proplen >= 20; proplen -= 20, addrs += 5) { 88 for (; proplen >= 20; proplen -= 20, addrs += 5) {
89 flags = pci_parse_of_flags(addrs[0], 0); 89 flags = pci_parse_of_flags(of_read_number(addrs, 1), 0);
90 if (!flags) 90 if (!flags)
91 continue; 91 continue;
92 base = of_read_number(&addrs[1], 2); 92 base = of_read_number(&addrs[1], 2);
93 size = of_read_number(&addrs[3], 2); 93 size = of_read_number(&addrs[3], 2);
94 if (!size) 94 if (!size)
95 continue; 95 continue;
96 i = addrs[0] & 0xff; 96 i = of_read_number(addrs, 1) & 0xff;
97 pr_debug(" base: %llx, size: %llx, i: %x\n", 97 pr_debug(" base: %llx, size: %llx, i: %x\n",
98 (unsigned long long)base, 98 (unsigned long long)base,
99 (unsigned long long)size, i); 99 (unsigned long long)size, i);
@@ -207,7 +207,7 @@ void of_scan_pci_bridge(struct pci_dev *dev)
207{ 207{
208 struct device_node *node = dev->dev.of_node; 208 struct device_node *node = dev->dev.of_node;
209 struct pci_bus *bus; 209 struct pci_bus *bus;
210 const u32 *busrange, *ranges; 210 const __be32 *busrange, *ranges;
211 int len, i, mode; 211 int len, i, mode;
212 struct pci_bus_region region; 212 struct pci_bus_region region;
213 struct resource *res; 213 struct resource *res;
@@ -230,9 +230,11 @@ void of_scan_pci_bridge(struct pci_dev *dev)
230 return; 230 return;
231 } 231 }
232 232
233 bus = pci_find_bus(pci_domain_nr(dev->bus), busrange[0]); 233 bus = pci_find_bus(pci_domain_nr(dev->bus),
234 of_read_number(busrange, 1));
234 if (!bus) { 235 if (!bus) {
235 bus = pci_add_new_bus(dev->bus, dev, busrange[0]); 236 bus = pci_add_new_bus(dev->bus, dev,
237 of_read_number(busrange, 1));
236 if (!bus) { 238 if (!bus) {
237 printk(KERN_ERR "Failed to create pci bus for %s\n", 239 printk(KERN_ERR "Failed to create pci bus for %s\n",
238 node->full_name); 240 node->full_name);
@@ -241,7 +243,8 @@ void of_scan_pci_bridge(struct pci_dev *dev)
241 } 243 }
242 244
243 bus->primary = dev->bus->number; 245 bus->primary = dev->bus->number;
244 pci_bus_insert_busn_res(bus, busrange[0], busrange[1]); 246 pci_bus_insert_busn_res(bus, of_read_number(busrange, 1),
247 of_read_number(busrange+1, 1));
245 bus->bridge_ctl = 0; 248 bus->bridge_ctl = 0;
246 249
247 /* parse ranges property */ 250 /* parse ranges property */
@@ -254,7 +257,7 @@ void of_scan_pci_bridge(struct pci_dev *dev)
254 } 257 }
255 i = 1; 258 i = 1;
256 for (; len >= 32; len -= 32, ranges += 8) { 259 for (; len >= 32; len -= 32, ranges += 8) {
257 flags = pci_parse_of_flags(ranges[0], 1); 260 flags = pci_parse_of_flags(of_read_number(ranges, 1), 1);
258 size = of_read_number(&ranges[6], 2); 261 size = of_read_number(&ranges[6], 2);
259 if (flags == 0 || size == 0) 262 if (flags == 0 || size == 0)
260 continue; 263 continue;
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index c29666586998..21646dbe1bb3 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -96,7 +96,9 @@ EXPORT_SYMBOL(pci_dram_offset);
96 96
97EXPORT_SYMBOL(start_thread); 97EXPORT_SYMBOL(start_thread);
98 98
99#ifdef CONFIG_PPC_FPU
99EXPORT_SYMBOL(giveup_fpu); 100EXPORT_SYMBOL(giveup_fpu);
101#endif
100#ifdef CONFIG_ALTIVEC 102#ifdef CONFIG_ALTIVEC
101EXPORT_SYMBOL(giveup_altivec); 103EXPORT_SYMBOL(giveup_altivec);
102#endif /* CONFIG_ALTIVEC */ 104#endif /* CONFIG_ALTIVEC */
@@ -111,7 +113,6 @@ EXPORT_SYMBOL(giveup_spe);
111#ifndef CONFIG_PPC64 113#ifndef CONFIG_PPC64
112EXPORT_SYMBOL(flush_instruction_cache); 114EXPORT_SYMBOL(flush_instruction_cache);
113#endif 115#endif
114EXPORT_SYMBOL(__flush_icache_range);
115EXPORT_SYMBOL(flush_dcache_range); 116EXPORT_SYMBOL(flush_dcache_range);
116 117
117#ifdef CONFIG_SMP 118#ifdef CONFIG_SMP
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 8083be20fe5e..6f428da53e20 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -74,6 +74,7 @@ struct task_struct *last_task_used_vsx = NULL;
74struct task_struct *last_task_used_spe = NULL; 74struct task_struct *last_task_used_spe = NULL;
75#endif 75#endif
76 76
77#ifdef CONFIG_PPC_FPU
77/* 78/*
78 * Make sure the floating-point register state in the 79 * Make sure the floating-point register state in the
79 * the thread_struct is up to date for task tsk. 80 * the thread_struct is up to date for task tsk.
@@ -107,6 +108,7 @@ void flush_fp_to_thread(struct task_struct *tsk)
107 } 108 }
108} 109}
109EXPORT_SYMBOL_GPL(flush_fp_to_thread); 110EXPORT_SYMBOL_GPL(flush_fp_to_thread);
111#endif
110 112
111void enable_kernel_fp(void) 113void enable_kernel_fp(void)
112{ 114{
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 1c14cd4a5e05..6bfcab97c981 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -215,16 +215,16 @@ static void __init check_cpu_pa_features(unsigned long node)
215#ifdef CONFIG_PPC_STD_MMU_64 215#ifdef CONFIG_PPC_STD_MMU_64
216static void __init check_cpu_slb_size(unsigned long node) 216static void __init check_cpu_slb_size(unsigned long node)
217{ 217{
218 u32 *slb_size_ptr; 218 __be32 *slb_size_ptr;
219 219
220 slb_size_ptr = of_get_flat_dt_prop(node, "slb-size", NULL); 220 slb_size_ptr = of_get_flat_dt_prop(node, "slb-size", NULL);
221 if (slb_size_ptr != NULL) { 221 if (slb_size_ptr != NULL) {
222 mmu_slb_size = *slb_size_ptr; 222 mmu_slb_size = be32_to_cpup(slb_size_ptr);
223 return; 223 return;
224 } 224 }
225 slb_size_ptr = of_get_flat_dt_prop(node, "ibm,slb-size", NULL); 225 slb_size_ptr = of_get_flat_dt_prop(node, "ibm,slb-size", NULL);
226 if (slb_size_ptr != NULL) { 226 if (slb_size_ptr != NULL) {
227 mmu_slb_size = *slb_size_ptr; 227 mmu_slb_size = be32_to_cpup(slb_size_ptr);
228 } 228 }
229} 229}
230#else 230#else
@@ -279,11 +279,11 @@ static void __init check_cpu_feature_properties(unsigned long node)
279{ 279{
280 unsigned long i; 280 unsigned long i;
281 struct feature_property *fp = feature_properties; 281 struct feature_property *fp = feature_properties;
282 const u32 *prop; 282 const __be32 *prop;
283 283
284 for (i = 0; i < ARRAY_SIZE(feature_properties); ++i, ++fp) { 284 for (i = 0; i < ARRAY_SIZE(feature_properties); ++i, ++fp) {
285 prop = of_get_flat_dt_prop(node, fp->name, NULL); 285 prop = of_get_flat_dt_prop(node, fp->name, NULL);
286 if (prop && *prop >= fp->min_value) { 286 if (prop && be32_to_cpup(prop) >= fp->min_value) {
287 cur_cpu_spec->cpu_features |= fp->cpu_feature; 287 cur_cpu_spec->cpu_features |= fp->cpu_feature;
288 cur_cpu_spec->cpu_user_features |= fp->cpu_user_ftr; 288 cur_cpu_spec->cpu_user_features |= fp->cpu_user_ftr;
289 } 289 }
@@ -295,8 +295,8 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
295 void *data) 295 void *data)
296{ 296{
297 char *type = of_get_flat_dt_prop(node, "device_type", NULL); 297 char *type = of_get_flat_dt_prop(node, "device_type", NULL);
298 const u32 *prop; 298 const __be32 *prop;
299 const u32 *intserv; 299 const __be32 *intserv;
300 int i, nthreads; 300 int i, nthreads;
301 unsigned long len; 301 unsigned long len;
302 int found = -1; 302 int found = -1;
@@ -324,8 +324,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
324 * version 2 of the kexec param format adds the phys cpuid of 324 * version 2 of the kexec param format adds the phys cpuid of
325 * booted proc. 325 * booted proc.
326 */ 326 */
327 if (initial_boot_params->version >= 2) { 327 if (be32_to_cpu(initial_boot_params->version) >= 2) {
328 if (intserv[i] == initial_boot_params->boot_cpuid_phys) { 328 if (be32_to_cpu(intserv[i]) ==
329 be32_to_cpu(initial_boot_params->boot_cpuid_phys)) {
329 found = boot_cpu_count; 330 found = boot_cpu_count;
330 found_thread = i; 331 found_thread = i;
331 } 332 }
@@ -347,9 +348,10 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
347 348
348 if (found >= 0) { 349 if (found >= 0) {
349 DBG("boot cpu: logical %d physical %d\n", found, 350 DBG("boot cpu: logical %d physical %d\n", found,
350 intserv[found_thread]); 351 be32_to_cpu(intserv[found_thread]));
351 boot_cpuid = found; 352 boot_cpuid = found;
352 set_hard_smp_processor_id(found, intserv[found_thread]); 353 set_hard_smp_processor_id(found,
354 be32_to_cpu(intserv[found_thread]));
353 355
354 /* 356 /*
355 * PAPR defines "logical" PVR values for cpus that 357 * PAPR defines "logical" PVR values for cpus that
@@ -366,8 +368,8 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
366 * it uses 0x0f000001. 368 * it uses 0x0f000001.
367 */ 369 */
368 prop = of_get_flat_dt_prop(node, "cpu-version", NULL); 370 prop = of_get_flat_dt_prop(node, "cpu-version", NULL);
369 if (prop && (*prop & 0xff000000) == 0x0f000000) 371 if (prop && (be32_to_cpup(prop) & 0xff000000) == 0x0f000000)
370 identify_cpu(0, *prop); 372 identify_cpu(0, be32_to_cpup(prop));
371 373
372 identical_pvr_fixup(node); 374 identical_pvr_fixup(node);
373 } 375 }
@@ -389,7 +391,7 @@ static int __init early_init_dt_scan_cpus(unsigned long node,
389int __init early_init_dt_scan_chosen_ppc(unsigned long node, const char *uname, 391int __init early_init_dt_scan_chosen_ppc(unsigned long node, const char *uname,
390 int depth, void *data) 392 int depth, void *data)
391{ 393{
392 unsigned long *lprop; 394 unsigned long *lprop; /* All these set by kernel, so no need to convert endian */
393 395
394 /* Use common scan routine to determine if this is the chosen node */ 396 /* Use common scan routine to determine if this is the chosen node */
395 if (early_init_dt_scan_chosen(node, uname, depth, data) == 0) 397 if (early_init_dt_scan_chosen(node, uname, depth, data) == 0)
@@ -454,7 +456,7 @@ static int __init early_init_dt_scan_drconf_memory(unsigned long node)
454 if (dm == NULL || l < sizeof(__be32)) 456 if (dm == NULL || l < sizeof(__be32))
455 return 0; 457 return 0;
456 458
457 n = *dm++; /* number of entries */ 459 n = of_read_number(dm++, 1); /* number of entries */
458 if (l < (n * (dt_root_addr_cells + 4) + 1) * sizeof(__be32)) 460 if (l < (n * (dt_root_addr_cells + 4) + 1) * sizeof(__be32))
459 return 0; 461 return 0;
460 462
@@ -466,7 +468,7 @@ static int __init early_init_dt_scan_drconf_memory(unsigned long node)
466 468
467 for (; n != 0; --n) { 469 for (; n != 0; --n) {
468 base = dt_mem_next_cell(dt_root_addr_cells, &dm); 470 base = dt_mem_next_cell(dt_root_addr_cells, &dm);
469 flags = dm[3]; 471 flags = of_read_number(&dm[3], 1);
470 /* skip DRC index, pad, assoc. list index, flags */ 472 /* skip DRC index, pad, assoc. list index, flags */
471 dm += 4; 473 dm += 4;
472 /* skip this block if the reserved bit is set in flags (0x80) 474 /* skip this block if the reserved bit is set in flags (0x80)
@@ -591,16 +593,16 @@ static void __init early_reserve_mem_dt(void)
591static void __init early_reserve_mem(void) 593static void __init early_reserve_mem(void)
592{ 594{
593 u64 base, size; 595 u64 base, size;
594 u64 *reserve_map; 596 __be64 *reserve_map;
595 unsigned long self_base; 597 unsigned long self_base;
596 unsigned long self_size; 598 unsigned long self_size;
597 599
598 reserve_map = (u64 *)(((unsigned long)initial_boot_params) + 600 reserve_map = (__be64 *)(((unsigned long)initial_boot_params) +
599 initial_boot_params->off_mem_rsvmap); 601 be32_to_cpu(initial_boot_params->off_mem_rsvmap));
600 602
601 /* before we do anything, lets reserve the dt blob */ 603 /* before we do anything, lets reserve the dt blob */
602 self_base = __pa((unsigned long)initial_boot_params); 604 self_base = __pa((unsigned long)initial_boot_params);
603 self_size = initial_boot_params->totalsize; 605 self_size = be32_to_cpu(initial_boot_params->totalsize);
604 memblock_reserve(self_base, self_size); 606 memblock_reserve(self_base, self_size);
605 607
606 /* Look for the new "reserved-regions" property in the DT */ 608 /* Look for the new "reserved-regions" property in the DT */
@@ -620,15 +622,15 @@ static void __init early_reserve_mem(void)
620 * Handle the case where we might be booting from an old kexec 622 * Handle the case where we might be booting from an old kexec
621 * image that setup the mem_rsvmap as pairs of 32-bit values 623 * image that setup the mem_rsvmap as pairs of 32-bit values
622 */ 624 */
623 if (*reserve_map > 0xffffffffull) { 625 if (be64_to_cpup(reserve_map) > 0xffffffffull) {
624 u32 base_32, size_32; 626 u32 base_32, size_32;
625 u32 *reserve_map_32 = (u32 *)reserve_map; 627 __be32 *reserve_map_32 = (__be32 *)reserve_map;
626 628
627 DBG("Found old 32-bit reserve map\n"); 629 DBG("Found old 32-bit reserve map\n");
628 630
629 while (1) { 631 while (1) {
630 base_32 = *(reserve_map_32++); 632 base_32 = be32_to_cpup(reserve_map_32++);
631 size_32 = *(reserve_map_32++); 633 size_32 = be32_to_cpup(reserve_map_32++);
632 if (size_32 == 0) 634 if (size_32 == 0)
633 break; 635 break;
634 /* skip if the reservation is for the blob */ 636 /* skip if the reservation is for the blob */
@@ -644,8 +646,8 @@ static void __init early_reserve_mem(void)
644 646
645 /* Handle the reserve map in the fdt blob if it exists */ 647 /* Handle the reserve map in the fdt blob if it exists */
646 while (1) { 648 while (1) {
647 base = *(reserve_map++); 649 base = be64_to_cpup(reserve_map++);
648 size = *(reserve_map++); 650 size = be64_to_cpup(reserve_map++);
649 if (size == 0) 651 if (size == 0)
650 break; 652 break;
651 DBG("reserving: %llx -> %llx\n", base, size); 653 DBG("reserving: %llx -> %llx\n", base, size);
@@ -795,6 +797,32 @@ struct device_node *of_find_next_cache_node(struct device_node *np)
795 return NULL; 797 return NULL;
796} 798}
797 799
800/**
801 * of_get_ibm_chip_id - Returns the IBM "chip-id" of a device
802 * @np: device node of the device
803 *
804 * This looks for a property "ibm,chip-id" in the node or any
805 * of its parents and returns its content, or -1 if it cannot
806 * be found.
807 */
808int of_get_ibm_chip_id(struct device_node *np)
809{
810 of_node_get(np);
811 while(np) {
812 struct device_node *old = np;
813 const __be32 *prop;
814
815 prop = of_get_property(np, "ibm,chip-id", NULL);
816 if (prop) {
817 of_node_put(np);
818 return be32_to_cpup(prop);
819 }
820 np = of_get_parent(np);
821 of_node_put(old);
822 }
823 return -1;
824}
825
798#ifdef CONFIG_PPC_PSERIES 826#ifdef CONFIG_PPC_PSERIES
799/* 827/*
800 * Fix up the uninitialized fields in a new device node: 828 * Fix up the uninitialized fields in a new device node:
@@ -878,7 +906,7 @@ static int __init export_flat_device_tree(void)
878 struct dentry *d; 906 struct dentry *d;
879 907
880 flat_dt_blob.data = initial_boot_params; 908 flat_dt_blob.data = initial_boot_params;
881 flat_dt_blob.size = initial_boot_params->totalsize; 909 flat_dt_blob.size = be32_to_cpu(initial_boot_params->totalsize);
882 910
883 d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR, 911 d = debugfs_create_blob("flat-device-tree", S_IFREG | S_IRUSR,
884 powerpc_debugfs_root, &flat_dt_blob); 912 powerpc_debugfs_root, &flat_dt_blob);
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 607902424e73..7b6391b68fb8 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -107,10 +107,10 @@ int of_workarounds;
107typedef u32 prom_arg_t; 107typedef u32 prom_arg_t;
108 108
109struct prom_args { 109struct prom_args {
110 u32 service; 110 __be32 service;
111 u32 nargs; 111 __be32 nargs;
112 u32 nret; 112 __be32 nret;
113 prom_arg_t args[10]; 113 __be32 args[10];
114}; 114};
115 115
116struct prom_t { 116struct prom_t {
@@ -123,11 +123,11 @@ struct prom_t {
123}; 123};
124 124
125struct mem_map_entry { 125struct mem_map_entry {
126 u64 base; 126 __be64 base;
127 u64 size; 127 __be64 size;
128}; 128};
129 129
130typedef u32 cell_t; 130typedef __be32 cell_t;
131 131
132extern void __start(unsigned long r3, unsigned long r4, unsigned long r5, 132extern void __start(unsigned long r3, unsigned long r4, unsigned long r5,
133 unsigned long r6, unsigned long r7, unsigned long r8, 133 unsigned long r6, unsigned long r7, unsigned long r8,
@@ -219,13 +219,13 @@ static int __init call_prom(const char *service, int nargs, int nret, ...)
219 struct prom_args args; 219 struct prom_args args;
220 va_list list; 220 va_list list;
221 221
222 args.service = ADDR(service); 222 args.service = cpu_to_be32(ADDR(service));
223 args.nargs = nargs; 223 args.nargs = cpu_to_be32(nargs);
224 args.nret = nret; 224 args.nret = cpu_to_be32(nret);
225 225
226 va_start(list, nret); 226 va_start(list, nret);
227 for (i = 0; i < nargs; i++) 227 for (i = 0; i < nargs; i++)
228 args.args[i] = va_arg(list, prom_arg_t); 228 args.args[i] = cpu_to_be32(va_arg(list, prom_arg_t));
229 va_end(list); 229 va_end(list);
230 230
231 for (i = 0; i < nret; i++) 231 for (i = 0; i < nret; i++)
@@ -234,7 +234,7 @@ static int __init call_prom(const char *service, int nargs, int nret, ...)
234 if (enter_prom(&args, prom_entry) < 0) 234 if (enter_prom(&args, prom_entry) < 0)
235 return PROM_ERROR; 235 return PROM_ERROR;
236 236
237 return (nret > 0) ? args.args[nargs] : 0; 237 return (nret > 0) ? be32_to_cpu(args.args[nargs]) : 0;
238} 238}
239 239
240static int __init call_prom_ret(const char *service, int nargs, int nret, 240static int __init call_prom_ret(const char *service, int nargs, int nret,
@@ -244,13 +244,13 @@ static int __init call_prom_ret(const char *service, int nargs, int nret,
244 struct prom_args args; 244 struct prom_args args;
245 va_list list; 245 va_list list;
246 246
247 args.service = ADDR(service); 247 args.service = cpu_to_be32(ADDR(service));
248 args.nargs = nargs; 248 args.nargs = cpu_to_be32(nargs);
249 args.nret = nret; 249 args.nret = cpu_to_be32(nret);
250 250
251 va_start(list, rets); 251 va_start(list, rets);
252 for (i = 0; i < nargs; i++) 252 for (i = 0; i < nargs; i++)
253 args.args[i] = va_arg(list, prom_arg_t); 253 args.args[i] = cpu_to_be32(va_arg(list, prom_arg_t));
254 va_end(list); 254 va_end(list);
255 255
256 for (i = 0; i < nret; i++) 256 for (i = 0; i < nret; i++)
@@ -261,9 +261,9 @@ static int __init call_prom_ret(const char *service, int nargs, int nret,
261 261
262 if (rets != NULL) 262 if (rets != NULL)
263 for (i = 1; i < nret; ++i) 263 for (i = 1; i < nret; ++i)
264 rets[i-1] = args.args[nargs+i]; 264 rets[i-1] = be32_to_cpu(args.args[nargs+i]);
265 265
266 return (nret > 0) ? args.args[nargs] : 0; 266 return (nret > 0) ? be32_to_cpu(args.args[nargs]) : 0;
267} 267}
268 268
269 269
@@ -527,7 +527,7 @@ static int __init prom_setprop(phandle node, const char *nodename,
527#define islower(c) ('a' <= (c) && (c) <= 'z') 527#define islower(c) ('a' <= (c) && (c) <= 'z')
528#define toupper(c) (islower(c) ? ((c) - 'a' + 'A') : (c)) 528#define toupper(c) (islower(c) ? ((c) - 'a' + 'A') : (c))
529 529
530unsigned long prom_strtoul(const char *cp, const char **endp) 530static unsigned long prom_strtoul(const char *cp, const char **endp)
531{ 531{
532 unsigned long result = 0, base = 10, value; 532 unsigned long result = 0, base = 10, value;
533 533
@@ -552,7 +552,7 @@ unsigned long prom_strtoul(const char *cp, const char **endp)
552 return result; 552 return result;
553} 553}
554 554
555unsigned long prom_memparse(const char *ptr, const char **retptr) 555static unsigned long prom_memparse(const char *ptr, const char **retptr)
556{ 556{
557 unsigned long ret = prom_strtoul(ptr, retptr); 557 unsigned long ret = prom_strtoul(ptr, retptr);
558 int shift = 0; 558 int shift = 0;
@@ -724,7 +724,8 @@ unsigned char ibm_architecture_vec[] = {
724 724
725}; 725};
726 726
727/* Old method - ELF header with PT_NOTE sections */ 727/* Old method - ELF header with PT_NOTE sections only works on BE */
728#ifdef __BIG_ENDIAN__
728static struct fake_elf { 729static struct fake_elf {
729 Elf32_Ehdr elfhdr; 730 Elf32_Ehdr elfhdr;
730 Elf32_Phdr phdr[2]; 731 Elf32_Phdr phdr[2];
@@ -810,6 +811,7 @@ static struct fake_elf {
810 } 811 }
811 } 812 }
812}; 813};
814#endif /* __BIG_ENDIAN__ */
813 815
814static int __init prom_count_smt_threads(void) 816static int __init prom_count_smt_threads(void)
815{ 817{
@@ -852,9 +854,9 @@ static int __init prom_count_smt_threads(void)
852 854
853static void __init prom_send_capabilities(void) 855static void __init prom_send_capabilities(void)
854{ 856{
855 ihandle elfloader, root; 857 ihandle root;
856 prom_arg_t ret; 858 prom_arg_t ret;
857 u32 *cores; 859 __be32 *cores;
858 860
859 root = call_prom("open", 1, 1, ADDR("/")); 861 root = call_prom("open", 1, 1, ADDR("/"));
860 if (root != 0) { 862 if (root != 0) {
@@ -864,15 +866,15 @@ static void __init prom_send_capabilities(void)
864 * (we assume this is the same for all cores) and use it to 866 * (we assume this is the same for all cores) and use it to
865 * divide NR_CPUS. 867 * divide NR_CPUS.
866 */ 868 */
867 cores = (u32 *)&ibm_architecture_vec[IBM_ARCH_VEC_NRCORES_OFFSET]; 869 cores = (__be32 *)&ibm_architecture_vec[IBM_ARCH_VEC_NRCORES_OFFSET];
868 if (*cores != NR_CPUS) { 870 if (be32_to_cpup(cores) != NR_CPUS) {
869 prom_printf("WARNING ! " 871 prom_printf("WARNING ! "
870 "ibm_architecture_vec structure inconsistent: %lu!\n", 872 "ibm_architecture_vec structure inconsistent: %lu!\n",
871 *cores); 873 be32_to_cpup(cores));
872 } else { 874 } else {
873 *cores = DIV_ROUND_UP(NR_CPUS, prom_count_smt_threads()); 875 *cores = cpu_to_be32(DIV_ROUND_UP(NR_CPUS, prom_count_smt_threads()));
874 prom_printf("Max number of cores passed to firmware: %lu (NR_CPUS = %lu)\n", 876 prom_printf("Max number of cores passed to firmware: %lu (NR_CPUS = %lu)\n",
875 *cores, NR_CPUS); 877 be32_to_cpup(cores), NR_CPUS);
876 } 878 }
877 879
878 /* try calling the ibm,client-architecture-support method */ 880 /* try calling the ibm,client-architecture-support method */
@@ -893,17 +895,24 @@ static void __init prom_send_capabilities(void)
893 prom_printf(" not implemented\n"); 895 prom_printf(" not implemented\n");
894 } 896 }
895 897
896 /* no ibm,client-architecture-support call, try the old way */ 898#ifdef __BIG_ENDIAN__
897 elfloader = call_prom("open", 1, 1, ADDR("/packages/elf-loader")); 899 {
898 if (elfloader == 0) { 900 ihandle elfloader;
899 prom_printf("couldn't open /packages/elf-loader\n"); 901
900 return; 902 /* no ibm,client-architecture-support call, try the old way */
903 elfloader = call_prom("open", 1, 1,
904 ADDR("/packages/elf-loader"));
905 if (elfloader == 0) {
906 prom_printf("couldn't open /packages/elf-loader\n");
907 return;
908 }
909 call_prom("call-method", 3, 1, ADDR("process-elf-header"),
910 elfloader, ADDR(&fake_elf));
911 call_prom("close", 1, 0, elfloader);
901 } 912 }
902 call_prom("call-method", 3, 1, ADDR("process-elf-header"), 913#endif /* __BIG_ENDIAN__ */
903 elfloader, ADDR(&fake_elf));
904 call_prom("close", 1, 0, elfloader);
905} 914}
906#endif 915#endif /* #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_POWERNV) */
907 916
908/* 917/*
909 * Memory allocation strategy... our layout is normally: 918 * Memory allocation strategy... our layout is normally:
@@ -1050,11 +1059,11 @@ static unsigned long __init prom_next_cell(int s, cell_t **cellp)
1050 p++; 1059 p++;
1051 s--; 1060 s--;
1052 } 1061 }
1053 r = *p++; 1062 r = be32_to_cpu(*p++);
1054#ifdef CONFIG_PPC64 1063#ifdef CONFIG_PPC64
1055 if (s > 1) { 1064 if (s > 1) {
1056 r <<= 32; 1065 r <<= 32;
1057 r |= *(p++); 1066 r |= be32_to_cpu(*(p++));
1058 } 1067 }
1059#endif 1068#endif
1060 *cellp = p; 1069 *cellp = p;
@@ -1087,8 +1096,8 @@ static void __init reserve_mem(u64 base, u64 size)
1087 1096
1088 if (cnt >= (MEM_RESERVE_MAP_SIZE - 1)) 1097 if (cnt >= (MEM_RESERVE_MAP_SIZE - 1))
1089 prom_panic("Memory reserve map exhausted !\n"); 1098 prom_panic("Memory reserve map exhausted !\n");
1090 mem_reserve_map[cnt].base = base; 1099 mem_reserve_map[cnt].base = cpu_to_be64(base);
1091 mem_reserve_map[cnt].size = size; 1100 mem_reserve_map[cnt].size = cpu_to_be64(size);
1092 mem_reserve_cnt = cnt + 1; 1101 mem_reserve_cnt = cnt + 1;
1093} 1102}
1094 1103
@@ -1102,6 +1111,7 @@ static void __init prom_init_mem(void)
1102 char *path, type[64]; 1111 char *path, type[64];
1103 unsigned int plen; 1112 unsigned int plen;
1104 cell_t *p, *endp; 1113 cell_t *p, *endp;
1114 __be32 val;
1105 u32 rac, rsc; 1115 u32 rac, rsc;
1106 1116
1107 /* 1117 /*
@@ -1109,12 +1119,14 @@ static void __init prom_init_mem(void)
1109 * 1) top of RMO (first node) 1119 * 1) top of RMO (first node)
1110 * 2) top of memory 1120 * 2) top of memory
1111 */ 1121 */
1112 rac = 2; 1122 val = cpu_to_be32(2);
1113 prom_getprop(prom.root, "#address-cells", &rac, sizeof(rac)); 1123 prom_getprop(prom.root, "#address-cells", &val, sizeof(val));
1114 rsc = 1; 1124 rac = be32_to_cpu(val);
1115 prom_getprop(prom.root, "#size-cells", &rsc, sizeof(rsc)); 1125 val = cpu_to_be32(1);
1116 prom_debug("root_addr_cells: %x\n", (unsigned long) rac); 1126 prom_getprop(prom.root, "#size-cells", &val, sizeof(rsc));
1117 prom_debug("root_size_cells: %x\n", (unsigned long) rsc); 1127 rsc = be32_to_cpu(val);
1128 prom_debug("root_addr_cells: %x\n", rac);
1129 prom_debug("root_size_cells: %x\n", rsc);
1118 1130
1119 prom_debug("scanning memory:\n"); 1131 prom_debug("scanning memory:\n");
1120 path = prom_scratch; 1132 path = prom_scratch;
@@ -1222,25 +1234,23 @@ static void __init prom_init_mem(void)
1222 1234
1223static void __init prom_close_stdin(void) 1235static void __init prom_close_stdin(void)
1224{ 1236{
1225 ihandle val; 1237 __be32 val;
1238 ihandle stdin;
1226 1239
1227 if (prom_getprop(prom.chosen, "stdin", &val, sizeof(val)) > 0) 1240 if (prom_getprop(prom.chosen, "stdin", &val, sizeof(val)) > 0) {
1228 call_prom("close", 1, 0, val); 1241 stdin = be32_to_cpu(val);
1242 call_prom("close", 1, 0, stdin);
1243 }
1229} 1244}
1230 1245
1231#ifdef CONFIG_PPC_POWERNV 1246#ifdef CONFIG_PPC_POWERNV
1232 1247
1233static u64 __initdata prom_opal_size;
1234static u64 __initdata prom_opal_align;
1235static int __initdata prom_rtas_start_cpu;
1236static u64 __initdata prom_rtas_data;
1237static u64 __initdata prom_rtas_entry;
1238
1239#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL 1248#ifdef CONFIG_PPC_EARLY_DEBUG_OPAL
1240static u64 __initdata prom_opal_base; 1249static u64 __initdata prom_opal_base;
1241static u64 __initdata prom_opal_entry; 1250static u64 __initdata prom_opal_entry;
1242#endif 1251#endif
1243 1252
1253#ifdef __BIG_ENDIAN__
1244/* XXX Don't change this structure without updating opal-takeover.S */ 1254/* XXX Don't change this structure without updating opal-takeover.S */
1245static struct opal_secondary_data { 1255static struct opal_secondary_data {
1246 s64 ack; /* 0 */ 1256 s64 ack; /* 0 */
@@ -1248,6 +1258,12 @@ static struct opal_secondary_data {
1248 struct opal_takeover_args args; /* 16 */ 1258 struct opal_takeover_args args; /* 16 */
1249} opal_secondary_data; 1259} opal_secondary_data;
1250 1260
1261static u64 __initdata prom_opal_align;
1262static u64 __initdata prom_opal_size;
1263static int __initdata prom_rtas_start_cpu;
1264static u64 __initdata prom_rtas_data;
1265static u64 __initdata prom_rtas_entry;
1266
1251extern char opal_secondary_entry; 1267extern char opal_secondary_entry;
1252 1268
1253static void __init prom_query_opal(void) 1269static void __init prom_query_opal(void)
@@ -1265,6 +1281,7 @@ static void __init prom_query_opal(void)
1265 } 1281 }
1266 1282
1267 prom_printf("Querying for OPAL presence... "); 1283 prom_printf("Querying for OPAL presence... ");
1284
1268 rc = opal_query_takeover(&prom_opal_size, 1285 rc = opal_query_takeover(&prom_opal_size,
1269 &prom_opal_align); 1286 &prom_opal_align);
1270 prom_debug("(rc = %ld) ", rc); 1287 prom_debug("(rc = %ld) ", rc);
@@ -1425,6 +1442,7 @@ static void __init prom_opal_takeover(void)
1425 for (;;) 1442 for (;;)
1426 opal_do_takeover(args); 1443 opal_do_takeover(args);
1427} 1444}
1445#endif /* __BIG_ENDIAN__ */
1428 1446
1429/* 1447/*
1430 * Allocate room for and instantiate OPAL 1448 * Allocate room for and instantiate OPAL
@@ -1435,6 +1453,7 @@ static void __init prom_instantiate_opal(void)
1435 ihandle opal_inst; 1453 ihandle opal_inst;
1436 u64 base, entry; 1454 u64 base, entry;
1437 u64 size = 0, align = 0x10000; 1455 u64 size = 0, align = 0x10000;
1456 __be64 val64;
1438 u32 rets[2]; 1457 u32 rets[2];
1439 1458
1440 prom_debug("prom_instantiate_opal: start...\n"); 1459 prom_debug("prom_instantiate_opal: start...\n");
@@ -1444,11 +1463,14 @@ static void __init prom_instantiate_opal(void)
1444 if (!PHANDLE_VALID(opal_node)) 1463 if (!PHANDLE_VALID(opal_node))
1445 return; 1464 return;
1446 1465
1447 prom_getprop(opal_node, "opal-runtime-size", &size, sizeof(size)); 1466 val64 = 0;
1467 prom_getprop(opal_node, "opal-runtime-size", &val64, sizeof(val64));
1468 size = be64_to_cpu(val64);
1448 if (size == 0) 1469 if (size == 0)
1449 return; 1470 return;
1450 prom_getprop(opal_node, "opal-runtime-alignment", &align, 1471 val64 = 0;
1451 sizeof(align)); 1472 prom_getprop(opal_node, "opal-runtime-alignment", &val64,sizeof(val64));
1473 align = be64_to_cpu(val64);
1452 1474
1453 base = alloc_down(size, align, 0); 1475 base = alloc_down(size, align, 0);
1454 if (base == 0) { 1476 if (base == 0) {
@@ -1505,6 +1527,7 @@ static void __init prom_instantiate_rtas(void)
1505 phandle rtas_node; 1527 phandle rtas_node;
1506 ihandle rtas_inst; 1528 ihandle rtas_inst;
1507 u32 base, entry = 0; 1529 u32 base, entry = 0;
1530 __be32 val;
1508 u32 size = 0; 1531 u32 size = 0;
1509 1532
1510 prom_debug("prom_instantiate_rtas: start...\n"); 1533 prom_debug("prom_instantiate_rtas: start...\n");
@@ -1514,7 +1537,9 @@ static void __init prom_instantiate_rtas(void)
1514 if (!PHANDLE_VALID(rtas_node)) 1537 if (!PHANDLE_VALID(rtas_node))
1515 return; 1538 return;
1516 1539
1517 prom_getprop(rtas_node, "rtas-size", &size, sizeof(size)); 1540 val = 0;
1541 prom_getprop(rtas_node, "rtas-size", &val, sizeof(size));
1542 size = be32_to_cpu(val);
1518 if (size == 0) 1543 if (size == 0)
1519 return; 1544 return;
1520 1545
@@ -1541,12 +1566,14 @@ static void __init prom_instantiate_rtas(void)
1541 1566
1542 reserve_mem(base, size); 1567 reserve_mem(base, size);
1543 1568
1569 val = cpu_to_be32(base);
1544 prom_setprop(rtas_node, "/rtas", "linux,rtas-base", 1570 prom_setprop(rtas_node, "/rtas", "linux,rtas-base",
1545 &base, sizeof(base)); 1571 &val, sizeof(val));
1572 val = cpu_to_be32(entry);
1546 prom_setprop(rtas_node, "/rtas", "linux,rtas-entry", 1573 prom_setprop(rtas_node, "/rtas", "linux,rtas-entry",
1547 &entry, sizeof(entry)); 1574 &val, sizeof(val));
1548 1575
1549#ifdef CONFIG_PPC_POWERNV 1576#if defined(CONFIG_PPC_POWERNV) && defined(__BIG_ENDIAN__)
1550 /* PowerVN takeover hack */ 1577 /* PowerVN takeover hack */
1551 prom_rtas_data = base; 1578 prom_rtas_data = base;
1552 prom_rtas_entry = entry; 1579 prom_rtas_entry = entry;
@@ -1620,6 +1647,7 @@ static void __init prom_instantiate_sml(void)
1620/* 1647/*
1621 * Allocate room for and initialize TCE tables 1648 * Allocate room for and initialize TCE tables
1622 */ 1649 */
1650#ifdef __BIG_ENDIAN__
1623static void __init prom_initialize_tce_table(void) 1651static void __init prom_initialize_tce_table(void)
1624{ 1652{
1625 phandle node; 1653 phandle node;
@@ -1748,7 +1776,8 @@ static void __init prom_initialize_tce_table(void)
1748 /* Flag the first invalid entry */ 1776 /* Flag the first invalid entry */
1749 prom_debug("ending prom_initialize_tce_table\n"); 1777 prom_debug("ending prom_initialize_tce_table\n");
1750} 1778}
1751#endif 1779#endif /* __BIG_ENDIAN__ */
1780#endif /* CONFIG_PPC64 */
1752 1781
1753/* 1782/*
1754 * With CHRP SMP we need to use the OF to start the other processors. 1783 * With CHRP SMP we need to use the OF to start the other processors.
@@ -1777,7 +1806,6 @@ static void __init prom_initialize_tce_table(void)
1777static void __init prom_hold_cpus(void) 1806static void __init prom_hold_cpus(void)
1778{ 1807{
1779 unsigned long i; 1808 unsigned long i;
1780 unsigned int reg;
1781 phandle node; 1809 phandle node;
1782 char type[64]; 1810 char type[64];
1783 unsigned long *spinloop 1811 unsigned long *spinloop
@@ -1803,6 +1831,9 @@ static void __init prom_hold_cpus(void)
1803 1831
1804 /* look for cpus */ 1832 /* look for cpus */
1805 for (node = 0; prom_next_node(&node); ) { 1833 for (node = 0; prom_next_node(&node); ) {
1834 unsigned int cpu_no;
1835 __be32 reg;
1836
1806 type[0] = 0; 1837 type[0] = 0;
1807 prom_getprop(node, "device_type", type, sizeof(type)); 1838 prom_getprop(node, "device_type", type, sizeof(type));
1808 if (strcmp(type, "cpu") != 0) 1839 if (strcmp(type, "cpu") != 0)
@@ -1813,10 +1844,11 @@ static void __init prom_hold_cpus(void)
1813 if (strcmp(type, "okay") != 0) 1844 if (strcmp(type, "okay") != 0)
1814 continue; 1845 continue;
1815 1846
1816 reg = -1; 1847 reg = cpu_to_be32(-1); /* make sparse happy */
1817 prom_getprop(node, "reg", &reg, sizeof(reg)); 1848 prom_getprop(node, "reg", &reg, sizeof(reg));
1849 cpu_no = be32_to_cpu(reg);
1818 1850
1819 prom_debug("cpu hw idx = %lu\n", reg); 1851 prom_debug("cpu hw idx = %lu\n", cpu_no);
1820 1852
1821 /* Init the acknowledge var which will be reset by 1853 /* Init the acknowledge var which will be reset by
1822 * the secondary cpu when it awakens from its OF 1854 * the secondary cpu when it awakens from its OF
@@ -1824,24 +1856,24 @@ static void __init prom_hold_cpus(void)
1824 */ 1856 */
1825 *acknowledge = (unsigned long)-1; 1857 *acknowledge = (unsigned long)-1;
1826 1858
1827 if (reg != prom.cpu) { 1859 if (cpu_no != prom.cpu) {
1828 /* Primary Thread of non-boot cpu or any thread */ 1860 /* Primary Thread of non-boot cpu or any thread */
1829 prom_printf("starting cpu hw idx %lu... ", reg); 1861 prom_printf("starting cpu hw idx %lu... ", cpu_no);
1830 call_prom("start-cpu", 3, 0, node, 1862 call_prom("start-cpu", 3, 0, node,
1831 secondary_hold, reg); 1863 secondary_hold, cpu_no);
1832 1864
1833 for (i = 0; (i < 100000000) && 1865 for (i = 0; (i < 100000000) &&
1834 (*acknowledge == ((unsigned long)-1)); i++ ) 1866 (*acknowledge == ((unsigned long)-1)); i++ )
1835 mb(); 1867 mb();
1836 1868
1837 if (*acknowledge == reg) 1869 if (*acknowledge == cpu_no)
1838 prom_printf("done\n"); 1870 prom_printf("done\n");
1839 else 1871 else
1840 prom_printf("failed: %x\n", *acknowledge); 1872 prom_printf("failed: %x\n", *acknowledge);
1841 } 1873 }
1842#ifdef CONFIG_SMP 1874#ifdef CONFIG_SMP
1843 else 1875 else
1844 prom_printf("boot cpu hw idx %lu\n", reg); 1876 prom_printf("boot cpu hw idx %lu\n", cpu_no);
1845#endif /* CONFIG_SMP */ 1877#endif /* CONFIG_SMP */
1846 } 1878 }
1847 1879
@@ -1895,6 +1927,7 @@ static void __init prom_find_mmu(void)
1895 prom.memory = call_prom("open", 1, 1, ADDR("/memory")); 1927 prom.memory = call_prom("open", 1, 1, ADDR("/memory"));
1896 prom_getprop(prom.chosen, "mmu", &prom.mmumap, 1928 prom_getprop(prom.chosen, "mmu", &prom.mmumap,
1897 sizeof(prom.mmumap)); 1929 sizeof(prom.mmumap));
1930 prom.mmumap = be32_to_cpu(prom.mmumap);
1898 if (!IHANDLE_VALID(prom.memory) || !IHANDLE_VALID(prom.mmumap)) 1931 if (!IHANDLE_VALID(prom.memory) || !IHANDLE_VALID(prom.mmumap))
1899 of_workarounds &= ~OF_WA_CLAIM; /* hmmm */ 1932 of_workarounds &= ~OF_WA_CLAIM; /* hmmm */
1900} 1933}
@@ -1906,17 +1939,19 @@ static void __init prom_init_stdout(void)
1906{ 1939{
1907 char *path = of_stdout_device; 1940 char *path = of_stdout_device;
1908 char type[16]; 1941 char type[16];
1909 u32 val; 1942 phandle stdout_node;
1943 __be32 val;
1910 1944
1911 if (prom_getprop(prom.chosen, "stdout", &val, sizeof(val)) <= 0) 1945 if (prom_getprop(prom.chosen, "stdout", &val, sizeof(val)) <= 0)
1912 prom_panic("cannot find stdout"); 1946 prom_panic("cannot find stdout");
1913 1947
1914 prom.stdout = val; 1948 prom.stdout = be32_to_cpu(val);
1915 1949
1916 /* Get the full OF pathname of the stdout device */ 1950 /* Get the full OF pathname of the stdout device */
1917 memset(path, 0, 256); 1951 memset(path, 0, 256);
1918 call_prom("instance-to-path", 3, 1, prom.stdout, path, 255); 1952 call_prom("instance-to-path", 3, 1, prom.stdout, path, 255);
1919 val = call_prom("instance-to-package", 1, 1, prom.stdout); 1953 stdout_node = call_prom("instance-to-package", 1, 1, prom.stdout);
1954 val = cpu_to_be32(stdout_node);
1920 prom_setprop(prom.chosen, "/chosen", "linux,stdout-package", 1955 prom_setprop(prom.chosen, "/chosen", "linux,stdout-package",
1921 &val, sizeof(val)); 1956 &val, sizeof(val));
1922 prom_printf("OF stdout device is: %s\n", of_stdout_device); 1957 prom_printf("OF stdout device is: %s\n", of_stdout_device);
@@ -1925,9 +1960,9 @@ static void __init prom_init_stdout(void)
1925 1960
1926 /* If it's a display, note it */ 1961 /* If it's a display, note it */
1927 memset(type, 0, sizeof(type)); 1962 memset(type, 0, sizeof(type));
1928 prom_getprop(val, "device_type", type, sizeof(type)); 1963 prom_getprop(stdout_node, "device_type", type, sizeof(type));
1929 if (strcmp(type, "display") == 0) 1964 if (strcmp(type, "display") == 0)
1930 prom_setprop(val, path, "linux,boot-display", NULL, 0); 1965 prom_setprop(stdout_node, path, "linux,boot-display", NULL, 0);
1931} 1966}
1932 1967
1933static int __init prom_find_machine_type(void) 1968static int __init prom_find_machine_type(void)
@@ -2082,6 +2117,22 @@ static void __init prom_check_displays(void)
2082 clut[2]) != 0) 2117 clut[2]) != 0)
2083 break; 2118 break;
2084#endif /* CONFIG_LOGO_LINUX_CLUT224 */ 2119#endif /* CONFIG_LOGO_LINUX_CLUT224 */
2120
2121#ifdef CONFIG_PPC_EARLY_DEBUG_BOOTX
2122 if (prom_getprop(node, "linux,boot-display", NULL, 0) !=
2123 PROM_ERROR) {
2124 u32 width, height, pitch, addr;
2125
2126 prom_printf("Setting btext !\n");
2127 prom_getprop(node, "width", &width, 4);
2128 prom_getprop(node, "height", &height, 4);
2129 prom_getprop(node, "linebytes", &pitch, 4);
2130 prom_getprop(node, "address", &addr, 4);
2131 prom_printf("W=%d H=%d LB=%d addr=0x%x\n",
2132 width, height, pitch, addr);
2133 btext_setup_display(width, height, 8, pitch, addr);
2134 }
2135#endif /* CONFIG_PPC_EARLY_DEBUG_BOOTX */
2085 } 2136 }
2086} 2137}
2087 2138
@@ -2117,8 +2168,10 @@ static void __init *make_room(unsigned long *mem_start, unsigned long *mem_end,
2117 return ret; 2168 return ret;
2118} 2169}
2119 2170
2120#define dt_push_token(token, mem_start, mem_end) \ 2171#define dt_push_token(token, mem_start, mem_end) do { \
2121 do { *((u32 *)make_room(mem_start, mem_end, 4, 4)) = token; } while(0) 2172 void *room = make_room(mem_start, mem_end, 4, 4); \
2173 *(__be32 *)room = cpu_to_be32(token); \
2174 } while(0)
2122 2175
2123static unsigned long __init dt_find_string(char *str) 2176static unsigned long __init dt_find_string(char *str)
2124{ 2177{
@@ -2291,7 +2344,7 @@ static void __init scan_dt_build_struct(phandle node, unsigned long *mem_start,
2291 dt_push_token(4, mem_start, mem_end); 2344 dt_push_token(4, mem_start, mem_end);
2292 dt_push_token(soff, mem_start, mem_end); 2345 dt_push_token(soff, mem_start, mem_end);
2293 valp = make_room(mem_start, mem_end, 4, 4); 2346 valp = make_room(mem_start, mem_end, 4, 4);
2294 *(u32 *)valp = node; 2347 *(__be32 *)valp = cpu_to_be32(node);
2295 } 2348 }
2296 } 2349 }
2297 2350
@@ -2364,16 +2417,16 @@ static void __init flatten_device_tree(void)
2364 dt_struct_end = PAGE_ALIGN(mem_start); 2417 dt_struct_end = PAGE_ALIGN(mem_start);
2365 2418
2366 /* Finish header */ 2419 /* Finish header */
2367 hdr->boot_cpuid_phys = prom.cpu; 2420 hdr->boot_cpuid_phys = cpu_to_be32(prom.cpu);
2368 hdr->magic = OF_DT_HEADER; 2421 hdr->magic = cpu_to_be32(OF_DT_HEADER);
2369 hdr->totalsize = dt_struct_end - dt_header_start; 2422 hdr->totalsize = cpu_to_be32(dt_struct_end - dt_header_start);
2370 hdr->off_dt_struct = dt_struct_start - dt_header_start; 2423 hdr->off_dt_struct = cpu_to_be32(dt_struct_start - dt_header_start);
2371 hdr->off_dt_strings = dt_string_start - dt_header_start; 2424 hdr->off_dt_strings = cpu_to_be32(dt_string_start - dt_header_start);
2372 hdr->dt_strings_size = dt_string_end - dt_string_start; 2425 hdr->dt_strings_size = cpu_to_be32(dt_string_end - dt_string_start);
2373 hdr->off_mem_rsvmap = ((unsigned long)rsvmap) - dt_header_start; 2426 hdr->off_mem_rsvmap = cpu_to_be32(((unsigned long)rsvmap) - dt_header_start);
2374 hdr->version = OF_DT_VERSION; 2427 hdr->version = cpu_to_be32(OF_DT_VERSION);
2375 /* Version 16 is not backward compatible */ 2428 /* Version 16 is not backward compatible */
2376 hdr->last_comp_version = 0x10; 2429 hdr->last_comp_version = cpu_to_be32(0x10);
2377 2430
2378 /* Copy the reserve map in */ 2431 /* Copy the reserve map in */
2379 memcpy(rsvmap, mem_reserve_map, sizeof(mem_reserve_map)); 2432 memcpy(rsvmap, mem_reserve_map, sizeof(mem_reserve_map));
@@ -2384,8 +2437,8 @@ static void __init flatten_device_tree(void)
2384 prom_printf("reserved memory map:\n"); 2437 prom_printf("reserved memory map:\n");
2385 for (i = 0; i < mem_reserve_cnt; i++) 2438 for (i = 0; i < mem_reserve_cnt; i++)
2386 prom_printf(" %x - %x\n", 2439 prom_printf(" %x - %x\n",
2387 mem_reserve_map[i].base, 2440 be64_to_cpu(mem_reserve_map[i].base),
2388 mem_reserve_map[i].size); 2441 be64_to_cpu(mem_reserve_map[i].size));
2389 } 2442 }
2390#endif 2443#endif
2391 /* Bump mem_reserve_cnt to cause further reservations to fail 2444 /* Bump mem_reserve_cnt to cause further reservations to fail
@@ -2397,7 +2450,6 @@ static void __init flatten_device_tree(void)
2397 dt_string_start, dt_string_end); 2450 dt_string_start, dt_string_end);
2398 prom_printf("Device tree struct 0x%x -> 0x%x\n", 2451 prom_printf("Device tree struct 0x%x -> 0x%x\n",
2399 dt_struct_start, dt_struct_end); 2452 dt_struct_start, dt_struct_end);
2400
2401} 2453}
2402 2454
2403#ifdef CONFIG_PPC_MAPLE 2455#ifdef CONFIG_PPC_MAPLE
@@ -2730,18 +2782,19 @@ static void __init fixup_device_tree(void)
2730 2782
2731static void __init prom_find_boot_cpu(void) 2783static void __init prom_find_boot_cpu(void)
2732{ 2784{
2733 u32 getprop_rval; 2785 __be32 rval;
2734 ihandle prom_cpu; 2786 ihandle prom_cpu;
2735 phandle cpu_pkg; 2787 phandle cpu_pkg;
2736 2788
2737 prom.cpu = 0; 2789 rval = 0;
2738 if (prom_getprop(prom.chosen, "cpu", &prom_cpu, sizeof(prom_cpu)) <= 0) 2790 if (prom_getprop(prom.chosen, "cpu", &rval, sizeof(rval)) <= 0)
2739 return; 2791 return;
2792 prom_cpu = be32_to_cpu(rval);
2740 2793
2741 cpu_pkg = call_prom("instance-to-package", 1, 1, prom_cpu); 2794 cpu_pkg = call_prom("instance-to-package", 1, 1, prom_cpu);
2742 2795
2743 prom_getprop(cpu_pkg, "reg", &getprop_rval, sizeof(getprop_rval)); 2796 prom_getprop(cpu_pkg, "reg", &rval, sizeof(rval));
2744 prom.cpu = getprop_rval; 2797 prom.cpu = be32_to_cpu(rval);
2745 2798
2746 prom_debug("Booting CPU hw index = %lu\n", prom.cpu); 2799 prom_debug("Booting CPU hw index = %lu\n", prom.cpu);
2747} 2800}
@@ -2750,15 +2803,15 @@ static void __init prom_check_initrd(unsigned long r3, unsigned long r4)
2750{ 2803{
2751#ifdef CONFIG_BLK_DEV_INITRD 2804#ifdef CONFIG_BLK_DEV_INITRD
2752 if (r3 && r4 && r4 != 0xdeadbeef) { 2805 if (r3 && r4 && r4 != 0xdeadbeef) {
2753 unsigned long val; 2806 __be64 val;
2754 2807
2755 prom_initrd_start = is_kernel_addr(r3) ? __pa(r3) : r3; 2808 prom_initrd_start = is_kernel_addr(r3) ? __pa(r3) : r3;
2756 prom_initrd_end = prom_initrd_start + r4; 2809 prom_initrd_end = prom_initrd_start + r4;
2757 2810
2758 val = prom_initrd_start; 2811 val = cpu_to_be64(prom_initrd_start);
2759 prom_setprop(prom.chosen, "/chosen", "linux,initrd-start", 2812 prom_setprop(prom.chosen, "/chosen", "linux,initrd-start",
2760 &val, sizeof(val)); 2813 &val, sizeof(val));
2761 val = prom_initrd_end; 2814 val = cpu_to_be64(prom_initrd_end);
2762 prom_setprop(prom.chosen, "/chosen", "linux,initrd-end", 2815 prom_setprop(prom.chosen, "/chosen", "linux,initrd-end",
2763 &val, sizeof(val)); 2816 &val, sizeof(val));
2764 2817
@@ -2915,7 +2968,7 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
2915 */ 2968 */
2916 prom_check_displays(); 2969 prom_check_displays();
2917 2970
2918#ifdef CONFIG_PPC64 2971#if defined(CONFIG_PPC64) && defined(__BIG_ENDIAN__)
2919 /* 2972 /*
2920 * Initialize IOMMU (TCE tables) on pSeries. Do that before anything else 2973 * Initialize IOMMU (TCE tables) on pSeries. Do that before anything else
2921 * that uses the allocator, we need to make sure we get the top of memory 2974 * that uses the allocator, we need to make sure we get the top of memory
@@ -2934,6 +2987,7 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
2934 prom_instantiate_rtas(); 2987 prom_instantiate_rtas();
2935 2988
2936#ifdef CONFIG_PPC_POWERNV 2989#ifdef CONFIG_PPC_POWERNV
2990#ifdef __BIG_ENDIAN__
2937 /* Detect HAL and try instanciating it & doing takeover */ 2991 /* Detect HAL and try instanciating it & doing takeover */
2938 if (of_platform == PLATFORM_PSERIES_LPAR) { 2992 if (of_platform == PLATFORM_PSERIES_LPAR) {
2939 prom_query_opal(); 2993 prom_query_opal();
@@ -2941,9 +2995,11 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
2941 prom_opal_hold_cpus(); 2995 prom_opal_hold_cpus();
2942 prom_opal_takeover(); 2996 prom_opal_takeover();
2943 } 2997 }
2944 } else if (of_platform == PLATFORM_OPAL) 2998 } else
2999#endif /* __BIG_ENDIAN__ */
3000 if (of_platform == PLATFORM_OPAL)
2945 prom_instantiate_opal(); 3001 prom_instantiate_opal();
2946#endif 3002#endif /* CONFIG_PPC_POWERNV */
2947 3003
2948#ifdef CONFIG_PPC64 3004#ifdef CONFIG_PPC64
2949 /* instantiate sml */ 3005 /* instantiate sml */
@@ -2962,10 +3018,11 @@ unsigned long __init prom_init(unsigned long r3, unsigned long r4,
2962 /* 3018 /*
2963 * Fill in some infos for use by the kernel later on 3019 * Fill in some infos for use by the kernel later on
2964 */ 3020 */
2965 if (prom_memory_limit) 3021 if (prom_memory_limit) {
3022 __be64 val = cpu_to_be64(prom_memory_limit);
2966 prom_setprop(prom.chosen, "/chosen", "linux,memory-limit", 3023 prom_setprop(prom.chosen, "/chosen", "linux,memory-limit",
2967 &prom_memory_limit, 3024 &val, sizeof(val));
2968 sizeof(prom_memory_limit)); 3025 }
2969#ifdef CONFIG_PPC64 3026#ifdef CONFIG_PPC64
2970 if (prom_iommu_off) 3027 if (prom_iommu_off)
2971 prom_setprop(prom.chosen, "/chosen", "linux,iommu-off", 3028 prom_setprop(prom.chosen, "/chosen", "linux,iommu-off",
diff --git a/arch/powerpc/kernel/prom_init_check.sh b/arch/powerpc/kernel/prom_init_check.sh
index 3765da6be4f2..b0c263da219a 100644
--- a/arch/powerpc/kernel/prom_init_check.sh
+++ b/arch/powerpc/kernel/prom_init_check.sh
@@ -22,7 +22,8 @@ __secondary_hold_acknowledge __secondary_hold_spinloop __start
22strcmp strcpy strlcpy strlen strncmp strstr logo_linux_clut224 22strcmp strcpy strlcpy strlen strncmp strstr logo_linux_clut224
23reloc_got2 kernstart_addr memstart_addr linux_banner _stext 23reloc_got2 kernstart_addr memstart_addr linux_banner _stext
24opal_query_takeover opal_do_takeover opal_enter_rtas opal_secondary_entry 24opal_query_takeover opal_do_takeover opal_enter_rtas opal_secondary_entry
25boot_command_line __prom_init_toc_start __prom_init_toc_end" 25boot_command_line __prom_init_toc_start __prom_init_toc_end
26btext_setup_display"
26 27
27NM="$1" 28NM="$1"
28OBJ="$2" 29OBJ="$2"
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c
index 4e1331b8eb33..6295e646f78c 100644
--- a/arch/powerpc/kernel/prom_parse.c
+++ b/arch/powerpc/kernel/prom_parse.c
@@ -7,28 +7,27 @@
7#include <linux/of_address.h> 7#include <linux/of_address.h>
8#include <asm/prom.h> 8#include <asm/prom.h>
9 9
10void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop, 10void of_parse_dma_window(struct device_node *dn, const __be32 *dma_window,
11 unsigned long *busno, unsigned long *phys, unsigned long *size) 11 unsigned long *busno, unsigned long *phys,
12 unsigned long *size)
12{ 13{
13 const u32 *dma_window;
14 u32 cells; 14 u32 cells;
15 const unsigned char *prop; 15 const __be32 *prop;
16
17 dma_window = dma_window_prop;
18 16
19 /* busno is always one cell */ 17 /* busno is always one cell */
20 *busno = *(dma_window++); 18 *busno = of_read_number(dma_window, 1);
19 dma_window++;
21 20
22 prop = of_get_property(dn, "ibm,#dma-address-cells", NULL); 21 prop = of_get_property(dn, "ibm,#dma-address-cells", NULL);
23 if (!prop) 22 if (!prop)
24 prop = of_get_property(dn, "#address-cells", NULL); 23 prop = of_get_property(dn, "#address-cells", NULL);
25 24
26 cells = prop ? *(u32 *)prop : of_n_addr_cells(dn); 25 cells = prop ? of_read_number(prop, 1) : of_n_addr_cells(dn);
27 *phys = of_read_number(dma_window, cells); 26 *phys = of_read_number(dma_window, cells);
28 27
29 dma_window += cells; 28 dma_window += cells;
30 29
31 prop = of_get_property(dn, "ibm,#dma-size-cells", NULL); 30 prop = of_get_property(dn, "ibm,#dma-size-cells", NULL);
32 cells = prop ? *(u32 *)prop : of_n_size_cells(dn); 31 cells = prop ? of_read_number(prop, 1) : of_n_size_cells(dn);
33 *size = of_read_number(dma_window, cells); 32 *size = of_read_number(dma_window, cells);
34} 33}
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 80b5ef403f68..4cf674d7d5ae 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -91,7 +91,7 @@ static void unlock_rtas(unsigned long flags)
91 * are designed only for very early low-level debugging, which 91 * are designed only for very early low-level debugging, which
92 * is why the token is hard-coded to 10. 92 * is why the token is hard-coded to 10.
93 */ 93 */
94static void call_rtas_display_status(char c) 94static void call_rtas_display_status(unsigned char c)
95{ 95{
96 struct rtas_args *args = &rtas.args; 96 struct rtas_args *args = &rtas.args;
97 unsigned long s; 97 unsigned long s;
@@ -100,11 +100,11 @@ static void call_rtas_display_status(char c)
100 return; 100 return;
101 s = lock_rtas(); 101 s = lock_rtas();
102 102
103 args->token = 10; 103 args->token = cpu_to_be32(10);
104 args->nargs = 1; 104 args->nargs = cpu_to_be32(1);
105 args->nret = 1; 105 args->nret = cpu_to_be32(1);
106 args->rets = (rtas_arg_t *)&(args->args[1]); 106 args->rets = &(args->args[1]);
107 args->args[0] = (unsigned char)c; 107 args->args[0] = cpu_to_be32(c);
108 108
109 enter_rtas(__pa(args)); 109 enter_rtas(__pa(args));
110 110
@@ -204,7 +204,7 @@ void rtas_progress(char *s, unsigned short hex)
204{ 204{
205 struct device_node *root; 205 struct device_node *root;
206 int width; 206 int width;
207 const int *p; 207 const __be32 *p;
208 char *os; 208 char *os;
209 static int display_character, set_indicator; 209 static int display_character, set_indicator;
210 static int display_width, display_lines, form_feed; 210 static int display_width, display_lines, form_feed;
@@ -221,13 +221,13 @@ void rtas_progress(char *s, unsigned short hex)
221 if ((root = of_find_node_by_path("/rtas"))) { 221 if ((root = of_find_node_by_path("/rtas"))) {
222 if ((p = of_get_property(root, 222 if ((p = of_get_property(root,
223 "ibm,display-line-length", NULL))) 223 "ibm,display-line-length", NULL)))
224 display_width = *p; 224 display_width = be32_to_cpu(*p);
225 if ((p = of_get_property(root, 225 if ((p = of_get_property(root,
226 "ibm,form-feed", NULL))) 226 "ibm,form-feed", NULL)))
227 form_feed = *p; 227 form_feed = be32_to_cpu(*p);
228 if ((p = of_get_property(root, 228 if ((p = of_get_property(root,
229 "ibm,display-number-of-lines", NULL))) 229 "ibm,display-number-of-lines", NULL)))
230 display_lines = *p; 230 display_lines = be32_to_cpu(*p);
231 row_width = of_get_property(root, 231 row_width = of_get_property(root,
232 "ibm,display-truncation-length", NULL); 232 "ibm,display-truncation-length", NULL);
233 of_node_put(root); 233 of_node_put(root);
@@ -322,11 +322,11 @@ EXPORT_SYMBOL(rtas_progress); /* needed by rtas_flash module */
322 322
323int rtas_token(const char *service) 323int rtas_token(const char *service)
324{ 324{
325 const int *tokp; 325 const __be32 *tokp;
326 if (rtas.dev == NULL) 326 if (rtas.dev == NULL)
327 return RTAS_UNKNOWN_SERVICE; 327 return RTAS_UNKNOWN_SERVICE;
328 tokp = of_get_property(rtas.dev, service, NULL); 328 tokp = of_get_property(rtas.dev, service, NULL);
329 return tokp ? *tokp : RTAS_UNKNOWN_SERVICE; 329 return tokp ? be32_to_cpu(*tokp) : RTAS_UNKNOWN_SERVICE;
330} 330}
331EXPORT_SYMBOL(rtas_token); 331EXPORT_SYMBOL(rtas_token);
332 332
@@ -380,11 +380,11 @@ static char *__fetch_rtas_last_error(char *altbuf)
380 380
381 bufsz = rtas_get_error_log_max(); 381 bufsz = rtas_get_error_log_max();
382 382
383 err_args.token = rtas_last_error_token; 383 err_args.token = cpu_to_be32(rtas_last_error_token);
384 err_args.nargs = 2; 384 err_args.nargs = cpu_to_be32(2);
385 err_args.nret = 1; 385 err_args.nret = cpu_to_be32(1);
386 err_args.args[0] = (rtas_arg_t)__pa(rtas_err_buf); 386 err_args.args[0] = cpu_to_be32(__pa(rtas_err_buf));
387 err_args.args[1] = bufsz; 387 err_args.args[1] = cpu_to_be32(bufsz);
388 err_args.args[2] = 0; 388 err_args.args[2] = 0;
389 389
390 save_args = rtas.args; 390 save_args = rtas.args;
@@ -433,13 +433,13 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
433 s = lock_rtas(); 433 s = lock_rtas();
434 rtas_args = &rtas.args; 434 rtas_args = &rtas.args;
435 435
436 rtas_args->token = token; 436 rtas_args->token = cpu_to_be32(token);
437 rtas_args->nargs = nargs; 437 rtas_args->nargs = cpu_to_be32(nargs);
438 rtas_args->nret = nret; 438 rtas_args->nret = cpu_to_be32(nret);
439 rtas_args->rets = (rtas_arg_t *)&(rtas_args->args[nargs]); 439 rtas_args->rets = &(rtas_args->args[nargs]);
440 va_start(list, outputs); 440 va_start(list, outputs);
441 for (i = 0; i < nargs; ++i) 441 for (i = 0; i < nargs; ++i)
442 rtas_args->args[i] = va_arg(list, rtas_arg_t); 442 rtas_args->args[i] = cpu_to_be32(va_arg(list, __u32));
443 va_end(list); 443 va_end(list);
444 444
445 for (i = 0; i < nret; ++i) 445 for (i = 0; i < nret; ++i)
@@ -449,13 +449,13 @@ int rtas_call(int token, int nargs, int nret, int *outputs, ...)
449 449
450 /* A -1 return code indicates that the last command couldn't 450 /* A -1 return code indicates that the last command couldn't
451 be completed due to a hardware error. */ 451 be completed due to a hardware error. */
452 if (rtas_args->rets[0] == -1) 452 if (be32_to_cpu(rtas_args->rets[0]) == -1)
453 buff_copy = __fetch_rtas_last_error(NULL); 453 buff_copy = __fetch_rtas_last_error(NULL);
454 454
455 if (nret > 1 && outputs != NULL) 455 if (nret > 1 && outputs != NULL)
456 for (i = 0; i < nret-1; ++i) 456 for (i = 0; i < nret-1; ++i)
457 outputs[i] = rtas_args->rets[i+1]; 457 outputs[i] = be32_to_cpu(rtas_args->rets[i+1]);
458 ret = (nret > 0)? rtas_args->rets[0]: 0; 458 ret = (nret > 0)? be32_to_cpu(rtas_args->rets[0]): 0;
459 459
460 unlock_rtas(s); 460 unlock_rtas(s);
461 461
@@ -588,8 +588,8 @@ bool rtas_indicator_present(int token, int *maxindex)
588{ 588{
589 int proplen, count, i; 589 int proplen, count, i;
590 const struct indicator_elem { 590 const struct indicator_elem {
591 u32 token; 591 __be32 token;
592 u32 maxindex; 592 __be32 maxindex;
593 } *indicators; 593 } *indicators;
594 594
595 indicators = of_get_property(rtas.dev, "rtas-indicators", &proplen); 595 indicators = of_get_property(rtas.dev, "rtas-indicators", &proplen);
@@ -599,10 +599,10 @@ bool rtas_indicator_present(int token, int *maxindex)
599 count = proplen / sizeof(struct indicator_elem); 599 count = proplen / sizeof(struct indicator_elem);
600 600
601 for (i = 0; i < count; i++) { 601 for (i = 0; i < count; i++) {
602 if (indicators[i].token != token) 602 if (__be32_to_cpu(indicators[i].token) != token)
603 continue; 603 continue;
604 if (maxindex) 604 if (maxindex)
605 *maxindex = indicators[i].maxindex; 605 *maxindex = __be32_to_cpu(indicators[i].maxindex);
606 return true; 606 return true;
607 } 607 }
608 608
@@ -1097,19 +1097,19 @@ void __init rtas_initialize(void)
1097 */ 1097 */
1098 rtas.dev = of_find_node_by_name(NULL, "rtas"); 1098 rtas.dev = of_find_node_by_name(NULL, "rtas");
1099 if (rtas.dev) { 1099 if (rtas.dev) {
1100 const u32 *basep, *entryp, *sizep; 1100 const __be32 *basep, *entryp, *sizep;
1101 1101
1102 basep = of_get_property(rtas.dev, "linux,rtas-base", NULL); 1102 basep = of_get_property(rtas.dev, "linux,rtas-base", NULL);
1103 sizep = of_get_property(rtas.dev, "rtas-size", NULL); 1103 sizep = of_get_property(rtas.dev, "rtas-size", NULL);
1104 if (basep != NULL && sizep != NULL) { 1104 if (basep != NULL && sizep != NULL) {
1105 rtas.base = *basep; 1105 rtas.base = __be32_to_cpu(*basep);
1106 rtas.size = *sizep; 1106 rtas.size = __be32_to_cpu(*sizep);
1107 entryp = of_get_property(rtas.dev, 1107 entryp = of_get_property(rtas.dev,
1108 "linux,rtas-entry", NULL); 1108 "linux,rtas-entry", NULL);
1109 if (entryp == NULL) /* Ugh */ 1109 if (entryp == NULL) /* Ugh */
1110 rtas.entry = rtas.base; 1110 rtas.entry = rtas.base;
1111 else 1111 else
1112 rtas.entry = *entryp; 1112 rtas.entry = __be32_to_cpu(*entryp);
1113 } else 1113 } else
1114 rtas.dev = NULL; 1114 rtas.dev = NULL;
1115 } 1115 }
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 63d051f5b7a5..3d261c071fc8 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -436,7 +436,8 @@ void __init smp_setup_cpu_maps(void)
436 DBG("smp_setup_cpu_maps()\n"); 436 DBG("smp_setup_cpu_maps()\n");
437 437
438 while ((dn = of_find_node_by_type(dn, "cpu")) && cpu < nr_cpu_ids) { 438 while ((dn = of_find_node_by_type(dn, "cpu")) && cpu < nr_cpu_ids) {
439 const int *intserv; 439 const __be32 *intserv;
440 __be32 cpu_be;
440 int j, len; 441 int j, len;
441 442
442 DBG(" * %s...\n", dn->full_name); 443 DBG(" * %s...\n", dn->full_name);
@@ -450,15 +451,17 @@ void __init smp_setup_cpu_maps(void)
450 } else { 451 } else {
451 DBG(" no ibm,ppc-interrupt-server#s -> 1 thread\n"); 452 DBG(" no ibm,ppc-interrupt-server#s -> 1 thread\n");
452 intserv = of_get_property(dn, "reg", NULL); 453 intserv = of_get_property(dn, "reg", NULL);
453 if (!intserv) 454 if (!intserv) {
454 intserv = &cpu; /* assume logical == phys */ 455 cpu_be = cpu_to_be32(cpu);
456 intserv = &cpu_be; /* assume logical == phys */
457 }
455 } 458 }
456 459
457 for (j = 0; j < nthreads && cpu < nr_cpu_ids; j++) { 460 for (j = 0; j < nthreads && cpu < nr_cpu_ids; j++) {
458 DBG(" thread %d -> cpu %d (hard id %d)\n", 461 DBG(" thread %d -> cpu %d (hard id %d)\n",
459 j, cpu, intserv[j]); 462 j, cpu, be32_to_cpu(intserv[j]));
460 set_cpu_present(cpu, true); 463 set_cpu_present(cpu, true);
461 set_hard_smp_processor_id(cpu, intserv[j]); 464 set_hard_smp_processor_id(cpu, be32_to_cpu(intserv[j]));
462 set_cpu_possible(cpu, true); 465 set_cpu_possible(cpu, true);
463 cpu++; 466 cpu++;
464 } 467 }
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index a8f54ecb091f..a4bbcae72578 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -38,6 +38,7 @@
38#include <asm/serial.h> 38#include <asm/serial.h>
39#include <asm/udbg.h> 39#include <asm/udbg.h>
40#include <asm/mmu_context.h> 40#include <asm/mmu_context.h>
41#include <asm/epapr_hcalls.h>
41 42
42#include "setup.h" 43#include "setup.h"
43 44
@@ -128,6 +129,8 @@ notrace void __init machine_init(u64 dt_ptr)
128 /* Do some early initialization based on the flat device tree */ 129 /* Do some early initialization based on the flat device tree */
129 early_init_devtree(__va(dt_ptr)); 130 early_init_devtree(__va(dt_ptr));
130 131
132 epapr_paravirt_early_init();
133
131 early_init_mmu(); 134 early_init_mmu();
132 135
133 probe_machine(); 136 probe_machine();
@@ -326,5 +329,4 @@ void __init setup_arch(char **cmdline_p)
326 329
327 /* Initialize the MMU context management stuff */ 330 /* Initialize the MMU context management stuff */
328 mmu_context_init(); 331 mmu_context_init();
329
330} 332}
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index fe6a58c9f0b7..278ca93e1f28 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -10,7 +10,7 @@
10 * 2 of the License, or (at your option) any later version. 10 * 2 of the License, or (at your option) any later version.
11 */ 11 */
12 12
13#undef DEBUG 13#define DEBUG
14 14
15#include <linux/export.h> 15#include <linux/export.h>
16#include <linux/string.h> 16#include <linux/string.h>
@@ -66,6 +66,7 @@
66#include <asm/code-patching.h> 66#include <asm/code-patching.h>
67#include <asm/kvm_ppc.h> 67#include <asm/kvm_ppc.h>
68#include <asm/hugetlb.h> 68#include <asm/hugetlb.h>
69#include <asm/epapr_hcalls.h>
69 70
70#include "setup.h" 71#include "setup.h"
71 72
@@ -215,6 +216,8 @@ void __init early_setup(unsigned long dt_ptr)
215 */ 216 */
216 early_init_devtree(__va(dt_ptr)); 217 early_init_devtree(__va(dt_ptr));
217 218
219 epapr_paravirt_early_init();
220
218 /* Now we know the logical id of our boot cpu, setup the paca. */ 221 /* Now we know the logical id of our boot cpu, setup the paca. */
219 setup_paca(&paca[boot_cpuid]); 222 setup_paca(&paca[boot_cpuid]);
220 fixup_boot_paca(); 223 fixup_boot_paca();
@@ -239,6 +242,18 @@ void __init early_setup(unsigned long dt_ptr)
239 reserve_hugetlb_gpages(); 242 reserve_hugetlb_gpages();
240 243
241 DBG(" <- early_setup()\n"); 244 DBG(" <- early_setup()\n");
245
246#ifdef CONFIG_PPC_EARLY_DEBUG_BOOTX
247 /*
248 * This needs to be done *last* (after the above DBG() even)
249 *
250 * Right after we return from this function, we turn on the MMU
251 * which means the real-mode access trick that btext does will
252 * no longer work, it needs to switch to using a real MMU
253 * mapping. This call will ensure that it does
254 */
255 btext_map();
256#endif /* CONFIG_PPC_EARLY_DEBUG_BOOTX */
242} 257}
243 258
244#ifdef CONFIG_SMP 259#ifdef CONFIG_SMP
@@ -307,14 +322,14 @@ static void __init initialize_cache_info(void)
307 * d-cache and i-cache sizes... -Peter 322 * d-cache and i-cache sizes... -Peter
308 */ 323 */
309 if (num_cpus == 1) { 324 if (num_cpus == 1) {
310 const u32 *sizep, *lsizep; 325 const __be32 *sizep, *lsizep;
311 u32 size, lsize; 326 u32 size, lsize;
312 327
313 size = 0; 328 size = 0;
314 lsize = cur_cpu_spec->dcache_bsize; 329 lsize = cur_cpu_spec->dcache_bsize;
315 sizep = of_get_property(np, "d-cache-size", NULL); 330 sizep = of_get_property(np, "d-cache-size", NULL);
316 if (sizep != NULL) 331 if (sizep != NULL)
317 size = *sizep; 332 size = be32_to_cpu(*sizep);
318 lsizep = of_get_property(np, "d-cache-block-size", 333 lsizep = of_get_property(np, "d-cache-block-size",
319 NULL); 334 NULL);
320 /* fallback if block size missing */ 335 /* fallback if block size missing */
@@ -323,8 +338,8 @@ static void __init initialize_cache_info(void)
323 "d-cache-line-size", 338 "d-cache-line-size",
324 NULL); 339 NULL);
325 if (lsizep != NULL) 340 if (lsizep != NULL)
326 lsize = *lsizep; 341 lsize = be32_to_cpu(*lsizep);
327 if (sizep == 0 || lsizep == 0) 342 if (sizep == NULL || lsizep == NULL)
328 DBG("Argh, can't find dcache properties ! " 343 DBG("Argh, can't find dcache properties ! "
329 "sizep: %p, lsizep: %p\n", sizep, lsizep); 344 "sizep: %p, lsizep: %p\n", sizep, lsizep);
330 345
@@ -337,7 +352,7 @@ static void __init initialize_cache_info(void)
337 lsize = cur_cpu_spec->icache_bsize; 352 lsize = cur_cpu_spec->icache_bsize;
338 sizep = of_get_property(np, "i-cache-size", NULL); 353 sizep = of_get_property(np, "i-cache-size", NULL);
339 if (sizep != NULL) 354 if (sizep != NULL)
340 size = *sizep; 355 size = be32_to_cpu(*sizep);
341 lsizep = of_get_property(np, "i-cache-block-size", 356 lsizep = of_get_property(np, "i-cache-block-size",
342 NULL); 357 NULL);
343 if (lsizep == NULL) 358 if (lsizep == NULL)
@@ -345,8 +360,8 @@ static void __init initialize_cache_info(void)
345 "i-cache-line-size", 360 "i-cache-line-size",
346 NULL); 361 NULL);
347 if (lsizep != NULL) 362 if (lsizep != NULL)
348 lsize = *lsizep; 363 lsize = be32_to_cpu(*lsizep);
349 if (sizep == 0 || lsizep == 0) 364 if (sizep == NULL || lsizep == NULL)
350 DBG("Argh, can't find icache properties ! " 365 DBG("Argh, can't find icache properties ! "
351 "sizep: %p, lsizep: %p\n", sizep, lsizep); 366 "sizep: %p, lsizep: %p\n", sizep, lsizep);
352 367
@@ -701,8 +716,7 @@ void __init setup_per_cpu_areas(void)
701#endif 716#endif
702 717
703 718
704#ifdef CONFIG_PPC_INDIRECT_IO 719#if defined(CONFIG_PPC_INDIRECT_PIO) || defined(CONFIG_PPC_INDIRECT_MMIO)
705struct ppc_pci_io ppc_pci_io; 720struct ppc_pci_io ppc_pci_io;
706EXPORT_SYMBOL(ppc_pci_io); 721EXPORT_SYMBOL(ppc_pci_io);
707#endif /* CONFIG_PPC_INDIRECT_IO */ 722#endif
708
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index 0f83122e6676..bebdf1a1a540 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -436,7 +436,10 @@ static int save_user_regs(struct pt_regs *regs, struct mcontext __user *frame,
436 * use altivec. Since VSCR only contains 32 bits saved in the least 436 * use altivec. Since VSCR only contains 32 bits saved in the least
437 * significant bits of a vector, we "cheat" and stuff VRSAVE in the 437 * significant bits of a vector, we "cheat" and stuff VRSAVE in the
438 * most significant bits of that same vector. --BenH 438 * most significant bits of that same vector. --BenH
439 * Note that the current VRSAVE value is in the SPR at this point.
439 */ 440 */
441 if (cpu_has_feature(CPU_FTR_ALTIVEC))
442 current->thread.vrsave = mfspr(SPRN_VRSAVE);
440 if (__put_user(current->thread.vrsave, (u32 __user *)&frame->mc_vregs[32])) 443 if (__put_user(current->thread.vrsave, (u32 __user *)&frame->mc_vregs[32]))
441 return 1; 444 return 1;
442#endif /* CONFIG_ALTIVEC */ 445#endif /* CONFIG_ALTIVEC */
@@ -557,6 +560,8 @@ static int save_tm_user_regs(struct pt_regs *regs,
557 * significant bits of a vector, we "cheat" and stuff VRSAVE in the 560 * significant bits of a vector, we "cheat" and stuff VRSAVE in the
558 * most significant bits of that same vector. --BenH 561 * most significant bits of that same vector. --BenH
559 */ 562 */
563 if (cpu_has_feature(CPU_FTR_ALTIVEC))
564 current->thread.vrsave = mfspr(SPRN_VRSAVE);
560 if (__put_user(current->thread.vrsave, 565 if (__put_user(current->thread.vrsave,
561 (u32 __user *)&frame->mc_vregs[32])) 566 (u32 __user *)&frame->mc_vregs[32]))
562 return 1; 567 return 1;
@@ -696,6 +701,8 @@ static long restore_user_regs(struct pt_regs *regs,
696 /* Always get VRSAVE back */ 701 /* Always get VRSAVE back */
697 if (__get_user(current->thread.vrsave, (u32 __user *)&sr->mc_vregs[32])) 702 if (__get_user(current->thread.vrsave, (u32 __user *)&sr->mc_vregs[32]))
698 return 1; 703 return 1;
704 if (cpu_has_feature(CPU_FTR_ALTIVEC))
705 mtspr(SPRN_VRSAVE, current->thread.vrsave);
699#endif /* CONFIG_ALTIVEC */ 706#endif /* CONFIG_ALTIVEC */
700 if (copy_fpr_from_user(current, &sr->mc_fregs)) 707 if (copy_fpr_from_user(current, &sr->mc_fregs))
701 return 1; 708 return 1;
@@ -809,6 +816,8 @@ static long restore_tm_user_regs(struct pt_regs *regs,
809 __get_user(current->thread.transact_vrsave, 816 __get_user(current->thread.transact_vrsave,
810 (u32 __user *)&tm_sr->mc_vregs[32])) 817 (u32 __user *)&tm_sr->mc_vregs[32]))
811 return 1; 818 return 1;
819 if (cpu_has_feature(CPU_FTR_ALTIVEC))
820 mtspr(SPRN_VRSAVE, current->thread.vrsave);
812#endif /* CONFIG_ALTIVEC */ 821#endif /* CONFIG_ALTIVEC */
813 822
814 regs->msr &= ~(MSR_FP | MSR_FE0 | MSR_FE1); 823 regs->msr &= ~(MSR_FP | MSR_FE0 | MSR_FE1);
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index 887e99d85bc2..f93ec2835a13 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -96,8 +96,6 @@ static long setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
96 unsigned long msr = regs->msr; 96 unsigned long msr = regs->msr;
97 long err = 0; 97 long err = 0;
98 98
99 flush_fp_to_thread(current);
100
101#ifdef CONFIG_ALTIVEC 99#ifdef CONFIG_ALTIVEC
102 err |= __put_user(v_regs, &sc->v_regs); 100 err |= __put_user(v_regs, &sc->v_regs);
103 101
@@ -114,6 +112,8 @@ static long setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
114 /* We always copy to/from vrsave, it's 0 if we don't have or don't 112 /* We always copy to/from vrsave, it's 0 if we don't have or don't
115 * use altivec. 113 * use altivec.
116 */ 114 */
115 if (cpu_has_feature(CPU_FTR_ALTIVEC))
116 current->thread.vrsave = mfspr(SPRN_VRSAVE);
117 err |= __put_user(current->thread.vrsave, (u32 __user *)&v_regs[33]); 117 err |= __put_user(current->thread.vrsave, (u32 __user *)&v_regs[33]);
118#else /* CONFIG_ALTIVEC */ 118#else /* CONFIG_ALTIVEC */
119 err |= __put_user(0, &sc->v_regs); 119 err |= __put_user(0, &sc->v_regs);
@@ -217,6 +217,8 @@ static long setup_tm_sigcontexts(struct sigcontext __user *sc,
217 /* We always copy to/from vrsave, it's 0 if we don't have or don't 217 /* We always copy to/from vrsave, it's 0 if we don't have or don't
218 * use altivec. 218 * use altivec.
219 */ 219 */
220 if (cpu_has_feature(CPU_FTR_ALTIVEC))
221 current->thread.vrsave = mfspr(SPRN_VRSAVE);
220 err |= __put_user(current->thread.vrsave, (u32 __user *)&v_regs[33]); 222 err |= __put_user(current->thread.vrsave, (u32 __user *)&v_regs[33]);
221 if (msr & MSR_VEC) 223 if (msr & MSR_VEC)
222 err |= __put_user(current->thread.transact_vrsave, 224 err |= __put_user(current->thread.transact_vrsave,
@@ -346,16 +348,18 @@ static long restore_sigcontext(struct pt_regs *regs, sigset_t *set, int sig,
346 if (v_regs && !access_ok(VERIFY_READ, v_regs, 34 * sizeof(vector128))) 348 if (v_regs && !access_ok(VERIFY_READ, v_regs, 34 * sizeof(vector128)))
347 return -EFAULT; 349 return -EFAULT;
348 /* Copy 33 vec registers (vr0..31 and vscr) from the stack */ 350 /* Copy 33 vec registers (vr0..31 and vscr) from the stack */
349 if (v_regs != 0 && (msr & MSR_VEC) != 0) 351 if (v_regs != NULL && (msr & MSR_VEC) != 0)
350 err |= __copy_from_user(current->thread.vr, v_regs, 352 err |= __copy_from_user(current->thread.vr, v_regs,
351 33 * sizeof(vector128)); 353 33 * sizeof(vector128));
352 else if (current->thread.used_vr) 354 else if (current->thread.used_vr)
353 memset(current->thread.vr, 0, 33 * sizeof(vector128)); 355 memset(current->thread.vr, 0, 33 * sizeof(vector128));
354 /* Always get VRSAVE back */ 356 /* Always get VRSAVE back */
355 if (v_regs != 0) 357 if (v_regs != NULL)
356 err |= __get_user(current->thread.vrsave, (u32 __user *)&v_regs[33]); 358 err |= __get_user(current->thread.vrsave, (u32 __user *)&v_regs[33]);
357 else 359 else
358 current->thread.vrsave = 0; 360 current->thread.vrsave = 0;
361 if (cpu_has_feature(CPU_FTR_ALTIVEC))
362 mtspr(SPRN_VRSAVE, current->thread.vrsave);
359#endif /* CONFIG_ALTIVEC */ 363#endif /* CONFIG_ALTIVEC */
360 /* restore floating point */ 364 /* restore floating point */
361 err |= copy_fpr_from_user(current, &sc->fp_regs); 365 err |= copy_fpr_from_user(current, &sc->fp_regs);
@@ -463,7 +467,7 @@ static long restore_tm_sigcontexts(struct pt_regs *regs,
463 tm_v_regs, 34 * sizeof(vector128))) 467 tm_v_regs, 34 * sizeof(vector128)))
464 return -EFAULT; 468 return -EFAULT;
465 /* Copy 33 vec registers (vr0..31 and vscr) from the stack */ 469 /* Copy 33 vec registers (vr0..31 and vscr) from the stack */
466 if (v_regs != 0 && tm_v_regs != 0 && (msr & MSR_VEC) != 0) { 470 if (v_regs != NULL && tm_v_regs != NULL && (msr & MSR_VEC) != 0) {
467 err |= __copy_from_user(current->thread.vr, v_regs, 471 err |= __copy_from_user(current->thread.vr, v_regs,
468 33 * sizeof(vector128)); 472 33 * sizeof(vector128));
469 err |= __copy_from_user(current->thread.transact_vr, tm_v_regs, 473 err |= __copy_from_user(current->thread.transact_vr, tm_v_regs,
@@ -474,7 +478,7 @@ static long restore_tm_sigcontexts(struct pt_regs *regs,
474 memset(current->thread.transact_vr, 0, 33 * sizeof(vector128)); 478 memset(current->thread.transact_vr, 0, 33 * sizeof(vector128));
475 } 479 }
476 /* Always get VRSAVE back */ 480 /* Always get VRSAVE back */
477 if (v_regs != 0 && tm_v_regs != 0) { 481 if (v_regs != NULL && tm_v_regs != NULL) {
478 err |= __get_user(current->thread.vrsave, 482 err |= __get_user(current->thread.vrsave,
479 (u32 __user *)&v_regs[33]); 483 (u32 __user *)&v_regs[33]);
480 err |= __get_user(current->thread.transact_vrsave, 484 err |= __get_user(current->thread.transact_vrsave,
@@ -484,6 +488,8 @@ static long restore_tm_sigcontexts(struct pt_regs *regs,
484 current->thread.vrsave = 0; 488 current->thread.vrsave = 0;
485 current->thread.transact_vrsave = 0; 489 current->thread.transact_vrsave = 0;
486 } 490 }
491 if (cpu_has_feature(CPU_FTR_ALTIVEC))
492 mtspr(SPRN_VRSAVE, current->thread.vrsave);
487#endif /* CONFIG_ALTIVEC */ 493#endif /* CONFIG_ALTIVEC */
488 /* restore floating point */ 494 /* restore floating point */
489 err |= copy_fpr_from_user(current, &sc->fp_regs); 495 err |= copy_fpr_from_user(current, &sc->fp_regs);
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 38b0ba65a735..442d8e23f8f4 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -81,6 +81,28 @@ int smt_enabled_at_boot = 1;
81 81
82static void (*crash_ipi_function_ptr)(struct pt_regs *) = NULL; 82static void (*crash_ipi_function_ptr)(struct pt_regs *) = NULL;
83 83
84/*
85 * Returns 1 if the specified cpu should be brought up during boot.
86 * Used to inhibit booting threads if they've been disabled or
87 * limited on the command line
88 */
89int smp_generic_cpu_bootable(unsigned int nr)
90{
91 /* Special case - we inhibit secondary thread startup
92 * during boot if the user requests it.
93 */
94 if (system_state == SYSTEM_BOOTING && cpu_has_feature(CPU_FTR_SMT)) {
95 if (!smt_enabled_at_boot && cpu_thread_in_core(nr) != 0)
96 return 0;
97 if (smt_enabled_at_boot
98 && cpu_thread_in_core(nr) >= smt_enabled_at_boot)
99 return 0;
100 }
101
102 return 1;
103}
104
105
84#ifdef CONFIG_PPC64 106#ifdef CONFIG_PPC64
85int smp_generic_kick_cpu(int nr) 107int smp_generic_kick_cpu(int nr)
86{ 108{
@@ -172,7 +194,7 @@ int smp_request_message_ipi(int virq, int msg)
172#endif 194#endif
173 err = request_irq(virq, smp_ipi_action[msg], 195 err = request_irq(virq, smp_ipi_action[msg],
174 IRQF_PERCPU | IRQF_NO_THREAD | IRQF_NO_SUSPEND, 196 IRQF_PERCPU | IRQF_NO_THREAD | IRQF_NO_SUSPEND,
175 smp_ipi_name[msg], 0); 197 smp_ipi_name[msg], NULL);
176 WARN(err < 0, "unable to request_irq %d for %s (rc %d)\n", 198 WARN(err < 0, "unable to request_irq %d for %s (rc %d)\n",
177 virq, smp_ipi_name[msg], err); 199 virq, smp_ipi_name[msg], err);
178 200
@@ -210,6 +232,12 @@ void smp_muxed_ipi_message_pass(int cpu, int msg)
210 smp_ops->cause_ipi(cpu, info->data); 232 smp_ops->cause_ipi(cpu, info->data);
211} 233}
212 234
235#ifdef __BIG_ENDIAN__
236#define IPI_MESSAGE(A) (1 << (24 - 8 * (A)))
237#else
238#define IPI_MESSAGE(A) (1 << (8 * (A)))
239#endif
240
213irqreturn_t smp_ipi_demux(void) 241irqreturn_t smp_ipi_demux(void)
214{ 242{
215 struct cpu_messages *info = &__get_cpu_var(ipi_message); 243 struct cpu_messages *info = &__get_cpu_var(ipi_message);
@@ -219,19 +247,14 @@ irqreturn_t smp_ipi_demux(void)
219 247
220 do { 248 do {
221 all = xchg(&info->messages, 0); 249 all = xchg(&info->messages, 0);
222 250 if (all & IPI_MESSAGE(PPC_MSG_CALL_FUNCTION))
223#ifdef __BIG_ENDIAN
224 if (all & (1 << (24 - 8 * PPC_MSG_CALL_FUNCTION)))
225 generic_smp_call_function_interrupt(); 251 generic_smp_call_function_interrupt();
226 if (all & (1 << (24 - 8 * PPC_MSG_RESCHEDULE))) 252 if (all & IPI_MESSAGE(PPC_MSG_RESCHEDULE))
227 scheduler_ipi(); 253 scheduler_ipi();
228 if (all & (1 << (24 - 8 * PPC_MSG_CALL_FUNC_SINGLE))) 254 if (all & IPI_MESSAGE(PPC_MSG_CALL_FUNC_SINGLE))
229 generic_smp_call_function_single_interrupt(); 255 generic_smp_call_function_single_interrupt();
230 if (all & (1 << (24 - 8 * PPC_MSG_DEBUGGER_BREAK))) 256 if (all & IPI_MESSAGE(PPC_MSG_DEBUGGER_BREAK))
231 debug_ipi_action(0, NULL); 257 debug_ipi_action(0, NULL);
232#else
233#error Unsupported ENDIAN
234#endif
235 } while (info->messages); 258 } while (info->messages);
236 259
237 return IRQ_HANDLED; 260 return IRQ_HANDLED;
@@ -574,6 +597,21 @@ out:
574 return id; 597 return id;
575} 598}
576 599
600/* Return the value of the chip-id property corresponding
601 * to the given logical cpu.
602 */
603int cpu_to_chip_id(int cpu)
604{
605 struct device_node *np;
606
607 np = of_get_cpu_node(cpu, NULL);
608 if (!np)
609 return -1;
610
611 of_node_put(np);
612 return of_get_ibm_chip_id(np);
613}
614
577/* Helper routines for cpu to core mapping */ 615/* Helper routines for cpu to core mapping */
578int cpu_core_index_of_thread(int cpu) 616int cpu_core_index_of_thread(int cpu)
579{ 617{
@@ -587,6 +625,33 @@ int cpu_first_thread_of_core(int core)
587} 625}
588EXPORT_SYMBOL_GPL(cpu_first_thread_of_core); 626EXPORT_SYMBOL_GPL(cpu_first_thread_of_core);
589 627
628static void traverse_siblings_chip_id(int cpu, bool add, int chipid)
629{
630 const struct cpumask *mask;
631 struct device_node *np;
632 int i, plen;
633 const __be32 *prop;
634
635 mask = add ? cpu_online_mask : cpu_present_mask;
636 for_each_cpu(i, mask) {
637 np = of_get_cpu_node(i, NULL);
638 if (!np)
639 continue;
640 prop = of_get_property(np, "ibm,chip-id", &plen);
641 if (prop && plen == sizeof(int) &&
642 of_read_number(prop, 1) == chipid) {
643 if (add) {
644 cpumask_set_cpu(cpu, cpu_core_mask(i));
645 cpumask_set_cpu(i, cpu_core_mask(cpu));
646 } else {
647 cpumask_clear_cpu(cpu, cpu_core_mask(i));
648 cpumask_clear_cpu(i, cpu_core_mask(cpu));
649 }
650 }
651 of_node_put(np);
652 }
653}
654
590/* Must be called when no change can occur to cpu_present_mask, 655/* Must be called when no change can occur to cpu_present_mask,
591 * i.e. during cpu online or offline. 656 * i.e. during cpu online or offline.
592 */ 657 */
@@ -609,11 +674,51 @@ static struct device_node *cpu_to_l2cache(int cpu)
609 return cache; 674 return cache;
610} 675}
611 676
677static void traverse_core_siblings(int cpu, bool add)
678{
679 struct device_node *l2_cache, *np;
680 const struct cpumask *mask;
681 int i, chip, plen;
682 const __be32 *prop;
683
684 /* First see if we have ibm,chip-id properties in cpu nodes */
685 np = of_get_cpu_node(cpu, NULL);
686 if (np) {
687 chip = -1;
688 prop = of_get_property(np, "ibm,chip-id", &plen);
689 if (prop && plen == sizeof(int))
690 chip = of_read_number(prop, 1);
691 of_node_put(np);
692 if (chip >= 0) {
693 traverse_siblings_chip_id(cpu, add, chip);
694 return;
695 }
696 }
697
698 l2_cache = cpu_to_l2cache(cpu);
699 mask = add ? cpu_online_mask : cpu_present_mask;
700 for_each_cpu(i, mask) {
701 np = cpu_to_l2cache(i);
702 if (!np)
703 continue;
704 if (np == l2_cache) {
705 if (add) {
706 cpumask_set_cpu(cpu, cpu_core_mask(i));
707 cpumask_set_cpu(i, cpu_core_mask(cpu));
708 } else {
709 cpumask_clear_cpu(cpu, cpu_core_mask(i));
710 cpumask_clear_cpu(i, cpu_core_mask(cpu));
711 }
712 }
713 of_node_put(np);
714 }
715 of_node_put(l2_cache);
716}
717
612/* Activate a secondary processor. */ 718/* Activate a secondary processor. */
613void start_secondary(void *unused) 719void start_secondary(void *unused)
614{ 720{
615 unsigned int cpu = smp_processor_id(); 721 unsigned int cpu = smp_processor_id();
616 struct device_node *l2_cache;
617 int i, base; 722 int i, base;
618 723
619 atomic_inc(&init_mm.mm_count); 724 atomic_inc(&init_mm.mm_count);
@@ -652,18 +757,7 @@ void start_secondary(void *unused)
652 cpumask_set_cpu(cpu, cpu_core_mask(base + i)); 757 cpumask_set_cpu(cpu, cpu_core_mask(base + i));
653 cpumask_set_cpu(base + i, cpu_core_mask(cpu)); 758 cpumask_set_cpu(base + i, cpu_core_mask(cpu));
654 } 759 }
655 l2_cache = cpu_to_l2cache(cpu); 760 traverse_core_siblings(cpu, true);
656 for_each_online_cpu(i) {
657 struct device_node *np = cpu_to_l2cache(i);
658 if (!np)
659 continue;
660 if (np == l2_cache) {
661 cpumask_set_cpu(cpu, cpu_core_mask(i));
662 cpumask_set_cpu(i, cpu_core_mask(cpu));
663 }
664 of_node_put(np);
665 }
666 of_node_put(l2_cache);
667 761
668 smp_wmb(); 762 smp_wmb();
669 notify_cpu_starting(cpu); 763 notify_cpu_starting(cpu);
@@ -719,7 +813,6 @@ int arch_sd_sibling_asym_packing(void)
719#ifdef CONFIG_HOTPLUG_CPU 813#ifdef CONFIG_HOTPLUG_CPU
720int __cpu_disable(void) 814int __cpu_disable(void)
721{ 815{
722 struct device_node *l2_cache;
723 int cpu = smp_processor_id(); 816 int cpu = smp_processor_id();
724 int base, i; 817 int base, i;
725 int err; 818 int err;
@@ -739,20 +832,7 @@ int __cpu_disable(void)
739 cpumask_clear_cpu(cpu, cpu_core_mask(base + i)); 832 cpumask_clear_cpu(cpu, cpu_core_mask(base + i));
740 cpumask_clear_cpu(base + i, cpu_core_mask(cpu)); 833 cpumask_clear_cpu(base + i, cpu_core_mask(cpu));
741 } 834 }
742 835 traverse_core_siblings(cpu, false);
743 l2_cache = cpu_to_l2cache(cpu);
744 for_each_present_cpu(i) {
745 struct device_node *np = cpu_to_l2cache(i);
746 if (!np)
747 continue;
748 if (np == l2_cache) {
749 cpumask_clear_cpu(cpu, cpu_core_mask(i));
750 cpumask_clear_cpu(i, cpu_core_mask(cpu));
751 }
752 of_node_put(np);
753 }
754 of_node_put(l2_cache);
755
756 836
757 return 0; 837 return 0;
758} 838}
diff --git a/arch/powerpc/kernel/softemu8xx.c b/arch/powerpc/kernel/softemu8xx.c
deleted file mode 100644
index 29b2f81dd709..000000000000
--- a/arch/powerpc/kernel/softemu8xx.c
+++ /dev/null
@@ -1,199 +0,0 @@
1/*
2 * Software emulation of some PPC instructions for the 8xx core.
3 *
4 * Copyright (C) 1998 Dan Malek (dmalek@jlc.net)
5 *
6 * Software floating emuation for the MPC8xx processor. I did this mostly
7 * because it was easier than trying to get the libraries compiled for
8 * software floating point. The goal is still to get the libraries done,
9 * but I lost patience and needed some hacks to at least get init and
10 * shells running. The first problem is the setjmp/longjmp that save
11 * and restore the floating point registers.
12 *
13 * For this emulation, our working registers are found on the register
14 * save area.
15 */
16
17#include <linux/errno.h>
18#include <linux/sched.h>
19#include <linux/kernel.h>
20#include <linux/mm.h>
21#include <linux/stddef.h>
22#include <linux/unistd.h>
23#include <linux/ptrace.h>
24#include <linux/user.h>
25#include <linux/interrupt.h>
26
27#include <asm/pgtable.h>
28#include <asm/uaccess.h>
29#include <asm/io.h>
30
31/* Eventually we may need a look-up table, but this works for now.
32*/
33#define LFS 48
34#define LFD 50
35#define LFDU 51
36#define STFD 54
37#define STFDU 55
38#define FMR 63
39
40void print_8xx_pte(struct mm_struct *mm, unsigned long addr)
41{
42 pgd_t *pgd;
43 pmd_t *pmd;
44 pte_t *pte;
45
46 printk(" pte @ 0x%8lx: ", addr);
47 pgd = pgd_offset(mm, addr & PAGE_MASK);
48 if (pgd) {
49 pmd = pmd_offset(pud_offset(pgd, addr & PAGE_MASK),
50 addr & PAGE_MASK);
51 if (pmd && pmd_present(*pmd)) {
52 pte = pte_offset_kernel(pmd, addr & PAGE_MASK);
53 if (pte) {
54 printk(" (0x%08lx)->(0x%08lx)->0x%08lx\n",
55 (long)pgd, (long)pte, (long)pte_val(*pte));
56#define pp ((long)pte_val(*pte))
57 printk(" RPN: %05lx PP: %lx SPS: %lx SH: %lx "
58 "CI: %lx v: %lx\n",
59 pp>>12, /* rpn */
60 (pp>>10)&3, /* pp */
61 (pp>>3)&1, /* small */
62 (pp>>2)&1, /* shared */
63 (pp>>1)&1, /* cache inhibit */
64 pp&1 /* valid */
65 );
66#undef pp
67 }
68 else {
69 printk("no pte\n");
70 }
71 }
72 else {
73 printk("no pmd\n");
74 }
75 }
76 else {
77 printk("no pgd\n");
78 }
79}
80
81int get_8xx_pte(struct mm_struct *mm, unsigned long addr)
82{
83 pgd_t *pgd;
84 pmd_t *pmd;
85 pte_t *pte;
86 int retval = 0;
87
88 pgd = pgd_offset(mm, addr & PAGE_MASK);
89 if (pgd) {
90 pmd = pmd_offset(pud_offset(pgd, addr & PAGE_MASK),
91 addr & PAGE_MASK);
92 if (pmd && pmd_present(*pmd)) {
93 pte = pte_offset_kernel(pmd, addr & PAGE_MASK);
94 if (pte) {
95 retval = (int)pte_val(*pte);
96 }
97 }
98 }
99 return retval;
100}
101
102/*
103 * We return 0 on success, 1 on unimplemented instruction, and EFAULT
104 * if a load/store faulted.
105 */
106int Soft_emulate_8xx(struct pt_regs *regs)
107{
108 u32 inst, instword;
109 u32 flreg, idxreg, disp;
110 int retval;
111 s16 sdisp;
112 u32 *ea, *ip;
113
114 retval = 0;
115
116 instword = *((u32 *)regs->nip);
117 inst = instword >> 26;
118
119 flreg = (instword >> 21) & 0x1f;
120 idxreg = (instword >> 16) & 0x1f;
121 disp = instword & 0xffff;
122
123 ea = (u32 *)(regs->gpr[idxreg] + disp);
124 ip = (u32 *)&current->thread.TS_FPR(flreg);
125
126 switch ( inst )
127 {
128 case LFD:
129 /* this is a 16 bit quantity that is sign extended
130 * so use a signed short here -- Cort
131 */
132 sdisp = (instword & 0xffff);
133 ea = (u32 *)(regs->gpr[idxreg] + sdisp);
134 if (copy_from_user(ip, ea, sizeof(double)))
135 retval = -EFAULT;
136 break;
137
138 case LFDU:
139 if (copy_from_user(ip, ea, sizeof(double)))
140 retval = -EFAULT;
141 else
142 regs->gpr[idxreg] = (u32)ea;
143 break;
144 case LFS:
145 sdisp = (instword & 0xffff);
146 ea = (u32 *)(regs->gpr[idxreg] + sdisp);
147 if (copy_from_user(ip, ea, sizeof(float)))
148 retval = -EFAULT;
149 break;
150 case STFD:
151 /* this is a 16 bit quantity that is sign extended
152 * so use a signed short here -- Cort
153 */
154 sdisp = (instword & 0xffff);
155 ea = (u32 *)(regs->gpr[idxreg] + sdisp);
156 if (copy_to_user(ea, ip, sizeof(double)))
157 retval = -EFAULT;
158 break;
159
160 case STFDU:
161 if (copy_to_user(ea, ip, sizeof(double)))
162 retval = -EFAULT;
163 else
164 regs->gpr[idxreg] = (u32)ea;
165 break;
166 case FMR:
167 /* assume this is a fp move -- Cort */
168 memcpy(ip, &current->thread.TS_FPR((instword>>11)&0x1f),
169 sizeof(double));
170 break;
171 default:
172 retval = 1;
173 printk("Bad emulation %s/%d\n"
174 " NIP: %08lx instruction: %08x opcode: %x "
175 "A: %x B: %x C: %x code: %x rc: %x\n",
176 current->comm,current->pid,
177 regs->nip,
178 instword,inst,
179 (instword>>16)&0x1f,
180 (instword>>11)&0x1f,
181 (instword>>6)&0x1f,
182 (instword>>1)&0x3ff,
183 instword&1);
184 {
185 int pa;
186 print_8xx_pte(current->mm,regs->nip);
187 pa = get_8xx_pte(current->mm,regs->nip) & PAGE_MASK;
188 pa |= (regs->nip & ~PAGE_MASK);
189 pa = (unsigned long)__va(pa);
190 printk("Kernel VA for NIP %x ", pa);
191 print_8xx_pte(current->mm,pa);
192 }
193 }
194
195 if (retval == 0)
196 regs->nip += 4;
197
198 return retval;
199}
diff --git a/arch/powerpc/kernel/swsusp_asm64.S b/arch/powerpc/kernel/swsusp_asm64.S
index 86ac1d90d02b..22045984835f 100644
--- a/arch/powerpc/kernel/swsusp_asm64.S
+++ b/arch/powerpc/kernel/swsusp_asm64.S
@@ -46,10 +46,19 @@
46#define SL_r29 0xe8 46#define SL_r29 0xe8
47#define SL_r30 0xf0 47#define SL_r30 0xf0
48#define SL_r31 0xf8 48#define SL_r31 0xf8
49#define SL_SIZE SL_r31+8 49#define SL_SPRG1 0x100
50#define SL_TCR 0x108
51#define SL_SIZE SL_TCR+8
50 52
51/* these macros rely on the save area being 53/* these macros rely on the save area being
52 * pointed to by r11 */ 54 * pointed to by r11 */
55
56#define SAVE_SPR(register) \
57 mfspr r0, SPRN_##register ;\
58 std r0, SL_##register(r11)
59#define RESTORE_SPR(register) \
60 ld r0, SL_##register(r11) ;\
61 mtspr SPRN_##register, r0
53#define SAVE_SPECIAL(special) \ 62#define SAVE_SPECIAL(special) \
54 mf##special r0 ;\ 63 mf##special r0 ;\
55 std r0, SL_##special(r11) 64 std r0, SL_##special(r11)
@@ -103,8 +112,15 @@ _GLOBAL(swsusp_arch_suspend)
103 SAVE_REGISTER(r30) 112 SAVE_REGISTER(r30)
104 SAVE_REGISTER(r31) 113 SAVE_REGISTER(r31)
105 SAVE_SPECIAL(MSR) 114 SAVE_SPECIAL(MSR)
106 SAVE_SPECIAL(SDR1)
107 SAVE_SPECIAL(XER) 115 SAVE_SPECIAL(XER)
116#ifdef CONFIG_PPC_BOOK3S_64
117 SAVE_SPECIAL(SDR1)
118#else
119 SAVE_SPR(TCR)
120
121 /* Save SPRG1, SPRG1 be used save paca */
122 SAVE_SPR(SPRG1)
123#endif
108 124
109 /* we push the stack up 128 bytes but don't store the 125 /* we push the stack up 128 bytes but don't store the
110 * stack pointer on the stack like a real stackframe */ 126 * stack pointer on the stack like a real stackframe */
@@ -151,6 +167,7 @@ copy_page_loop:
151 bne+ copyloop 167 bne+ copyloop
152nothing_to_copy: 168nothing_to_copy:
153 169
170#ifdef CONFIG_PPC_BOOK3S_64
154 /* flush caches */ 171 /* flush caches */
155 lis r3, 0x10 172 lis r3, 0x10
156 mtctr r3 173 mtctr r3
@@ -167,6 +184,7 @@ nothing_to_copy:
167 sync 184 sync
168 185
169 tlbia 186 tlbia
187#endif
170 188
171 ld r11,swsusp_save_area_ptr@toc(r2) 189 ld r11,swsusp_save_area_ptr@toc(r2)
172 190
@@ -208,16 +226,39 @@ nothing_to_copy:
208 RESTORE_REGISTER(r29) 226 RESTORE_REGISTER(r29)
209 RESTORE_REGISTER(r30) 227 RESTORE_REGISTER(r30)
210 RESTORE_REGISTER(r31) 228 RESTORE_REGISTER(r31)
229
230#ifdef CONFIG_PPC_BOOK3S_64
211 /* can't use RESTORE_SPECIAL(MSR) */ 231 /* can't use RESTORE_SPECIAL(MSR) */
212 ld r0, SL_MSR(r11) 232 ld r0, SL_MSR(r11)
213 mtmsrd r0, 0 233 mtmsrd r0, 0
214 RESTORE_SPECIAL(SDR1) 234 RESTORE_SPECIAL(SDR1)
235#else
236 /* Restore SPRG1, be used to save paca */
237 ld r0, SL_SPRG1(r11)
238 mtsprg 1, r0
239
240 RESTORE_SPECIAL(MSR)
241
242 /* Restore TCR and clear any pending bits in TSR. */
243 RESTORE_SPR(TCR)
244 lis r0, (TSR_ENW | TSR_WIS | TSR_DIS | TSR_FIS)@h
245 mtspr SPRN_TSR, r0
246
247 /* Kick decrementer */
248 li r0, 1
249 mtdec r0
250
251 /* Invalidate all tlbs */
252 bl _tlbil_all
253#endif
215 RESTORE_SPECIAL(XER) 254 RESTORE_SPECIAL(XER)
216 255
217 sync 256 sync
218 257
219 addi r1,r1,-128 258 addi r1,r1,-128
259#ifdef CONFIG_PPC_BOOK3S_64
220 bl slb_flush_and_rebolt 260 bl slb_flush_and_rebolt
261#endif
221 bl do_after_copyback 262 bl do_after_copyback
222 addi r1,r1,128 263 addi r1,r1,128
223 264
diff --git a/arch/powerpc/kernel/swsusp_booke.S b/arch/powerpc/kernel/swsusp_booke.S
index 11a39307dd71..0f204053e5b5 100644
--- a/arch/powerpc/kernel/swsusp_booke.S
+++ b/arch/powerpc/kernel/swsusp_booke.S
@@ -141,6 +141,14 @@ _GLOBAL(swsusp_arch_resume)
141 lis r11,swsusp_save_area@h 141 lis r11,swsusp_save_area@h
142 ori r11,r11,swsusp_save_area@l 142 ori r11,r11,swsusp_save_area@l
143 143
144 /*
145 * Mappings from virtual addresses to physical addresses may be
146 * different than they were prior to restoring hibernation state.
147 * Invalidate the TLB so that the boot CPU is using the new
148 * mappings.
149 */
150 bl _tlbil_all
151
144 lwz r4,SL_SPRG0(r11) 152 lwz r4,SL_SPRG0(r11)
145 mtsprg 0,r4 153 mtsprg 0,r4
146 lwz r4,SL_SPRG1(r11) 154 lwz r4,SL_SPRG1(r11)
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index cdcc156865ef..192b051df97e 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -210,18 +210,18 @@ static u64 scan_dispatch_log(u64 stop_tb)
210 if (!dtl) 210 if (!dtl)
211 return 0; 211 return 0;
212 212
213 if (i == vpa->dtl_idx) 213 if (i == be64_to_cpu(vpa->dtl_idx))
214 return 0; 214 return 0;
215 while (i < vpa->dtl_idx) { 215 while (i < be64_to_cpu(vpa->dtl_idx)) {
216 if (dtl_consumer) 216 if (dtl_consumer)
217 dtl_consumer(dtl, i); 217 dtl_consumer(dtl, i);
218 dtb = dtl->timebase; 218 dtb = be64_to_cpu(dtl->timebase);
219 tb_delta = dtl->enqueue_to_dispatch_time + 219 tb_delta = be32_to_cpu(dtl->enqueue_to_dispatch_time) +
220 dtl->ready_to_enqueue_time; 220 be32_to_cpu(dtl->ready_to_enqueue_time);
221 barrier(); 221 barrier();
222 if (i + N_DISPATCH_LOG < vpa->dtl_idx) { 222 if (i + N_DISPATCH_LOG < be64_to_cpu(vpa->dtl_idx)) {
223 /* buffer has overflowed */ 223 /* buffer has overflowed */
224 i = vpa->dtl_idx - N_DISPATCH_LOG; 224 i = be64_to_cpu(vpa->dtl_idx) - N_DISPATCH_LOG;
225 dtl = local_paca->dispatch_log + (i % N_DISPATCH_LOG); 225 dtl = local_paca->dispatch_log + (i % N_DISPATCH_LOG);
226 continue; 226 continue;
227 } 227 }
@@ -269,7 +269,7 @@ static inline u64 calculate_stolen_time(u64 stop_tb)
269{ 269{
270 u64 stolen = 0; 270 u64 stolen = 0;
271 271
272 if (get_paca()->dtl_ridx != get_paca()->lppaca_ptr->dtl_idx) { 272 if (get_paca()->dtl_ridx != be64_to_cpu(get_lppaca()->dtl_idx)) {
273 stolen = scan_dispatch_log(stop_tb); 273 stolen = scan_dispatch_log(stop_tb);
274 get_paca()->system_time -= stolen; 274 get_paca()->system_time -= stolen;
275 } 275 }
@@ -612,7 +612,7 @@ unsigned long long sched_clock(void)
612static int __init get_freq(char *name, int cells, unsigned long *val) 612static int __init get_freq(char *name, int cells, unsigned long *val)
613{ 613{
614 struct device_node *cpu; 614 struct device_node *cpu;
615 const unsigned int *fp; 615 const __be32 *fp;
616 int found = 0; 616 int found = 0;
617 617
618 /* The cpu node should have timebase and clock frequency properties */ 618 /* The cpu node should have timebase and clock frequency properties */
diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S
index 0554d1f6d70d..7b60b9851469 100644
--- a/arch/powerpc/kernel/tm.S
+++ b/arch/powerpc/kernel/tm.S
@@ -155,10 +155,10 @@ _GLOBAL(tm_reclaim)
155 mfvscr vr0 155 mfvscr vr0
156 li r6, THREAD_TRANSACT_VSCR 156 li r6, THREAD_TRANSACT_VSCR
157 stvx vr0, r3, r6 157 stvx vr0, r3, r6
158dont_backup_vec:
158 mfspr r0, SPRN_VRSAVE 159 mfspr r0, SPRN_VRSAVE
159 std r0, THREAD_TRANSACT_VRSAVE(r3) 160 std r0, THREAD_TRANSACT_VRSAVE(r3)
160 161
161dont_backup_vec:
162 andi. r0, r4, MSR_FP 162 andi. r0, r4, MSR_FP
163 beq dont_backup_fp 163 beq dont_backup_fp
164 164
@@ -341,11 +341,11 @@ _GLOBAL(tm_recheckpoint)
341 lvx vr0, r3, r5 341 lvx vr0, r3, r5
342 mtvscr vr0 342 mtvscr vr0
343 REST_32VRS(0, r5, r3) /* r5 scratch, r3 THREAD ptr */ 343 REST_32VRS(0, r5, r3) /* r5 scratch, r3 THREAD ptr */
344dont_restore_vec:
344 ld r5, THREAD_VRSAVE(r3) 345 ld r5, THREAD_VRSAVE(r3)
345 mtspr SPRN_VRSAVE, r5 346 mtspr SPRN_VRSAVE, r5
346#endif 347#endif
347 348
348dont_restore_vec:
349 andi. r0, r4, MSR_FP 349 andi. r0, r4, MSR_FP
350 beq dont_restore_fp 350 beq dont_restore_fp
351 351
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index e435bc089ea3..f783c932faeb 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -60,6 +60,7 @@
60#include <asm/switch_to.h> 60#include <asm/switch_to.h>
61#include <asm/tm.h> 61#include <asm/tm.h>
62#include <asm/debug.h> 62#include <asm/debug.h>
63#include <sysdev/fsl_pci.h>
63 64
64#if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC) 65#if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC)
65int (*__debugger)(struct pt_regs *regs) __read_mostly; 66int (*__debugger)(struct pt_regs *regs) __read_mostly;
@@ -565,6 +566,8 @@ int machine_check_e500(struct pt_regs *regs)
565 if (reason & MCSR_BUS_RBERR) { 566 if (reason & MCSR_BUS_RBERR) {
566 if (fsl_rio_mcheck_exception(regs)) 567 if (fsl_rio_mcheck_exception(regs))
567 return 1; 568 return 1;
569 if (fsl_pci_mcheck_exception(regs))
570 return 1;
568 } 571 }
569 572
570 printk("Machine check in kernel mode.\n"); 573 printk("Machine check in kernel mode.\n");
@@ -962,7 +965,7 @@ static int emulate_instruction(struct pt_regs *regs)
962 u32 instword; 965 u32 instword;
963 u32 rd; 966 u32 rd;
964 967
965 if (!user_mode(regs) || (regs->msr & MSR_LE)) 968 if (!user_mode(regs))
966 return -EINVAL; 969 return -EINVAL;
967 CHECK_FULL_REGS(regs); 970 CHECK_FULL_REGS(regs);
968 971
@@ -1050,11 +1053,41 @@ int is_valid_bugaddr(unsigned long addr)
1050 return is_kernel_addr(addr); 1053 return is_kernel_addr(addr);
1051} 1054}
1052 1055
1056#ifdef CONFIG_MATH_EMULATION
1057static int emulate_math(struct pt_regs *regs)
1058{
1059 int ret;
1060 extern int do_mathemu(struct pt_regs *regs);
1061
1062 ret = do_mathemu(regs);
1063 if (ret >= 0)
1064 PPC_WARN_EMULATED(math, regs);
1065
1066 switch (ret) {
1067 case 0:
1068 emulate_single_step(regs);
1069 return 0;
1070 case 1: {
1071 int code = 0;
1072 code = __parse_fpscr(current->thread.fpscr.val);
1073 _exception(SIGFPE, regs, code, regs->nip);
1074 return 0;
1075 }
1076 case -EFAULT:
1077 _exception(SIGSEGV, regs, SEGV_MAPERR, regs->nip);
1078 return 0;
1079 }
1080
1081 return -1;
1082}
1083#else
1084static inline int emulate_math(struct pt_regs *regs) { return -1; }
1085#endif
1086
1053void __kprobes program_check_exception(struct pt_regs *regs) 1087void __kprobes program_check_exception(struct pt_regs *regs)
1054{ 1088{
1055 enum ctx_state prev_state = exception_enter(); 1089 enum ctx_state prev_state = exception_enter();
1056 unsigned int reason = get_reason(regs); 1090 unsigned int reason = get_reason(regs);
1057 extern int do_mathemu(struct pt_regs *regs);
1058 1091
1059 /* We can now get here via a FP Unavailable exception if the core 1092 /* We can now get here via a FP Unavailable exception if the core
1060 * has no FPU, in that case the reason flags will be 0 */ 1093 * has no FPU, in that case the reason flags will be 0 */
@@ -1116,11 +1149,20 @@ void __kprobes program_check_exception(struct pt_regs *regs)
1116 } 1149 }
1117#endif 1150#endif
1118 1151
1152 /*
1153 * If we took the program check in the kernel skip down to sending a
1154 * SIGILL. The subsequent cases all relate to emulating instructions
1155 * which we should only do for userspace. We also do not want to enable
1156 * interrupts for kernel faults because that might lead to further
1157 * faults, and loose the context of the original exception.
1158 */
1159 if (!user_mode(regs))
1160 goto sigill;
1161
1119 /* We restore the interrupt state now */ 1162 /* We restore the interrupt state now */
1120 if (!arch_irq_disabled_regs(regs)) 1163 if (!arch_irq_disabled_regs(regs))
1121 local_irq_enable(); 1164 local_irq_enable();
1122 1165
1123#ifdef CONFIG_MATH_EMULATION
1124 /* (reason & REASON_ILLEGAL) would be the obvious thing here, 1166 /* (reason & REASON_ILLEGAL) would be the obvious thing here,
1125 * but there seems to be a hardware bug on the 405GP (RevD) 1167 * but there seems to be a hardware bug on the 405GP (RevD)
1126 * that means ESR is sometimes set incorrectly - either to 1168 * that means ESR is sometimes set incorrectly - either to
@@ -1129,31 +1171,8 @@ void __kprobes program_check_exception(struct pt_regs *regs)
1129 * instruction or only on FP instructions, whether there is a 1171 * instruction or only on FP instructions, whether there is a
1130 * pattern to occurrences etc. -dgibson 31/Mar/2003 1172 * pattern to occurrences etc. -dgibson 31/Mar/2003
1131 */ 1173 */
1132 1174 if (!emulate_math(regs))
1133 /*
1134 * If we support a HW FPU, we need to ensure the FP state
1135 * if flushed into the thread_struct before attempting
1136 * emulation
1137 */
1138#ifdef CONFIG_PPC_FPU
1139 flush_fp_to_thread(current);
1140#endif
1141 switch (do_mathemu(regs)) {
1142 case 0:
1143 emulate_single_step(regs);
1144 goto bail;
1145 case 1: {
1146 int code = 0;
1147 code = __parse_fpscr(current->thread.fpscr.val);
1148 _exception(SIGFPE, regs, code, regs->nip);
1149 goto bail;
1150 }
1151 case -EFAULT:
1152 _exception(SIGSEGV, regs, SEGV_MAPERR, regs->nip);
1153 goto bail; 1175 goto bail;
1154 }
1155 /* fall through on any other errors */
1156#endif /* CONFIG_MATH_EMULATION */
1157 1176
1158 /* Try to emulate it if we should. */ 1177 /* Try to emulate it if we should. */
1159 if (reason & (REASON_ILLEGAL | REASON_PRIVILEGED)) { 1178 if (reason & (REASON_ILLEGAL | REASON_PRIVILEGED)) {
@@ -1168,6 +1187,7 @@ void __kprobes program_check_exception(struct pt_regs *regs)
1168 } 1187 }
1169 } 1188 }
1170 1189
1190sigill:
1171 if (reason & REASON_PRIVILEGED) 1191 if (reason & REASON_PRIVILEGED)
1172 _exception(SIGILL, regs, ILL_PRVOPC, regs->nip); 1192 _exception(SIGILL, regs, ILL_PRVOPC, regs->nip);
1173 else 1193 else
@@ -1322,13 +1342,10 @@ void facility_unavailable_exception(struct pt_regs *regs)
1322 if (status == FSCR_DSCR_LG) { 1342 if (status == FSCR_DSCR_LG) {
1323 /* User is acessing the DSCR. Set the inherit bit and allow 1343 /* User is acessing the DSCR. Set the inherit bit and allow
1324 * the user to set it directly in future by setting via the 1344 * the user to set it directly in future by setting via the
1325 * H/FSCR DSCR bit. 1345 * FSCR DSCR bit. We always leave HFSCR DSCR set.
1326 */ 1346 */
1327 current->thread.dscr_inherit = 1; 1347 current->thread.dscr_inherit = 1;
1328 if (hv) 1348 mtspr(SPRN_FSCR, value | FSCR_DSCR);
1329 mtspr(SPRN_HFSCR, value | HFSCR_DSCR);
1330 else
1331 mtspr(SPRN_FSCR, value | FSCR_DSCR);
1332 return; 1349 return;
1333 } 1350 }
1334 1351
@@ -1444,11 +1461,6 @@ void performance_monitor_exception(struct pt_regs *regs)
1444#ifdef CONFIG_8xx 1461#ifdef CONFIG_8xx
1445void SoftwareEmulation(struct pt_regs *regs) 1462void SoftwareEmulation(struct pt_regs *regs)
1446{ 1463{
1447 extern int do_mathemu(struct pt_regs *);
1448#if defined(CONFIG_MATH_EMULATION)
1449 int errcode;
1450#endif
1451
1452 CHECK_FULL_REGS(regs); 1464 CHECK_FULL_REGS(regs);
1453 1465
1454 if (!user_mode(regs)) { 1466 if (!user_mode(regs)) {
@@ -1456,31 +1468,10 @@ void SoftwareEmulation(struct pt_regs *regs)
1456 die("Kernel Mode Software FPU Emulation", regs, SIGFPE); 1468 die("Kernel Mode Software FPU Emulation", regs, SIGFPE);
1457 } 1469 }
1458 1470
1459#ifdef CONFIG_MATH_EMULATION 1471 if (!emulate_math(regs))
1460 errcode = do_mathemu(regs);
1461 if (errcode >= 0)
1462 PPC_WARN_EMULATED(math, regs);
1463
1464 switch (errcode) {
1465 case 0:
1466 emulate_single_step(regs);
1467 return; 1472 return;
1468 case 1: { 1473
1469 int code = 0;
1470 code = __parse_fpscr(current->thread.fpscr.val);
1471 _exception(SIGFPE, regs, code, regs->nip);
1472 return;
1473 }
1474 case -EFAULT:
1475 _exception(SIGSEGV, regs, SEGV_MAPERR, regs->nip);
1476 return;
1477 default:
1478 _exception(SIGILL, regs, ILL_ILLOPC, regs->nip);
1479 return;
1480 }
1481#else
1482 _exception(SIGILL, regs, ILL_ILLOPC, regs->nip); 1474 _exception(SIGILL, regs, ILL_ILLOPC, regs->nip);
1483#endif
1484} 1475}
1485#endif /* CONFIG_8xx */ 1476#endif /* CONFIG_8xx */
1486 1477
diff --git a/arch/powerpc/kernel/udbg_16550.c b/arch/powerpc/kernel/udbg_16550.c
index 6837f839ab78..75702e207b29 100644
--- a/arch/powerpc/kernel/udbg_16550.c
+++ b/arch/powerpc/kernel/udbg_16550.c
@@ -18,23 +18,19 @@ extern void real_writeb(u8 data, volatile u8 __iomem *addr);
18extern u8 real_205_readb(volatile u8 __iomem *addr); 18extern u8 real_205_readb(volatile u8 __iomem *addr);
19extern void real_205_writeb(u8 data, volatile u8 __iomem *addr); 19extern void real_205_writeb(u8 data, volatile u8 __iomem *addr);
20 20
21struct NS16550 { 21#define UART_RBR 0
22 /* this struct must be packed */ 22#define UART_IER 1
23 unsigned char rbr; /* 0 */ 23#define UART_FCR 2
24 unsigned char ier; /* 1 */ 24#define UART_LCR 3
25 unsigned char fcr; /* 2 */ 25#define UART_MCR 4
26 unsigned char lcr; /* 3 */ 26#define UART_LSR 5
27 unsigned char mcr; /* 4 */ 27#define UART_MSR 6
28 unsigned char lsr; /* 5 */ 28#define UART_SCR 7
29 unsigned char msr; /* 6 */ 29#define UART_THR UART_RBR
30 unsigned char scr; /* 7 */ 30#define UART_IIR UART_FCR
31}; 31#define UART_DLL UART_RBR
32 32#define UART_DLM UART_IER
33#define thr rbr 33#define UART_DLAB UART_LCR
34#define iir fcr
35#define dll rbr
36#define dlm ier
37#define dlab lcr
38 34
39#define LSR_DR 0x01 /* Data ready */ 35#define LSR_DR 0x01 /* Data ready */
40#define LSR_OE 0x02 /* Overrun */ 36#define LSR_OE 0x02 /* Overrun */
@@ -47,52 +43,62 @@ struct NS16550 {
47 43
48#define LCR_DLAB 0x80 44#define LCR_DLAB 0x80
49 45
50static struct NS16550 __iomem *udbg_comport; 46static u8 (*udbg_uart_in)(unsigned int reg);
47static void (*udbg_uart_out)(unsigned int reg, u8 data);
51 48
52static void udbg_550_flush(void) 49static void udbg_uart_flush(void)
53{ 50{
54 if (udbg_comport) { 51 if (!udbg_uart_in)
55 while ((in_8(&udbg_comport->lsr) & LSR_THRE) == 0) 52 return;
56 /* wait for idle */; 53
57 } 54 /* wait for idle */
55 while ((udbg_uart_in(UART_LSR) & LSR_THRE) == 0)
56 cpu_relax();
58} 57}
59 58
60static void udbg_550_putc(char c) 59static void udbg_uart_putc(char c)
61{ 60{
62 if (udbg_comport) { 61 if (!udbg_uart_out)
63 if (c == '\n') 62 return;
64 udbg_550_putc('\r'); 63
65 udbg_550_flush(); 64 if (c == '\n')
66 out_8(&udbg_comport->thr, c); 65 udbg_uart_putc('\r');
67 } 66 udbg_uart_flush();
67 udbg_uart_out(UART_THR, c);
68} 68}
69 69
70static int udbg_550_getc_poll(void) 70static int udbg_uart_getc_poll(void)
71{ 71{
72 if (udbg_comport) { 72 if (!udbg_uart_in || !(udbg_uart_in(UART_LSR) & LSR_DR))
73 if ((in_8(&udbg_comport->lsr) & LSR_DR) != 0) 73 return udbg_uart_in(UART_RBR);
74 return in_8(&udbg_comport->rbr);
75 else
76 return -1;
77 }
78 return -1; 74 return -1;
79} 75}
80 76
81static int udbg_550_getc(void) 77static int udbg_uart_getc(void)
82{ 78{
83 if (udbg_comport) { 79 if (!udbg_uart_in)
84 while ((in_8(&udbg_comport->lsr) & LSR_DR) == 0) 80 return -1;
85 /* wait for char */; 81 /* wait for char */
86 return in_8(&udbg_comport->rbr); 82 while (!(udbg_uart_in(UART_LSR) & LSR_DR))
87 } 83 cpu_relax();
88 return -1; 84 return udbg_uart_in(UART_RBR);
85}
86
87static void udbg_use_uart(void)
88{
89 udbg_putc = udbg_uart_putc;
90 udbg_flush = udbg_uart_flush;
91 udbg_getc = udbg_uart_getc;
92 udbg_getc_poll = udbg_uart_getc_poll;
89} 93}
90 94
91void udbg_init_uart(void __iomem *comport, unsigned int speed, 95void udbg_uart_setup(unsigned int speed, unsigned int clock)
92 unsigned int clock)
93{ 96{
94 unsigned int dll, base_bauds; 97 unsigned int dll, base_bauds;
95 98
99 if (!udbg_uart_out)
100 return;
101
96 if (clock == 0) 102 if (clock == 0)
97 clock = 1843200; 103 clock = 1843200;
98 if (speed == 0) 104 if (speed == 0)
@@ -101,51 +107,43 @@ void udbg_init_uart(void __iomem *comport, unsigned int speed,
101 base_bauds = clock / 16; 107 base_bauds = clock / 16;
102 dll = base_bauds / speed; 108 dll = base_bauds / speed;
103 109
104 if (comport) { 110 udbg_uart_out(UART_LCR, 0x00);
105 udbg_comport = (struct NS16550 __iomem *)comport; 111 udbg_uart_out(UART_IER, 0xff);
106 out_8(&udbg_comport->lcr, 0x00); 112 udbg_uart_out(UART_IER, 0x00);
107 out_8(&udbg_comport->ier, 0xff); 113 udbg_uart_out(UART_LCR, LCR_DLAB);
108 out_8(&udbg_comport->ier, 0x00); 114 udbg_uart_out(UART_DLL, dll & 0xff);
109 out_8(&udbg_comport->lcr, LCR_DLAB); 115 udbg_uart_out(UART_DLM, dll >> 8);
110 out_8(&udbg_comport->dll, dll & 0xff); 116 /* 8 data, 1 stop, no parity */
111 out_8(&udbg_comport->dlm, dll >> 8); 117 udbg_uart_out(UART_LCR, 0x3);
112 /* 8 data, 1 stop, no parity */ 118 /* RTS/DTR */
113 out_8(&udbg_comport->lcr, 0x03); 119 udbg_uart_out(UART_MCR, 0x3);
114 /* RTS/DTR */ 120 /* Clear & enable FIFOs */
115 out_8(&udbg_comport->mcr, 0x03); 121 udbg_uart_out(UART_FCR, 0x7);
116 /* Clear & enable FIFOs */
117 out_8(&udbg_comport->fcr ,0x07);
118 udbg_putc = udbg_550_putc;
119 udbg_flush = udbg_550_flush;
120 udbg_getc = udbg_550_getc;
121 udbg_getc_poll = udbg_550_getc_poll;
122 }
123} 122}
124 123
125unsigned int udbg_probe_uart_speed(void __iomem *comport, unsigned int clock) 124unsigned int udbg_probe_uart_speed(unsigned int clock)
126{ 125{
127 unsigned int dll, dlm, divisor, prescaler, speed; 126 unsigned int dll, dlm, divisor, prescaler, speed;
128 u8 old_lcr; 127 u8 old_lcr;
129 struct NS16550 __iomem *port = comport;
130 128
131 old_lcr = in_8(&port->lcr); 129 old_lcr = udbg_uart_in(UART_LCR);
132 130
133 /* select divisor latch registers. */ 131 /* select divisor latch registers. */
134 out_8(&port->lcr, LCR_DLAB); 132 udbg_uart_out(UART_LCR, old_lcr | LCR_DLAB);
135 133
136 /* now, read the divisor */ 134 /* now, read the divisor */
137 dll = in_8(&port->dll); 135 dll = udbg_uart_in(UART_DLL);
138 dlm = in_8(&port->dlm); 136 dlm = udbg_uart_in(UART_DLM);
139 divisor = dlm << 8 | dll; 137 divisor = dlm << 8 | dll;
140 138
141 /* check prescaling */ 139 /* check prescaling */
142 if (in_8(&port->mcr) & 0x80) 140 if (udbg_uart_in(UART_MCR) & 0x80)
143 prescaler = 4; 141 prescaler = 4;
144 else 142 else
145 prescaler = 1; 143 prescaler = 1;
146 144
147 /* restore the LCR */ 145 /* restore the LCR */
148 out_8(&port->lcr, old_lcr); 146 udbg_uart_out(UART_LCR, old_lcr);
149 147
150 /* calculate speed */ 148 /* calculate speed */
151 speed = (clock / prescaler) / (divisor * 16); 149 speed = (clock / prescaler) / (divisor * 16);
@@ -157,195 +155,155 @@ unsigned int udbg_probe_uart_speed(void __iomem *comport, unsigned int clock)
157 return speed; 155 return speed;
158} 156}
159 157
160#ifdef CONFIG_PPC_MAPLE 158static union {
161void udbg_maple_real_flush(void) 159 unsigned char __iomem *mmio_base;
160 unsigned long pio_base;
161} udbg_uart;
162
163static unsigned int udbg_uart_stride = 1;
164
165static u8 udbg_uart_in_pio(unsigned int reg)
162{ 166{
163 if (udbg_comport) { 167 return inb(udbg_uart.pio_base + (reg * udbg_uart_stride));
164 while ((real_readb(&udbg_comport->lsr) & LSR_THRE) == 0)
165 /* wait for idle */;
166 }
167} 168}
168 169
169void udbg_maple_real_putc(char c) 170static void udbg_uart_out_pio(unsigned int reg, u8 data)
170{ 171{
171 if (udbg_comport) { 172 outb(data, udbg_uart.pio_base + (reg * udbg_uart_stride));
172 if (c == '\n')
173 udbg_maple_real_putc('\r');
174 udbg_maple_real_flush();
175 real_writeb(c, &udbg_comport->thr); eieio();
176 }
177} 173}
178 174
179void __init udbg_init_maple_realmode(void) 175void udbg_uart_init_pio(unsigned long port, unsigned int stride)
180{ 176{
181 udbg_comport = (struct NS16550 __iomem *)0xf40003f8; 177 if (!port)
182 178 return;
183 udbg_putc = udbg_maple_real_putc; 179 udbg_uart.pio_base = port;
184 udbg_flush = udbg_maple_real_flush; 180 udbg_uart_stride = stride;
185 udbg_getc = NULL; 181 udbg_uart_in = udbg_uart_in_pio;
186 udbg_getc_poll = NULL; 182 udbg_uart_out = udbg_uart_out_pio;
183 udbg_use_uart();
187} 184}
188#endif /* CONFIG_PPC_MAPLE */
189 185
190#ifdef CONFIG_PPC_PASEMI 186static u8 udbg_uart_in_mmio(unsigned int reg)
191void udbg_pas_real_flush(void)
192{ 187{
193 if (udbg_comport) { 188 return in_8(udbg_uart.mmio_base + (reg * udbg_uart_stride));
194 while ((real_205_readb(&udbg_comport->lsr) & LSR_THRE) == 0)
195 /* wait for idle */;
196 }
197} 189}
198 190
199void udbg_pas_real_putc(char c) 191static void udbg_uart_out_mmio(unsigned int reg, u8 data)
200{ 192{
201 if (udbg_comport) { 193 out_8(udbg_uart.mmio_base + (reg * udbg_uart_stride), data);
202 if (c == '\n')
203 udbg_pas_real_putc('\r');
204 udbg_pas_real_flush();
205 real_205_writeb(c, &udbg_comport->thr); eieio();
206 }
207} 194}
208 195
209void udbg_init_pas_realmode(void)
210{
211 udbg_comport = (struct NS16550 __iomem *)0xfcff03f8UL;
212 196
213 udbg_putc = udbg_pas_real_putc; 197void udbg_uart_init_mmio(void __iomem *addr, unsigned int stride)
214 udbg_flush = udbg_pas_real_flush; 198{
215 udbg_getc = NULL; 199 if (!addr)
216 udbg_getc_poll = NULL; 200 return;
201 udbg_uart.mmio_base = addr;
202 udbg_uart_stride = stride;
203 udbg_uart_in = udbg_uart_in_mmio;
204 udbg_uart_out = udbg_uart_out_mmio;
205 udbg_use_uart();
217} 206}
218#endif /* CONFIG_PPC_MAPLE */
219 207
220#ifdef CONFIG_PPC_EARLY_DEBUG_44x 208#ifdef CONFIG_PPC_MAPLE
221#include <platforms/44x/44x.h> 209
210#define UDBG_UART_MAPLE_ADDR ((void __iomem *)0xf40003f8)
222 211
223static void udbg_44x_as1_flush(void) 212static u8 udbg_uart_in_maple(unsigned int reg)
224{ 213{
225 if (udbg_comport) { 214 return real_readb(UDBG_UART_MAPLE_ADDR + reg);
226 while ((as1_readb(&udbg_comport->lsr) & LSR_THRE) == 0)
227 /* wait for idle */;
228 }
229} 215}
230 216
231static void udbg_44x_as1_putc(char c) 217static void udbg_uart_out_maple(unsigned int reg, u8 val)
232{ 218{
233 if (udbg_comport) { 219 real_writeb(val, UDBG_UART_MAPLE_ADDR + reg);
234 if (c == '\n')
235 udbg_44x_as1_putc('\r');
236 udbg_44x_as1_flush();
237 as1_writeb(c, &udbg_comport->thr); eieio();
238 }
239} 220}
240 221
241static int udbg_44x_as1_getc(void) 222void __init udbg_init_maple_realmode(void)
242{ 223{
243 if (udbg_comport) { 224 udbg_uart_in = udbg_uart_in_maple;
244 while ((as1_readb(&udbg_comport->lsr) & LSR_DR) == 0) 225 udbg_uart_out = udbg_uart_out_maple;
245 ; /* wait for char */ 226 udbg_use_uart();
246 return as1_readb(&udbg_comport->rbr);
247 }
248 return -1;
249} 227}
250 228
251void __init udbg_init_44x_as1(void) 229#endif /* CONFIG_PPC_MAPLE */
252{
253 udbg_comport =
254 (struct NS16550 __iomem *)PPC44x_EARLY_DEBUG_VIRTADDR;
255 230
256 udbg_putc = udbg_44x_as1_putc; 231#ifdef CONFIG_PPC_PASEMI
257 udbg_flush = udbg_44x_as1_flush;
258 udbg_getc = udbg_44x_as1_getc;
259}
260#endif /* CONFIG_PPC_EARLY_DEBUG_44x */
261 232
262#ifdef CONFIG_PPC_EARLY_DEBUG_40x 233#define UDBG_UART_PAS_ADDR ((void __iomem *)0xfcff03f8UL)
263static void udbg_40x_real_flush(void) 234
235static u8 udbg_uart_in_pas(unsigned int reg)
264{ 236{
265 if (udbg_comport) { 237 return real_205_readb(UDBG_UART_PAS_ADDR + reg);
266 while ((real_readb(&udbg_comport->lsr) & LSR_THRE) == 0)
267 /* wait for idle */;
268 }
269} 238}
270 239
271static void udbg_40x_real_putc(char c) 240static void udbg_uart_out_pas(unsigned int reg, u8 val)
272{ 241{
273 if (udbg_comport) { 242 real_205_writeb(val, UDBG_UART_PAS_ADDR + reg);
274 if (c == '\n')
275 udbg_40x_real_putc('\r');
276 udbg_40x_real_flush();
277 real_writeb(c, &udbg_comport->thr); eieio();
278 }
279} 243}
280 244
281static int udbg_40x_real_getc(void) 245void __init udbg_init_pas_realmode(void)
282{ 246{
283 if (udbg_comport) { 247 udbg_uart_in = udbg_uart_in_pas;
284 while ((real_readb(&udbg_comport->lsr) & LSR_DR) == 0) 248 udbg_uart_out = udbg_uart_out_pas;
285 ; /* wait for char */ 249 udbg_use_uart();
286 return real_readb(&udbg_comport->rbr);
287 }
288 return -1;
289} 250}
290 251
291void __init udbg_init_40x_realmode(void) 252#endif /* CONFIG_PPC_PASEMI */
292{ 253
293 udbg_comport = (struct NS16550 __iomem *) 254#ifdef CONFIG_PPC_EARLY_DEBUG_44x
294 CONFIG_PPC_EARLY_DEBUG_40x_PHYSADDR;
295 255
296 udbg_putc = udbg_40x_real_putc; 256#include <platforms/44x/44x.h>
297 udbg_flush = udbg_40x_real_flush; 257
298 udbg_getc = udbg_40x_real_getc; 258static u8 udbg_uart_in_44x_as1(unsigned int reg)
299 udbg_getc_poll = NULL; 259{
260 return as1_readb((void __iomem *)PPC44x_EARLY_DEBUG_VIRTADDR + reg);
300} 261}
301#endif /* CONFIG_PPC_EARLY_DEBUG_40x */
302 262
303#ifdef CONFIG_PPC_EARLY_DEBUG_WSP 263static void udbg_uart_out_44x_as1(unsigned int reg, u8 val)
304static void udbg_wsp_flush(void)
305{ 264{
306 if (udbg_comport) { 265 as1_writeb(val, (void __iomem *)PPC44x_EARLY_DEBUG_VIRTADDR + reg);
307 while ((readb(&udbg_comport->lsr) & LSR_THRE) == 0)
308 /* wait for idle */;
309 }
310} 266}
311 267
312static void udbg_wsp_putc(char c) 268void __init udbg_init_44x_as1(void)
313{ 269{
314 if (udbg_comport) { 270 udbg_uart_in = udbg_uart_in_44x_as1;
315 if (c == '\n') 271 udbg_uart_out = udbg_uart_out_44x_as1;
316 udbg_wsp_putc('\r'); 272 udbg_use_uart();
317 udbg_wsp_flush();
318 writeb(c, &udbg_comport->thr); eieio();
319 }
320} 273}
321 274
322static int udbg_wsp_getc(void) 275#endif /* CONFIG_PPC_EARLY_DEBUG_44x */
276
277#ifdef CONFIG_PPC_EARLY_DEBUG_40x
278
279static u8 udbg_uart_in_40x(unsigned int reg)
323{ 280{
324 if (udbg_comport) { 281 return real_readb((void __iomem *)CONFIG_PPC_EARLY_DEBUG_40x_PHYSADDR
325 while ((readb(&udbg_comport->lsr) & LSR_DR) == 0) 282 + reg);
326 ; /* wait for char */
327 return readb(&udbg_comport->rbr);
328 }
329 return -1;
330} 283}
331 284
332static int udbg_wsp_getc_poll(void) 285static void udbg_uart_out_40x(unsigned int reg, u8 val)
333{ 286{
334 if (udbg_comport) 287 real_writeb(val, (void __iomem *)CONFIG_PPC_EARLY_DEBUG_40x_PHYSADDR
335 if (readb(&udbg_comport->lsr) & LSR_DR) 288 + reg);
336 return readb(&udbg_comport->rbr);
337 return -1;
338} 289}
339 290
340void __init udbg_init_wsp(void) 291void __init udbg_init_40x_realmode(void)
341{ 292{
342 udbg_comport = (struct NS16550 __iomem *)WSP_UART_VIRT; 293 udbg_uart_in = udbg_uart_in_40x;
294 udbg_uart_out = udbg_uart_out_40x;
295 udbg_use_uart();
296}
343 297
344 udbg_init_uart(udbg_comport, 57600, 50000000); 298#endif /* CONFIG_PPC_EARLY_DEBUG_40x */
299
300
301#ifdef CONFIG_PPC_EARLY_DEBUG_WSP
345 302
346 udbg_putc = udbg_wsp_putc; 303void __init udbg_init_wsp(void)
347 udbg_flush = udbg_wsp_flush; 304{
348 udbg_getc = udbg_wsp_getc; 305 udbg_uart_init_mmio((void *)WSP_UART_VIRT, 1);
349 udbg_getc_poll = udbg_wsp_getc_poll; 306 udbg_uart_setup(57600, 50000000);
350} 307}
308
351#endif /* CONFIG_PPC_EARLY_DEBUG_WSP */ 309#endif /* CONFIG_PPC_EARLY_DEBUG_WSP */
diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S
index 27e2f623210b..6b1f2a6d5517 100644
--- a/arch/powerpc/kernel/vdso32/gettimeofday.S
+++ b/arch/powerpc/kernel/vdso32/gettimeofday.S
@@ -232,9 +232,9 @@ __do_get_tspec:
232 lwz r6,(CFG_TB_ORIG_STAMP+4)(r9) 232 lwz r6,(CFG_TB_ORIG_STAMP+4)(r9)
233 233
234 /* Get a stable TB value */ 234 /* Get a stable TB value */
2352: mftbu r3 2352: mfspr r3, SPRN_TBRU
236 mftbl r4 236 mfspr r4, SPRN_TBRL
237 mftbu r0 237 mfspr r0, SPRN_TBRU
238 cmplw cr0,r3,r0 238 cmplw cr0,r3,r0
239 bne- 2b 239 bne- 2b
240 240
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 536016d792ba..78a350670de3 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -1153,7 +1153,7 @@ EXPORT_SYMBOL(vio_h_cop_sync);
1153 1153
1154static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev) 1154static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev)
1155{ 1155{
1156 const unsigned char *dma_window; 1156 const __be32 *dma_window;
1157 struct iommu_table *tbl; 1157 struct iommu_table *tbl;
1158 unsigned long offset, size; 1158 unsigned long offset, size;
1159 1159
@@ -1312,8 +1312,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
1312{ 1312{
1313 struct vio_dev *viodev; 1313 struct vio_dev *viodev;
1314 struct device_node *parent_node; 1314 struct device_node *parent_node;
1315 const unsigned int *unit_address; 1315 const __be32 *prop;
1316 const unsigned int *pfo_resid = NULL;
1317 enum vio_dev_family family; 1316 enum vio_dev_family family;
1318 const char *of_node_name = of_node->name ? of_node->name : "<unknown>"; 1317 const char *of_node_name = of_node->name ? of_node->name : "<unknown>";
1319 1318
@@ -1360,6 +1359,8 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
1360 /* we need the 'device_type' property, in order to match with drivers */ 1359 /* we need the 'device_type' property, in order to match with drivers */
1361 viodev->family = family; 1360 viodev->family = family;
1362 if (viodev->family == VDEVICE) { 1361 if (viodev->family == VDEVICE) {
1362 unsigned int unit_address;
1363
1363 if (of_node->type != NULL) 1364 if (of_node->type != NULL)
1364 viodev->type = of_node->type; 1365 viodev->type = of_node->type;
1365 else { 1366 else {
@@ -1368,24 +1369,24 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
1368 goto out; 1369 goto out;
1369 } 1370 }
1370 1371
1371 unit_address = of_get_property(of_node, "reg", NULL); 1372 prop = of_get_property(of_node, "reg", NULL);
1372 if (unit_address == NULL) { 1373 if (prop == NULL) {
1373 pr_warn("%s: node %s missing 'reg'\n", 1374 pr_warn("%s: node %s missing 'reg'\n",
1374 __func__, of_node_name); 1375 __func__, of_node_name);
1375 goto out; 1376 goto out;
1376 } 1377 }
1377 dev_set_name(&viodev->dev, "%x", *unit_address); 1378 unit_address = of_read_number(prop, 1);
1379 dev_set_name(&viodev->dev, "%x", unit_address);
1378 viodev->irq = irq_of_parse_and_map(of_node, 0); 1380 viodev->irq = irq_of_parse_and_map(of_node, 0);
1379 viodev->unit_address = *unit_address; 1381 viodev->unit_address = unit_address;
1380 } else { 1382 } else {
1381 /* PFO devices need their resource_id for submitting COP_OPs 1383 /* PFO devices need their resource_id for submitting COP_OPs
1382 * This is an optional field for devices, but is required when 1384 * This is an optional field for devices, but is required when
1383 * performing synchronous ops */ 1385 * performing synchronous ops */
1384 pfo_resid = of_get_property(of_node, "ibm,resource-id", NULL); 1386 prop = of_get_property(of_node, "ibm,resource-id", NULL);
1385 if (pfo_resid != NULL) 1387 if (prop != NULL)
1386 viodev->resource_id = *pfo_resid; 1388 viodev->resource_id = of_read_number(prop, 1);
1387 1389
1388 unit_address = NULL;
1389 dev_set_name(&viodev->dev, "%s", of_node_name); 1390 dev_set_name(&viodev->dev, "%s", of_node_name);
1390 viodev->type = of_node_name; 1391 viodev->type = of_node_name;
1391 viodev->irq = 0; 1392 viodev->irq = 0;
@@ -1622,7 +1623,6 @@ static struct vio_dev *vio_find_name(const char *name)
1622 */ 1623 */
1623struct vio_dev *vio_find_node(struct device_node *vnode) 1624struct vio_dev *vio_find_node(struct device_node *vnode)
1624{ 1625{
1625 const uint32_t *unit_address;
1626 char kobj_name[20]; 1626 char kobj_name[20];
1627 struct device_node *vnode_parent; 1627 struct device_node *vnode_parent;
1628 const char *dev_type; 1628 const char *dev_type;
@@ -1638,10 +1638,13 @@ struct vio_dev *vio_find_node(struct device_node *vnode)
1638 1638
1639 /* construct the kobject name from the device node */ 1639 /* construct the kobject name from the device node */
1640 if (!strcmp(dev_type, "vdevice")) { 1640 if (!strcmp(dev_type, "vdevice")) {
1641 unit_address = of_get_property(vnode, "reg", NULL); 1641 const __be32 *prop;
1642 if (!unit_address) 1642
1643 prop = of_get_property(vnode, "reg", NULL);
1644 if (!prop)
1643 return NULL; 1645 return NULL;
1644 snprintf(kobj_name, sizeof(kobj_name), "%x", *unit_address); 1646 snprintf(kobj_name, sizeof(kobj_name), "%x",
1647 (uint32_t)of_read_number(prop, 1));
1645 } else if (!strcmp(dev_type, "ibm,platform-facilities")) 1648 } else if (!strcmp(dev_type, "ibm,platform-facilities"))
1646 snprintf(kobj_name, sizeof(kobj_name), "%s", vnode->name); 1649 snprintf(kobj_name, sizeof(kobj_name), "%s", vnode->name);
1647 else 1650 else
diff --git a/arch/powerpc/kvm/book3s_64_slb.S b/arch/powerpc/kvm/book3s_64_slb.S
index 4f0caecc0f9d..4f12e8f0c718 100644
--- a/arch/powerpc/kvm/book3s_64_slb.S
+++ b/arch/powerpc/kvm/book3s_64_slb.S
@@ -17,6 +17,10 @@
17 * Authors: Alexander Graf <agraf@suse.de> 17 * Authors: Alexander Graf <agraf@suse.de>
18 */ 18 */
19 19
20#ifdef __LITTLE_ENDIAN__
21#error Need to fix SLB shadow accesses in little endian mode
22#endif
23
20#define SHADOW_SLB_ESID(num) (SLBSHADOW_SAVEAREA + (num * 0x10)) 24#define SHADOW_SLB_ESID(num) (SLBSHADOW_SAVEAREA + (num * 0x10))
21#define SHADOW_SLB_VSID(num) (SLBSHADOW_SAVEAREA + (num * 0x10) + 0x8) 25#define SHADOW_SLB_VSID(num) (SLBSHADOW_SAVEAREA + (num * 0x10) + 0x8)
22#define UNBOLT_SLB_ENTRY(num) \ 26#define UNBOLT_SLB_ENTRY(num) \
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index b0ee3bc9ca76..62a2b5ab08ed 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -217,7 +217,7 @@ struct kvm_vcpu *kvmppc_find_vcpu(struct kvm *kvm, int id)
217 217
218static void init_vpa(struct kvm_vcpu *vcpu, struct lppaca *vpa) 218static void init_vpa(struct kvm_vcpu *vcpu, struct lppaca *vpa)
219{ 219{
220 vpa->shared_proc = 1; 220 vpa->__old_status |= LPPACA_OLD_SHARED_PROC;
221 vpa->yield_count = 1; 221 vpa->yield_count = 1;
222} 222}
223 223
diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
index 45e30d6e462b..9c515440ad1a 100644
--- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
+++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
@@ -363,7 +363,11 @@ long kvmppc_h_enter(struct kvm_vcpu *vcpu, unsigned long flags,
363 vcpu->arch.pgdir, true, &vcpu->arch.gpr[4]); 363 vcpu->arch.pgdir, true, &vcpu->arch.gpr[4]);
364} 364}
365 365
366#ifdef __BIG_ENDIAN__
366#define LOCK_TOKEN (*(u32 *)(&get_paca()->lock_token)) 367#define LOCK_TOKEN (*(u32 *)(&get_paca()->lock_token))
368#else
369#define LOCK_TOKEN (*(u32 *)(&get_paca()->paca_index))
370#endif
367 371
368static inline int try_lock_tlbie(unsigned int *lock) 372static inline int try_lock_tlbie(unsigned int *lock)
369{ 373{
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index 60dce5bfab3f..294b7af28cdd 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -29,6 +29,10 @@
29#include <asm/kvm_book3s_asm.h> 29#include <asm/kvm_book3s_asm.h>
30#include <asm/mmu-hash64.h> 30#include <asm/mmu-hash64.h>
31 31
32#ifdef __LITTLE_ENDIAN__
33#error Need to fix lppaca and SLB shadow accesses in little endian mode
34#endif
35
32/***************************************************************************** 36/*****************************************************************************
33 * * 37 * *
34 * Real Mode handlers that need to be in the linear mapping * 38 * Real Mode handlers that need to be in the linear mapping *
@@ -389,7 +393,11 @@ toc_tlbie_lock:
389 .tc native_tlbie_lock[TC],native_tlbie_lock 393 .tc native_tlbie_lock[TC],native_tlbie_lock
390 .previous 394 .previous
391 ld r3,toc_tlbie_lock@toc(2) 395 ld r3,toc_tlbie_lock@toc(2)
396#ifdef __BIG_ENDIAN__
392 lwz r8,PACA_LOCK_TOKEN(r13) 397 lwz r8,PACA_LOCK_TOKEN(r13)
398#else
399 lwz r8,PACAPACAINDEX(r13)
400#endif
39324: lwarx r0,0,r3 40124: lwarx r0,0,r3
394 cmpwi r0,0 402 cmpwi r0,0
395 bne 24b 403 bne 24b
@@ -964,7 +972,11 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
96432: ld r4,VCPU_KVM(r9) /* pointer to struct kvm */ 97232: ld r4,VCPU_KVM(r9) /* pointer to struct kvm */
965 973
966 /* Take the guest's tlbie_lock */ 974 /* Take the guest's tlbie_lock */
975#ifdef __BIG_ENDIAN__
967 lwz r8,PACA_LOCK_TOKEN(r13) 976 lwz r8,PACA_LOCK_TOKEN(r13)
977#else
978 lwz r8,PACAPACAINDEX(r13)
979#endif
968 addi r3,r4,KVM_TLBIE_LOCK 980 addi r3,r4,KVM_TLBIE_LOCK
96924: lwarx r0,0,r3 98124: lwarx r0,0,r3
970 cmpwi r0,0 982 cmpwi r0,0
diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
index 2c52ada30775..751cd45f65a0 100644
--- a/arch/powerpc/kvm/emulate.c
+++ b/arch/powerpc/kvm/emulate.c
@@ -30,53 +30,10 @@
30#include <asm/byteorder.h> 30#include <asm/byteorder.h>
31#include <asm/kvm_ppc.h> 31#include <asm/kvm_ppc.h>
32#include <asm/disassemble.h> 32#include <asm/disassemble.h>
33#include <asm/ppc-opcode.h>
33#include "timing.h" 34#include "timing.h"
34#include "trace.h" 35#include "trace.h"
35 36
36#define OP_TRAP 3
37#define OP_TRAP_64 2
38
39#define OP_31_XOP_TRAP 4
40#define OP_31_XOP_LWZX 23
41#define OP_31_XOP_DCBST 54
42#define OP_31_XOP_TRAP_64 68
43#define OP_31_XOP_DCBF 86
44#define OP_31_XOP_LBZX 87
45#define OP_31_XOP_STWX 151
46#define OP_31_XOP_STBX 215
47#define OP_31_XOP_LBZUX 119
48#define OP_31_XOP_STBUX 247
49#define OP_31_XOP_LHZX 279
50#define OP_31_XOP_LHZUX 311
51#define OP_31_XOP_MFSPR 339
52#define OP_31_XOP_LHAX 343
53#define OP_31_XOP_STHX 407
54#define OP_31_XOP_STHUX 439
55#define OP_31_XOP_MTSPR 467
56#define OP_31_XOP_DCBI 470
57#define OP_31_XOP_LWBRX 534
58#define OP_31_XOP_TLBSYNC 566
59#define OP_31_XOP_STWBRX 662
60#define OP_31_XOP_LHBRX 790
61#define OP_31_XOP_STHBRX 918
62
63#define OP_LWZ 32
64#define OP_LD 58
65#define OP_LWZU 33
66#define OP_LBZ 34
67#define OP_LBZU 35
68#define OP_STW 36
69#define OP_STWU 37
70#define OP_STD 62
71#define OP_STB 38
72#define OP_STBU 39
73#define OP_LHZ 40
74#define OP_LHZU 41
75#define OP_LHA 42
76#define OP_LHAU 43
77#define OP_STH 44
78#define OP_STHU 45
79
80void kvmppc_emulate_dec(struct kvm_vcpu *vcpu) 37void kvmppc_emulate_dec(struct kvm_vcpu *vcpu)
81{ 38{
82 unsigned long dec_nsec; 39 unsigned long dec_nsec;
diff --git a/arch/powerpc/lib/locks.c b/arch/powerpc/lib/locks.c
index bb7cfecf2788..0c9c8d7d0734 100644
--- a/arch/powerpc/lib/locks.c
+++ b/arch/powerpc/lib/locks.c
@@ -32,7 +32,7 @@ void __spin_yield(arch_spinlock_t *lock)
32 return; 32 return;
33 holder_cpu = lock_value & 0xffff; 33 holder_cpu = lock_value & 0xffff;
34 BUG_ON(holder_cpu >= NR_CPUS); 34 BUG_ON(holder_cpu >= NR_CPUS);
35 yield_count = lppaca_of(holder_cpu).yield_count; 35 yield_count = be32_to_cpu(lppaca_of(holder_cpu).yield_count);
36 if ((yield_count & 1) == 0) 36 if ((yield_count & 1) == 0)
37 return; /* virtual cpu is currently running */ 37 return; /* virtual cpu is currently running */
38 rmb(); 38 rmb();
@@ -57,7 +57,7 @@ void __rw_yield(arch_rwlock_t *rw)
57 return; /* no write lock at present */ 57 return; /* no write lock at present */
58 holder_cpu = lock_value & 0xffff; 58 holder_cpu = lock_value & 0xffff;
59 BUG_ON(holder_cpu >= NR_CPUS); 59 BUG_ON(holder_cpu >= NR_CPUS);
60 yield_count = lppaca_of(holder_cpu).yield_count; 60 yield_count = be32_to_cpu(lppaca_of(holder_cpu).yield_count);
61 if ((yield_count & 1) == 0) 61 if ((yield_count & 1) == 0)
62 return; /* virtual cpu is currently running */ 62 return; /* virtual cpu is currently running */
63 rmb(); 63 rmb();
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 99c7fc16dc0d..a7ee978fb860 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -100,8 +100,10 @@ static unsigned long __kprobes dform_ea(unsigned int instr, struct pt_regs *regs
100 ea = (signed short) instr; /* sign-extend */ 100 ea = (signed short) instr; /* sign-extend */
101 if (ra) { 101 if (ra) {
102 ea += regs->gpr[ra]; 102 ea += regs->gpr[ra];
103 if (instr & 0x04000000) /* update forms */ 103 if (instr & 0x04000000) { /* update forms */
104 regs->gpr[ra] = ea; 104 if ((instr>>26) != 47) /* stmw is not an update form */
105 regs->gpr[ra] = ea;
106 }
105 } 107 }
106 108
107 return truncate_if_32bit(regs->msr, ea); 109 return truncate_if_32bit(regs->msr, ea);
@@ -279,7 +281,7 @@ static int __kprobes write_mem_unaligned(unsigned long val, unsigned long ea,
279 err = write_mem_aligned(val >> (nb - c) * 8, ea, c); 281 err = write_mem_aligned(val >> (nb - c) * 8, ea, c);
280 if (err) 282 if (err)
281 return err; 283 return err;
282 ++ea; 284 ea += c;
283 } 285 }
284 return 0; 286 return 0;
285} 287}
diff --git a/arch/powerpc/math-emu/Makefile b/arch/powerpc/math-emu/Makefile
index 8d035d2d42a6..1b46ab4f6417 100644
--- a/arch/powerpc/math-emu/Makefile
+++ b/arch/powerpc/math-emu/Makefile
@@ -1,15 +1,15 @@
1 1math-emu-common-objs = math.o fre.o fsqrt.o fsqrts.o frsqrtes.o mtfsf.o mtfsfi.o
2obj-$(CONFIG_MATH_EMULATION) += fabs.o fadd.o fadds.o fcmpo.o fcmpu.o \ 2obj-$(CONFIG_MATH_EMULATION_HW_UNIMPLEMENTED) += $(math-emu-common-objs)
3 fctiw.o fctiwz.o fdiv.o fdivs.o \ 3obj-$(CONFIG_MATH_EMULATION_FULL) += $(math-emu-common-objs) fabs.o fadd.o \
4 fmadd.o fmadds.o fmsub.o fmsubs.o \ 4 fadds.o fcmpo.o fcmpu.o fctiw.o \
5 fmul.o fmuls.o fnabs.o fneg.o \ 5 fctiwz.o fdiv.o fdivs.o fmadd.o \
6 fnmadd.o fnmadds.o fnmsub.o fnmsubs.o \ 6 fmadds.o fmsub.o fmsubs.o fmul.o \
7 fres.o fre.o frsp.o fsel.o lfs.o \ 7 fmuls.o fnabs.o fneg.o fnmadd.o \
8 frsqrte.o frsqrtes.o \ 8 fnmadds.o fnmsub.o fnmsubs.o fres.o \
9 fsqrt.o fsqrts.o fsub.o fsubs.o \ 9 frsp.o fsel.o lfs.o frsqrte.o fsub.o \
10 mcrfs.o mffs.o mtfsb0.o mtfsb1.o \ 10 fsubs.o mcrfs.o mffs.o mtfsb0.o \
11 mtfsf.o mtfsfi.o stfiwx.o stfs.o \ 11 mtfsb1.o stfiwx.o stfs.o math.o \
12 math.o fmr.o lfd.o stfd.o 12 fmr.o lfd.o stfd.o
13 13
14obj-$(CONFIG_SPE) += math_efp.o 14obj-$(CONFIG_SPE) += math_efp.o
15 15
diff --git a/arch/powerpc/math-emu/math.c b/arch/powerpc/math-emu/math.c
index 0328e66e0799..ab151f040502 100644
--- a/arch/powerpc/math-emu/math.c
+++ b/arch/powerpc/math-emu/math.c
@@ -7,12 +7,27 @@
7 7
8#include <asm/uaccess.h> 8#include <asm/uaccess.h>
9#include <asm/reg.h> 9#include <asm/reg.h>
10#include <asm/switch_to.h>
10 11
11#include <asm/sfp-machine.h> 12#include <asm/sfp-machine.h>
12#include <math-emu/double.h> 13#include <math-emu/double.h>
13 14
14#define FLOATFUNC(x) extern int x(void *, void *, void *, void *) 15#define FLOATFUNC(x) extern int x(void *, void *, void *, void *)
15 16
17/* The instructions list which may be not implemented by a hardware FPU */
18FLOATFUNC(fre);
19FLOATFUNC(frsqrtes);
20FLOATFUNC(fsqrt);
21FLOATFUNC(fsqrts);
22FLOATFUNC(mtfsf);
23FLOATFUNC(mtfsfi);
24
25#ifdef CONFIG_MATH_EMULATION_HW_UNIMPLEMENTED
26#undef FLOATFUNC(x)
27#define FLOATFUNC(x) static inline int x(void *op1, void *op2, void *op3, \
28 void *op4) { }
29#endif
30
16FLOATFUNC(fadd); 31FLOATFUNC(fadd);
17FLOATFUNC(fadds); 32FLOATFUNC(fadds);
18FLOATFUNC(fdiv); 33FLOATFUNC(fdiv);
@@ -42,8 +57,6 @@ FLOATFUNC(mcrfs);
42FLOATFUNC(mffs); 57FLOATFUNC(mffs);
43FLOATFUNC(mtfsb0); 58FLOATFUNC(mtfsb0);
44FLOATFUNC(mtfsb1); 59FLOATFUNC(mtfsb1);
45FLOATFUNC(mtfsf);
46FLOATFUNC(mtfsfi);
47 60
48FLOATFUNC(lfd); 61FLOATFUNC(lfd);
49FLOATFUNC(lfs); 62FLOATFUNC(lfs);
@@ -58,13 +71,9 @@ FLOATFUNC(fnabs);
58FLOATFUNC(fneg); 71FLOATFUNC(fneg);
59 72
60/* Optional */ 73/* Optional */
61FLOATFUNC(fre);
62FLOATFUNC(fres); 74FLOATFUNC(fres);
63FLOATFUNC(frsqrte); 75FLOATFUNC(frsqrte);
64FLOATFUNC(frsqrtes);
65FLOATFUNC(fsel); 76FLOATFUNC(fsel);
66FLOATFUNC(fsqrt);
67FLOATFUNC(fsqrts);
68 77
69 78
70#define OP31 0x1f /* 31 */ 79#define OP31 0x1f /* 31 */
@@ -154,7 +163,6 @@ FLOATFUNC(fsqrts);
154#define XEU 15 163#define XEU 15
155#define XFLB 10 164#define XFLB 10
156 165
157#ifdef CONFIG_MATH_EMULATION
158static int 166static int
159record_exception(struct pt_regs *regs, int eflag) 167record_exception(struct pt_regs *regs, int eflag)
160{ 168{
@@ -212,7 +220,6 @@ record_exception(struct pt_regs *regs, int eflag)
212 220
213 return (fpscr & FPSCR_FEX) ? 1 : 0; 221 return (fpscr & FPSCR_FEX) ? 1 : 0;
214} 222}
215#endif /* CONFIG_MATH_EMULATION */
216 223
217int 224int
218do_mathemu(struct pt_regs *regs) 225do_mathemu(struct pt_regs *regs)
@@ -222,56 +229,13 @@ do_mathemu(struct pt_regs *regs)
222 signed short sdisp; 229 signed short sdisp;
223 u32 insn = 0; 230 u32 insn = 0;
224 int idx = 0; 231 int idx = 0;
225#ifdef CONFIG_MATH_EMULATION
226 int (*func)(void *, void *, void *, void *); 232 int (*func)(void *, void *, void *, void *);
227 int type = 0; 233 int type = 0;
228 int eflag, trap; 234 int eflag, trap;
229#endif
230 235
231 if (get_user(insn, (u32 *)pc)) 236 if (get_user(insn, (u32 *)pc))
232 return -EFAULT; 237 return -EFAULT;
233 238
234#ifndef CONFIG_MATH_EMULATION
235 switch (insn >> 26) {
236 case LFD:
237 idx = (insn >> 16) & 0x1f;
238 sdisp = (insn & 0xffff);
239 op0 = (void *)&current->thread.TS_FPR((insn >> 21) & 0x1f);
240 op1 = (void *)((idx ? regs->gpr[idx] : 0) + sdisp);
241 lfd(op0, op1, op2, op3);
242 break;
243 case LFDU:
244 idx = (insn >> 16) & 0x1f;
245 sdisp = (insn & 0xffff);
246 op0 = (void *)&current->thread.TS_FPR((insn >> 21) & 0x1f);
247 op1 = (void *)((idx ? regs->gpr[idx] : 0) + sdisp);
248 lfd(op0, op1, op2, op3);
249 regs->gpr[idx] = (unsigned long)op1;
250 break;
251 case STFD:
252 idx = (insn >> 16) & 0x1f;
253 sdisp = (insn & 0xffff);
254 op0 = (void *)&current->thread.TS_FPR((insn >> 21) & 0x1f);
255 op1 = (void *)((idx ? regs->gpr[idx] : 0) + sdisp);
256 stfd(op0, op1, op2, op3);
257 break;
258 case STFDU:
259 idx = (insn >> 16) & 0x1f;
260 sdisp = (insn & 0xffff);
261 op0 = (void *)&current->thread.TS_FPR((insn >> 21) & 0x1f);
262 op1 = (void *)((idx ? regs->gpr[idx] : 0) + sdisp);
263 stfd(op0, op1, op2, op3);
264 regs->gpr[idx] = (unsigned long)op1;
265 break;
266 case OP63:
267 op0 = (void *)&current->thread.TS_FPR((insn >> 21) & 0x1f);
268 op1 = (void *)&current->thread.TS_FPR((insn >> 11) & 0x1f);
269 fmr(op0, op1, op2, op3);
270 break;
271 default:
272 goto illegal;
273 }
274#else /* CONFIG_MATH_EMULATION */
275 switch (insn >> 26) { 239 switch (insn >> 26) {
276 case LFS: func = lfs; type = D; break; 240 case LFS: func = lfs; type = D; break;
277 case LFSU: func = lfs; type = DU; break; 241 case LFSU: func = lfs; type = DU; break;
@@ -416,21 +380,16 @@ do_mathemu(struct pt_regs *regs)
416 case XE: 380 case XE:
417 idx = (insn >> 16) & 0x1f; 381 idx = (insn >> 16) & 0x1f;
418 op0 = (void *)&current->thread.TS_FPR((insn >> 21) & 0x1f); 382 op0 = (void *)&current->thread.TS_FPR((insn >> 21) & 0x1f);
419 if (!idx) { 383 op1 = (void *)((idx ? regs->gpr[idx] : 0)
420 if (((insn >> 1) & 0x3ff) == STFIWX) 384 + regs->gpr[(insn >> 11) & 0x1f]);
421 op1 = (void *)(regs->gpr[(insn >> 11) & 0x1f]);
422 else
423 goto illegal;
424 } else {
425 op1 = (void *)(regs->gpr[idx] + regs->gpr[(insn >> 11) & 0x1f]);
426 }
427
428 break; 385 break;
429 386
430 case XEU: 387 case XEU:
431 idx = (insn >> 16) & 0x1f; 388 idx = (insn >> 16) & 0x1f;
389 if (!idx)
390 goto illegal;
432 op0 = (void *)&current->thread.TS_FPR((insn >> 21) & 0x1f); 391 op0 = (void *)&current->thread.TS_FPR((insn >> 21) & 0x1f);
433 op1 = (void *)((idx ? regs->gpr[idx] : 0) 392 op1 = (void *)(regs->gpr[idx]
434 + regs->gpr[(insn >> 11) & 0x1f]); 393 + regs->gpr[(insn >> 11) & 0x1f]);
435 break; 394 break;
436 395
@@ -465,6 +424,13 @@ do_mathemu(struct pt_regs *regs)
465 goto illegal; 424 goto illegal;
466 } 425 }
467 426
427 /*
428 * If we support a HW FPU, we need to ensure the FP state
429 * is flushed into the thread_struct before attempting
430 * emulation
431 */
432 flush_fp_to_thread(current);
433
468 eflag = func(op0, op1, op2, op3); 434 eflag = func(op0, op1, op2, op3);
469 435
470 if (insn & 1) { 436 if (insn & 1) {
@@ -485,7 +451,6 @@ do_mathemu(struct pt_regs *regs)
485 default: 451 default:
486 break; 452 break;
487 } 453 }
488#endif /* CONFIG_MATH_EMULATION */
489 454
490 regs->nip += 4; 455 regs->nip += 4;
491 return 0; 456 return 0;
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index 8726779e1409..76d8e7cc7805 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -443,8 +443,12 @@ good_area:
443 regs, address); 443 regs, address);
444#ifdef CONFIG_PPC_SMLPAR 444#ifdef CONFIG_PPC_SMLPAR
445 if (firmware_has_feature(FW_FEATURE_CMO)) { 445 if (firmware_has_feature(FW_FEATURE_CMO)) {
446 u32 page_ins;
447
446 preempt_disable(); 448 preempt_disable();
447 get_lppaca()->page_ins += (1 << PAGE_FACTOR); 449 page_ins = be32_to_cpu(get_lppaca()->page_ins);
450 page_ins += 1 << PAGE_FACTOR;
451 get_lppaca()->page_ins = cpu_to_be32(page_ins);
448 preempt_enable(); 452 preempt_enable();
449 } 453 }
450#endif /* CONFIG_PPC_SMLPAR */ 454#endif /* CONFIG_PPC_SMLPAR */
diff --git a/arch/powerpc/mm/gup.c b/arch/powerpc/mm/gup.c
index 49822d90ea96..6936547018b8 100644
--- a/arch/powerpc/mm/gup.c
+++ b/arch/powerpc/mm/gup.c
@@ -117,8 +117,8 @@ static int gup_pud_range(pgd_t pgd, unsigned long addr, unsigned long end,
117 return 1; 117 return 1;
118} 118}
119 119
120int get_user_pages_fast(unsigned long start, int nr_pages, int write, 120int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
121 struct page **pages) 121 struct page **pages)
122{ 122{
123 struct mm_struct *mm = current->mm; 123 struct mm_struct *mm = current->mm;
124 unsigned long addr, len, end; 124 unsigned long addr, len, end;
@@ -135,7 +135,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
135 135
136 if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ, 136 if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
137 start, len))) 137 start, len)))
138 goto slow_irqon; 138 return 0;
139 139
140 pr_devel(" aligned: %lx .. %lx\n", start, end); 140 pr_devel(" aligned: %lx .. %lx\n", start, end);
141 141
@@ -166,30 +166,35 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
166 (void *)pgd_val(pgd)); 166 (void *)pgd_val(pgd));
167 next = pgd_addr_end(addr, end); 167 next = pgd_addr_end(addr, end);
168 if (pgd_none(pgd)) 168 if (pgd_none(pgd))
169 goto slow; 169 break;
170 if (pgd_huge(pgd)) { 170 if (pgd_huge(pgd)) {
171 if (!gup_hugepte((pte_t *)pgdp, PGDIR_SIZE, addr, next, 171 if (!gup_hugepte((pte_t *)pgdp, PGDIR_SIZE, addr, next,
172 write, pages, &nr)) 172 write, pages, &nr))
173 goto slow; 173 break;
174 } else if (is_hugepd(pgdp)) { 174 } else if (is_hugepd(pgdp)) {
175 if (!gup_hugepd((hugepd_t *)pgdp, PGDIR_SHIFT, 175 if (!gup_hugepd((hugepd_t *)pgdp, PGDIR_SHIFT,
176 addr, next, write, pages, &nr)) 176 addr, next, write, pages, &nr))
177 goto slow; 177 break;
178 } else if (!gup_pud_range(pgd, addr, next, write, pages, &nr)) 178 } else if (!gup_pud_range(pgd, addr, next, write, pages, &nr))
179 goto slow; 179 break;
180 } while (pgdp++, addr = next, addr != end); 180 } while (pgdp++, addr = next, addr != end);
181 181
182 local_irq_enable(); 182 local_irq_enable();
183 183
184 VM_BUG_ON(nr != (end - start) >> PAGE_SHIFT);
185 return nr; 184 return nr;
185}
186 186
187 { 187int get_user_pages_fast(unsigned long start, int nr_pages, int write,
188 int ret; 188 struct page **pages)
189{
190 struct mm_struct *mm = current->mm;
191 int nr, ret;
192
193 start &= PAGE_MASK;
194 nr = __get_user_pages_fast(start, nr_pages, write, pages);
195 ret = nr;
189 196
190slow: 197 if (nr < nr_pages) {
191 local_irq_enable();
192slow_irqon:
193 pr_devel(" slow path ! nr = %d\n", nr); 198 pr_devel(" slow path ! nr = %d\n", nr);
194 199
195 /* Try to get the remaining pages with get_user_pages */ 200 /* Try to get the remaining pages with get_user_pages */
@@ -198,7 +203,7 @@ slow_irqon:
198 203
199 down_read(&mm->mmap_sem); 204 down_read(&mm->mmap_sem);
200 ret = get_user_pages(current, mm, start, 205 ret = get_user_pages(current, mm, start,
201 (end - start) >> PAGE_SHIFT, write, 0, pages, NULL); 206 nr_pages - nr, write, 0, pages, NULL);
202 up_read(&mm->mmap_sem); 207 up_read(&mm->mmap_sem);
203 208
204 /* Have to be a bit careful with return values */ 209 /* Have to be a bit careful with return values */
@@ -208,9 +213,9 @@ slow_irqon:
208 else 213 else
209 ret += nr; 214 ret += nr;
210 } 215 }
211
212 return ret;
213 } 216 }
217
218 return ret;
214} 219}
215 220
216#endif /* __HAVE_ARCH_PTE_SPECIAL */ 221#endif /* __HAVE_ARCH_PTE_SPECIAL */
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 6ecc38bd5b24..bde8b5589755 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -907,7 +907,7 @@ static int subpage_protection(struct mm_struct *mm, unsigned long ea)
907 907
908 if (ea >= spt->maxaddr) 908 if (ea >= spt->maxaddr)
909 return 0; 909 return 0;
910 if (ea < 0x100000000) { 910 if (ea < 0x100000000UL) {
911 /* addresses below 4GB use spt->low_prot */ 911 /* addresses below 4GB use spt->low_prot */
912 sbpm = spt->low_prot; 912 sbpm = spt->low_prot;
913 } else { 913 } else {
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 7f4bea162026..1cf9c5b67f24 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -514,7 +514,7 @@ static int add_system_ram_resources(void)
514 res->name = "System RAM"; 514 res->name = "System RAM";
515 res->start = base; 515 res->start = base;
516 res->end = base + size - 1; 516 res->end = base + size - 1;
517 res->flags = IORESOURCE_MEM; 517 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
518 WARN_ON(request_resource(&iomem_resource, res) < 0); 518 WARN_ON(request_resource(&iomem_resource, res) < 0);
519 } 519 }
520 } 520 }
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 5850798826cd..c916127f10c3 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -58,7 +58,7 @@ static int form1_affinity;
58 58
59#define MAX_DISTANCE_REF_POINTS 4 59#define MAX_DISTANCE_REF_POINTS 4
60static int distance_ref_points_depth; 60static int distance_ref_points_depth;
61static const unsigned int *distance_ref_points; 61static const __be32 *distance_ref_points;
62static int distance_lookup_table[MAX_NUMNODES][MAX_DISTANCE_REF_POINTS]; 62static int distance_lookup_table[MAX_NUMNODES][MAX_DISTANCE_REF_POINTS];
63 63
64/* 64/*
@@ -179,7 +179,7 @@ static void unmap_cpu_from_node(unsigned long cpu)
179#endif /* CONFIG_HOTPLUG_CPU || CONFIG_PPC_SPLPAR */ 179#endif /* CONFIG_HOTPLUG_CPU || CONFIG_PPC_SPLPAR */
180 180
181/* must hold reference to node during call */ 181/* must hold reference to node during call */
182static const int *of_get_associativity(struct device_node *dev) 182static const __be32 *of_get_associativity(struct device_node *dev)
183{ 183{
184 return of_get_property(dev, "ibm,associativity", NULL); 184 return of_get_property(dev, "ibm,associativity", NULL);
185} 185}
@@ -189,9 +189,9 @@ static const int *of_get_associativity(struct device_node *dev)
189 * it exists (the property exists only in kexec/kdump kernels, 189 * it exists (the property exists only in kexec/kdump kernels,
190 * added by kexec-tools) 190 * added by kexec-tools)
191 */ 191 */
192static const u32 *of_get_usable_memory(struct device_node *memory) 192static const __be32 *of_get_usable_memory(struct device_node *memory)
193{ 193{
194 const u32 *prop; 194 const __be32 *prop;
195 u32 len; 195 u32 len;
196 prop = of_get_property(memory, "linux,drconf-usable-memory", &len); 196 prop = of_get_property(memory, "linux,drconf-usable-memory", &len);
197 if (!prop || len < sizeof(unsigned int)) 197 if (!prop || len < sizeof(unsigned int))
@@ -219,7 +219,7 @@ int __node_distance(int a, int b)
219} 219}
220 220
221static void initialize_distance_lookup_table(int nid, 221static void initialize_distance_lookup_table(int nid,
222 const unsigned int *associativity) 222 const __be32 *associativity)
223{ 223{
224 int i; 224 int i;
225 225
@@ -227,29 +227,32 @@ static void initialize_distance_lookup_table(int nid,
227 return; 227 return;
228 228
229 for (i = 0; i < distance_ref_points_depth; i++) { 229 for (i = 0; i < distance_ref_points_depth; i++) {
230 distance_lookup_table[nid][i] = 230 const __be32 *entry;
231 associativity[distance_ref_points[i]]; 231
232 entry = &associativity[be32_to_cpu(distance_ref_points[i])];
233 distance_lookup_table[nid][i] = of_read_number(entry, 1);
232 } 234 }
233} 235}
234 236
235/* Returns nid in the range [0..MAX_NUMNODES-1], or -1 if no useful numa 237/* Returns nid in the range [0..MAX_NUMNODES-1], or -1 if no useful numa
236 * info is found. 238 * info is found.
237 */ 239 */
238static int associativity_to_nid(const unsigned int *associativity) 240static int associativity_to_nid(const __be32 *associativity)
239{ 241{
240 int nid = -1; 242 int nid = -1;
241 243
242 if (min_common_depth == -1) 244 if (min_common_depth == -1)
243 goto out; 245 goto out;
244 246
245 if (associativity[0] >= min_common_depth) 247 if (of_read_number(associativity, 1) >= min_common_depth)
246 nid = associativity[min_common_depth]; 248 nid = of_read_number(&associativity[min_common_depth], 1);
247 249
248 /* POWER4 LPAR uses 0xffff as invalid node */ 250 /* POWER4 LPAR uses 0xffff as invalid node */
249 if (nid == 0xffff || nid >= MAX_NUMNODES) 251 if (nid == 0xffff || nid >= MAX_NUMNODES)
250 nid = -1; 252 nid = -1;
251 253
252 if (nid > 0 && associativity[0] >= distance_ref_points_depth) 254 if (nid > 0 &&
255 of_read_number(associativity, 1) >= distance_ref_points_depth)
253 initialize_distance_lookup_table(nid, associativity); 256 initialize_distance_lookup_table(nid, associativity);
254 257
255out: 258out:
@@ -262,7 +265,7 @@ out:
262static int of_node_to_nid_single(struct device_node *device) 265static int of_node_to_nid_single(struct device_node *device)
263{ 266{
264 int nid = -1; 267 int nid = -1;
265 const unsigned int *tmp; 268 const __be32 *tmp;
266 269
267 tmp = of_get_associativity(device); 270 tmp = of_get_associativity(device);
268 if (tmp) 271 if (tmp)
@@ -334,7 +337,7 @@ static int __init find_min_common_depth(void)
334 } 337 }
335 338
336 if (form1_affinity) { 339 if (form1_affinity) {
337 depth = distance_ref_points[0]; 340 depth = of_read_number(distance_ref_points, 1);
338 } else { 341 } else {
339 if (distance_ref_points_depth < 2) { 342 if (distance_ref_points_depth < 2) {
340 printk(KERN_WARNING "NUMA: " 343 printk(KERN_WARNING "NUMA: "
@@ -342,7 +345,7 @@ static int __init find_min_common_depth(void)
342 goto err; 345 goto err;
343 } 346 }
344 347
345 depth = distance_ref_points[1]; 348 depth = of_read_number(&distance_ref_points[1], 1);
346 } 349 }
347 350
348 /* 351 /*
@@ -376,12 +379,12 @@ static void __init get_n_mem_cells(int *n_addr_cells, int *n_size_cells)
376 of_node_put(memory); 379 of_node_put(memory);
377} 380}
378 381
379static unsigned long read_n_cells(int n, const unsigned int **buf) 382static unsigned long read_n_cells(int n, const __be32 **buf)
380{ 383{
381 unsigned long result = 0; 384 unsigned long result = 0;
382 385
383 while (n--) { 386 while (n--) {
384 result = (result << 32) | **buf; 387 result = (result << 32) | of_read_number(*buf, 1);
385 (*buf)++; 388 (*buf)++;
386 } 389 }
387 return result; 390 return result;
@@ -391,17 +394,17 @@ static unsigned long read_n_cells(int n, const unsigned int **buf)
391 * Read the next memblock list entry from the ibm,dynamic-memory property 394 * Read the next memblock list entry from the ibm,dynamic-memory property
392 * and return the information in the provided of_drconf_cell structure. 395 * and return the information in the provided of_drconf_cell structure.
393 */ 396 */
394static void read_drconf_cell(struct of_drconf_cell *drmem, const u32 **cellp) 397static void read_drconf_cell(struct of_drconf_cell *drmem, const __be32 **cellp)
395{ 398{
396 const u32 *cp; 399 const __be32 *cp;
397 400
398 drmem->base_addr = read_n_cells(n_mem_addr_cells, cellp); 401 drmem->base_addr = read_n_cells(n_mem_addr_cells, cellp);
399 402
400 cp = *cellp; 403 cp = *cellp;
401 drmem->drc_index = cp[0]; 404 drmem->drc_index = of_read_number(cp, 1);
402 drmem->reserved = cp[1]; 405 drmem->reserved = of_read_number(&cp[1], 1);
403 drmem->aa_index = cp[2]; 406 drmem->aa_index = of_read_number(&cp[2], 1);
404 drmem->flags = cp[3]; 407 drmem->flags = of_read_number(&cp[3], 1);
405 408
406 *cellp = cp + 4; 409 *cellp = cp + 4;
407} 410}
@@ -413,16 +416,16 @@ static void read_drconf_cell(struct of_drconf_cell *drmem, const u32 **cellp)
413 * list entries followed by N memblock list entries. Each memblock list entry 416 * list entries followed by N memblock list entries. Each memblock list entry
414 * contains information as laid out in the of_drconf_cell struct above. 417 * contains information as laid out in the of_drconf_cell struct above.
415 */ 418 */
416static int of_get_drconf_memory(struct device_node *memory, const u32 **dm) 419static int of_get_drconf_memory(struct device_node *memory, const __be32 **dm)
417{ 420{
418 const u32 *prop; 421 const __be32 *prop;
419 u32 len, entries; 422 u32 len, entries;
420 423
421 prop = of_get_property(memory, "ibm,dynamic-memory", &len); 424 prop = of_get_property(memory, "ibm,dynamic-memory", &len);
422 if (!prop || len < sizeof(unsigned int)) 425 if (!prop || len < sizeof(unsigned int))
423 return 0; 426 return 0;
424 427
425 entries = *prop++; 428 entries = of_read_number(prop++, 1);
426 429
427 /* Now that we know the number of entries, revalidate the size 430 /* Now that we know the number of entries, revalidate the size
428 * of the property read in to ensure we have everything 431 * of the property read in to ensure we have everything
@@ -440,7 +443,7 @@ static int of_get_drconf_memory(struct device_node *memory, const u32 **dm)
440 */ 443 */
441static u64 of_get_lmb_size(struct device_node *memory) 444static u64 of_get_lmb_size(struct device_node *memory)
442{ 445{
443 const u32 *prop; 446 const __be32 *prop;
444 u32 len; 447 u32 len;
445 448
446 prop = of_get_property(memory, "ibm,lmb-size", &len); 449 prop = of_get_property(memory, "ibm,lmb-size", &len);
@@ -453,7 +456,7 @@ static u64 of_get_lmb_size(struct device_node *memory)
453struct assoc_arrays { 456struct assoc_arrays {
454 u32 n_arrays; 457 u32 n_arrays;
455 u32 array_sz; 458 u32 array_sz;
456 const u32 *arrays; 459 const __be32 *arrays;
457}; 460};
458 461
459/* 462/*
@@ -469,15 +472,15 @@ struct assoc_arrays {
469static int of_get_assoc_arrays(struct device_node *memory, 472static int of_get_assoc_arrays(struct device_node *memory,
470 struct assoc_arrays *aa) 473 struct assoc_arrays *aa)
471{ 474{
472 const u32 *prop; 475 const __be32 *prop;
473 u32 len; 476 u32 len;
474 477
475 prop = of_get_property(memory, "ibm,associativity-lookup-arrays", &len); 478 prop = of_get_property(memory, "ibm,associativity-lookup-arrays", &len);
476 if (!prop || len < 2 * sizeof(unsigned int)) 479 if (!prop || len < 2 * sizeof(unsigned int))
477 return -1; 480 return -1;
478 481
479 aa->n_arrays = *prop++; 482 aa->n_arrays = of_read_number(prop++, 1);
480 aa->array_sz = *prop++; 483 aa->array_sz = of_read_number(prop++, 1);
481 484
482 /* Now that we know the number of arrays and size of each array, 485 /* Now that we know the number of arrays and size of each array,
483 * revalidate the size of the property read in. 486 * revalidate the size of the property read in.
@@ -504,7 +507,7 @@ static int of_drconf_to_nid_single(struct of_drconf_cell *drmem,
504 !(drmem->flags & DRCONF_MEM_AI_INVALID) && 507 !(drmem->flags & DRCONF_MEM_AI_INVALID) &&
505 drmem->aa_index < aa->n_arrays) { 508 drmem->aa_index < aa->n_arrays) {
506 index = drmem->aa_index * aa->array_sz + min_common_depth - 1; 509 index = drmem->aa_index * aa->array_sz + min_common_depth - 1;
507 nid = aa->arrays[index]; 510 nid = of_read_number(&aa->arrays[index], 1);
508 511
509 if (nid == 0xffff || nid >= MAX_NUMNODES) 512 if (nid == 0xffff || nid >= MAX_NUMNODES)
510 nid = default_nid; 513 nid = default_nid;
@@ -595,7 +598,7 @@ static unsigned long __init numa_enforce_memory_limit(unsigned long start,
595 * Reads the counter for a given entry in 598 * Reads the counter for a given entry in
596 * linux,drconf-usable-memory property 599 * linux,drconf-usable-memory property
597 */ 600 */
598static inline int __init read_usm_ranges(const u32 **usm) 601static inline int __init read_usm_ranges(const __be32 **usm)
599{ 602{
600 /* 603 /*
601 * For each lmb in ibm,dynamic-memory a corresponding 604 * For each lmb in ibm,dynamic-memory a corresponding
@@ -612,7 +615,7 @@ static inline int __init read_usm_ranges(const u32 **usm)
612 */ 615 */
613static void __init parse_drconf_memory(struct device_node *memory) 616static void __init parse_drconf_memory(struct device_node *memory)
614{ 617{
615 const u32 *uninitialized_var(dm), *usm; 618 const __be32 *uninitialized_var(dm), *usm;
616 unsigned int n, rc, ranges, is_kexec_kdump = 0; 619 unsigned int n, rc, ranges, is_kexec_kdump = 0;
617 unsigned long lmb_size, base, size, sz; 620 unsigned long lmb_size, base, size, sz;
618 int nid; 621 int nid;
@@ -721,7 +724,7 @@ static int __init parse_numa_properties(void)
721 unsigned long size; 724 unsigned long size;
722 int nid; 725 int nid;
723 int ranges; 726 int ranges;
724 const unsigned int *memcell_buf; 727 const __be32 *memcell_buf;
725 unsigned int len; 728 unsigned int len;
726 729
727 memcell_buf = of_get_property(memory, 730 memcell_buf = of_get_property(memory,
@@ -1106,7 +1109,7 @@ early_param("numa", early_numa);
1106static int hot_add_drconf_scn_to_nid(struct device_node *memory, 1109static int hot_add_drconf_scn_to_nid(struct device_node *memory,
1107 unsigned long scn_addr) 1110 unsigned long scn_addr)
1108{ 1111{
1109 const u32 *dm; 1112 const __be32 *dm;
1110 unsigned int drconf_cell_cnt, rc; 1113 unsigned int drconf_cell_cnt, rc;
1111 unsigned long lmb_size; 1114 unsigned long lmb_size;
1112 struct assoc_arrays aa; 1115 struct assoc_arrays aa;
@@ -1159,7 +1162,7 @@ int hot_add_node_scn_to_nid(unsigned long scn_addr)
1159 for_each_node_by_type(memory, "memory") { 1162 for_each_node_by_type(memory, "memory") {
1160 unsigned long start, size; 1163 unsigned long start, size;
1161 int ranges; 1164 int ranges;
1162 const unsigned int *memcell_buf; 1165 const __be32 *memcell_buf;
1163 unsigned int len; 1166 unsigned int len;
1164 1167
1165 memcell_buf = of_get_property(memory, "reg", &len); 1168 memcell_buf = of_get_property(memory, "reg", &len);
@@ -1232,7 +1235,7 @@ static u64 hot_add_drconf_memory_max(void)
1232 struct device_node *memory = NULL; 1235 struct device_node *memory = NULL;
1233 unsigned int drconf_cell_cnt = 0; 1236 unsigned int drconf_cell_cnt = 0;
1234 u64 lmb_size = 0; 1237 u64 lmb_size = 0;
1235 const u32 *dm = 0; 1238 const __be32 *dm = 0;
1236 1239
1237 memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory"); 1240 memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
1238 if (memory) { 1241 if (memory) {
@@ -1337,40 +1340,41 @@ static int update_cpu_associativity_changes_mask(void)
1337 * Convert the associativity domain numbers returned from the hypervisor 1340 * Convert the associativity domain numbers returned from the hypervisor
1338 * to the sequence they would appear in the ibm,associativity property. 1341 * to the sequence they would appear in the ibm,associativity property.
1339 */ 1342 */
1340static int vphn_unpack_associativity(const long *packed, unsigned int *unpacked) 1343static int vphn_unpack_associativity(const long *packed, __be32 *unpacked)
1341{ 1344{
1342 int i, nr_assoc_doms = 0; 1345 int i, nr_assoc_doms = 0;
1343 const u16 *field = (const u16*) packed; 1346 const __be16 *field = (const __be16 *) packed;
1344 1347
1345#define VPHN_FIELD_UNUSED (0xffff) 1348#define VPHN_FIELD_UNUSED (0xffff)
1346#define VPHN_FIELD_MSB (0x8000) 1349#define VPHN_FIELD_MSB (0x8000)
1347#define VPHN_FIELD_MASK (~VPHN_FIELD_MSB) 1350#define VPHN_FIELD_MASK (~VPHN_FIELD_MSB)
1348 1351
1349 for (i = 1; i < VPHN_ASSOC_BUFSIZE; i++) { 1352 for (i = 1; i < VPHN_ASSOC_BUFSIZE; i++) {
1350 if (*field == VPHN_FIELD_UNUSED) { 1353 if (be16_to_cpup(field) == VPHN_FIELD_UNUSED) {
1351 /* All significant fields processed, and remaining 1354 /* All significant fields processed, and remaining
1352 * fields contain the reserved value of all 1's. 1355 * fields contain the reserved value of all 1's.
1353 * Just store them. 1356 * Just store them.
1354 */ 1357 */
1355 unpacked[i] = *((u32*)field); 1358 unpacked[i] = *((__be32 *)field);
1356 field += 2; 1359 field += 2;
1357 } else if (*field & VPHN_FIELD_MSB) { 1360 } else if (be16_to_cpup(field) & VPHN_FIELD_MSB) {
1358 /* Data is in the lower 15 bits of this field */ 1361 /* Data is in the lower 15 bits of this field */
1359 unpacked[i] = *field & VPHN_FIELD_MASK; 1362 unpacked[i] = cpu_to_be32(
1363 be16_to_cpup(field) & VPHN_FIELD_MASK);
1360 field++; 1364 field++;
1361 nr_assoc_doms++; 1365 nr_assoc_doms++;
1362 } else { 1366 } else {
1363 /* Data is in the lower 15 bits of this field 1367 /* Data is in the lower 15 bits of this field
1364 * concatenated with the next 16 bit field 1368 * concatenated with the next 16 bit field
1365 */ 1369 */
1366 unpacked[i] = *((u32*)field); 1370 unpacked[i] = *((__be32 *)field);
1367 field += 2; 1371 field += 2;
1368 nr_assoc_doms++; 1372 nr_assoc_doms++;
1369 } 1373 }
1370 } 1374 }
1371 1375
1372 /* The first cell contains the length of the property */ 1376 /* The first cell contains the length of the property */
1373 unpacked[0] = nr_assoc_doms; 1377 unpacked[0] = cpu_to_be32(nr_assoc_doms);
1374 1378
1375 return nr_assoc_doms; 1379 return nr_assoc_doms;
1376} 1380}
@@ -1379,7 +1383,7 @@ static int vphn_unpack_associativity(const long *packed, unsigned int *unpacked)
1379 * Retrieve the new associativity information for a virtual processor's 1383 * Retrieve the new associativity information for a virtual processor's
1380 * home node. 1384 * home node.
1381 */ 1385 */
1382static long hcall_vphn(unsigned long cpu, unsigned int *associativity) 1386static long hcall_vphn(unsigned long cpu, __be32 *associativity)
1383{ 1387{
1384 long rc; 1388 long rc;
1385 long retbuf[PLPAR_HCALL9_BUFSIZE] = {0}; 1389 long retbuf[PLPAR_HCALL9_BUFSIZE] = {0};
@@ -1393,7 +1397,7 @@ static long hcall_vphn(unsigned long cpu, unsigned int *associativity)
1393} 1397}
1394 1398
1395static long vphn_get_associativity(unsigned long cpu, 1399static long vphn_get_associativity(unsigned long cpu,
1396 unsigned int *associativity) 1400 __be32 *associativity)
1397{ 1401{
1398 long rc; 1402 long rc;
1399 1403
@@ -1450,7 +1454,7 @@ int arch_update_cpu_topology(void)
1450{ 1454{
1451 unsigned int cpu, sibling, changed = 0; 1455 unsigned int cpu, sibling, changed = 0;
1452 struct topology_update_data *updates, *ud; 1456 struct topology_update_data *updates, *ud;
1453 unsigned int associativity[VPHN_ASSOC_BUFSIZE] = {0}; 1457 __be32 associativity[VPHN_ASSOC_BUFSIZE] = {0};
1454 cpumask_t updated_cpus; 1458 cpumask_t updated_cpus;
1455 struct device *dev; 1459 struct device *dev;
1456 int weight, new_nid, i = 0; 1460 int weight, new_nid, i = 0;
@@ -1609,7 +1613,7 @@ int start_topology_update(void)
1609#endif 1613#endif
1610 } 1614 }
1611 } else if (firmware_has_feature(FW_FEATURE_VPHN) && 1615 } else if (firmware_has_feature(FW_FEATURE_VPHN) &&
1612 get_lppaca()->shared_proc) { 1616 lppaca_shared_proc(get_lppaca())) {
1613 if (!vphn_enabled) { 1617 if (!vphn_enabled) {
1614 prrn_enabled = 0; 1618 prrn_enabled = 0;
1615 vphn_enabled = 1; 1619 vphn_enabled = 1;
diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
index a538c80db2df..9d1d33cd2be5 100644
--- a/arch/powerpc/mm/slb.c
+++ b/arch/powerpc/mm/slb.c
@@ -66,8 +66,10 @@ static inline void slb_shadow_update(unsigned long ea, int ssize,
66 * we only update the current CPU's SLB shadow buffer. 66 * we only update the current CPU's SLB shadow buffer.
67 */ 67 */
68 get_slb_shadow()->save_area[entry].esid = 0; 68 get_slb_shadow()->save_area[entry].esid = 0;
69 get_slb_shadow()->save_area[entry].vsid = mk_vsid_data(ea, ssize, flags); 69 get_slb_shadow()->save_area[entry].vsid =
70 get_slb_shadow()->save_area[entry].esid = mk_esid_data(ea, ssize, entry); 70 cpu_to_be64(mk_vsid_data(ea, ssize, flags));
71 get_slb_shadow()->save_area[entry].esid =
72 cpu_to_be64(mk_esid_data(ea, ssize, entry));
71} 73}
72 74
73static inline void slb_shadow_clear(unsigned long entry) 75static inline void slb_shadow_clear(unsigned long entry)
@@ -112,7 +114,8 @@ static void __slb_flush_and_rebolt(void)
112 } else { 114 } else {
113 /* Update stack entry; others don't change */ 115 /* Update stack entry; others don't change */
114 slb_shadow_update(get_paca()->kstack, mmu_kernel_ssize, lflags, 2); 116 slb_shadow_update(get_paca()->kstack, mmu_kernel_ssize, lflags, 2);
115 ksp_vsid_data = get_slb_shadow()->save_area[2].vsid; 117 ksp_vsid_data =
118 be64_to_cpu(get_slb_shadow()->save_area[2].vsid);
116 } 119 }
117 120
118 /* We need to do this all in asm, so we're sure we don't touch 121 /* We need to do this all in asm, so we're sure we don't touch
diff --git a/arch/powerpc/mm/subpage-prot.c b/arch/powerpc/mm/subpage-prot.c
index aa74acb0fdfc..a770df2dae70 100644
--- a/arch/powerpc/mm/subpage-prot.c
+++ b/arch/powerpc/mm/subpage-prot.c
@@ -105,7 +105,7 @@ static void subpage_prot_clear(unsigned long addr, unsigned long len)
105 limit = spt->maxaddr; 105 limit = spt->maxaddr;
106 for (; addr < limit; addr = next) { 106 for (; addr < limit; addr = next) {
107 next = pmd_addr_end(addr, limit); 107 next = pmd_addr_end(addr, limit);
108 if (addr < 0x100000000) { 108 if (addr < 0x100000000UL) {
109 spm = spt->low_prot; 109 spm = spt->low_prot;
110 } else { 110 } else {
111 spm = spt->protptrs[addr >> SBP_L3_SHIFT]; 111 spm = spt->protptrs[addr >> SBP_L3_SHIFT];
@@ -219,7 +219,7 @@ long sys_subpage_prot(unsigned long addr, unsigned long len, u32 __user *map)
219 for (limit = addr + len; addr < limit; addr = next) { 219 for (limit = addr + len; addr < limit; addr = next) {
220 next = pmd_addr_end(addr, limit); 220 next = pmd_addr_end(addr, limit);
221 err = -ENOMEM; 221 err = -ENOMEM;
222 if (addr < 0x100000000) { 222 if (addr < 0x100000000UL) {
223 spm = spt->low_prot; 223 spm = spt->low_prot;
224 } else { 224 } else {
225 spm = spt->protptrs[addr >> SBP_L3_SHIFT]; 225 spm = spt->protptrs[addr >> SBP_L3_SHIFT];
diff --git a/arch/powerpc/oprofile/op_model_fsl_emb.c b/arch/powerpc/oprofile/op_model_fsl_emb.c
index ccc1daa33aed..2a82d3ed464d 100644
--- a/arch/powerpc/oprofile/op_model_fsl_emb.c
+++ b/arch/powerpc/oprofile/op_model_fsl_emb.c
@@ -46,6 +46,12 @@ static inline u32 get_pmlca(int ctr)
46 case 3: 46 case 3:
47 pmlca = mfpmr(PMRN_PMLCA3); 47 pmlca = mfpmr(PMRN_PMLCA3);
48 break; 48 break;
49 case 4:
50 pmlca = mfpmr(PMRN_PMLCA4);
51 break;
52 case 5:
53 pmlca = mfpmr(PMRN_PMLCA5);
54 break;
49 default: 55 default:
50 panic("Bad ctr number\n"); 56 panic("Bad ctr number\n");
51 } 57 }
@@ -68,6 +74,12 @@ static inline void set_pmlca(int ctr, u32 pmlca)
68 case 3: 74 case 3:
69 mtpmr(PMRN_PMLCA3, pmlca); 75 mtpmr(PMRN_PMLCA3, pmlca);
70 break; 76 break;
77 case 4:
78 mtpmr(PMRN_PMLCA4, pmlca);
79 break;
80 case 5:
81 mtpmr(PMRN_PMLCA5, pmlca);
82 break;
71 default: 83 default:
72 panic("Bad ctr number\n"); 84 panic("Bad ctr number\n");
73 } 85 }
@@ -84,6 +96,10 @@ static inline unsigned int ctr_read(unsigned int i)
84 return mfpmr(PMRN_PMC2); 96 return mfpmr(PMRN_PMC2);
85 case 3: 97 case 3:
86 return mfpmr(PMRN_PMC3); 98 return mfpmr(PMRN_PMC3);
99 case 4:
100 return mfpmr(PMRN_PMC4);
101 case 5:
102 return mfpmr(PMRN_PMC5);
87 default: 103 default:
88 return 0; 104 return 0;
89 } 105 }
@@ -104,6 +120,12 @@ static inline void ctr_write(unsigned int i, unsigned int val)
104 case 3: 120 case 3:
105 mtpmr(PMRN_PMC3, val); 121 mtpmr(PMRN_PMC3, val);
106 break; 122 break;
123 case 4:
124 mtpmr(PMRN_PMC4, val);
125 break;
126 case 5:
127 mtpmr(PMRN_PMC5, val);
128 break;
107 default: 129 default:
108 break; 130 break;
109 } 131 }
@@ -133,6 +155,14 @@ static void init_pmc_stop(int ctr)
133 mtpmr(PMRN_PMLCA3, pmlca); 155 mtpmr(PMRN_PMLCA3, pmlca);
134 mtpmr(PMRN_PMLCB3, pmlcb); 156 mtpmr(PMRN_PMLCB3, pmlcb);
135 break; 157 break;
158 case 4:
159 mtpmr(PMRN_PMLCA4, pmlca);
160 mtpmr(PMRN_PMLCB4, pmlcb);
161 break;
162 case 5:
163 mtpmr(PMRN_PMLCA5, pmlca);
164 mtpmr(PMRN_PMLCB5, pmlcb);
165 break;
136 default: 166 default:
137 panic("Bad ctr number!\n"); 167 panic("Bad ctr number!\n");
138 } 168 }
diff --git a/arch/powerpc/perf/Makefile b/arch/powerpc/perf/Makefile
index 510fae10513d..60d71eea919c 100644
--- a/arch/powerpc/perf/Makefile
+++ b/arch/powerpc/perf/Makefile
@@ -9,7 +9,7 @@ obj64-$(CONFIG_PPC_PERF_CTRS) += power4-pmu.o ppc970-pmu.o power5-pmu.o \
9obj32-$(CONFIG_PPC_PERF_CTRS) += mpc7450-pmu.o 9obj32-$(CONFIG_PPC_PERF_CTRS) += mpc7450-pmu.o
10 10
11obj-$(CONFIG_FSL_EMB_PERF_EVENT) += core-fsl-emb.o 11obj-$(CONFIG_FSL_EMB_PERF_EVENT) += core-fsl-emb.o
12obj-$(CONFIG_FSL_EMB_PERF_EVENT_E500) += e500-pmu.o 12obj-$(CONFIG_FSL_EMB_PERF_EVENT_E500) += e500-pmu.o e6500-pmu.o
13 13
14obj-$(CONFIG_PPC64) += $(obj64-y) 14obj-$(CONFIG_PPC64) += $(obj64-y)
15obj-$(CONFIG_PPC32) += $(obj32-y) 15obj-$(CONFIG_PPC32) += $(obj32-y)
diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index eeae308cf982..29b89e863d7c 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -24,7 +24,7 @@
24#define BHRB_MAX_ENTRIES 32 24#define BHRB_MAX_ENTRIES 32
25#define BHRB_TARGET 0x0000000000000002 25#define BHRB_TARGET 0x0000000000000002
26#define BHRB_PREDICTION 0x0000000000000001 26#define BHRB_PREDICTION 0x0000000000000001
27#define BHRB_EA 0xFFFFFFFFFFFFFFFC 27#define BHRB_EA 0xFFFFFFFFFFFFFFFCUL
28 28
29struct cpu_hw_events { 29struct cpu_hw_events {
30 int n_events; 30 int n_events;
diff --git a/arch/powerpc/perf/core-fsl-emb.c b/arch/powerpc/perf/core-fsl-emb.c
index 106c53354675..d35ae52c69dc 100644
--- a/arch/powerpc/perf/core-fsl-emb.c
+++ b/arch/powerpc/perf/core-fsl-emb.c
@@ -70,6 +70,12 @@ static unsigned long read_pmc(int idx)
70 case 3: 70 case 3:
71 val = mfpmr(PMRN_PMC3); 71 val = mfpmr(PMRN_PMC3);
72 break; 72 break;
73 case 4:
74 val = mfpmr(PMRN_PMC4);
75 break;
76 case 5:
77 val = mfpmr(PMRN_PMC5);
78 break;
73 default: 79 default:
74 printk(KERN_ERR "oops trying to read PMC%d\n", idx); 80 printk(KERN_ERR "oops trying to read PMC%d\n", idx);
75 val = 0; 81 val = 0;
@@ -95,6 +101,12 @@ static void write_pmc(int idx, unsigned long val)
95 case 3: 101 case 3:
96 mtpmr(PMRN_PMC3, val); 102 mtpmr(PMRN_PMC3, val);
97 break; 103 break;
104 case 4:
105 mtpmr(PMRN_PMC4, val);
106 break;
107 case 5:
108 mtpmr(PMRN_PMC5, val);
109 break;
98 default: 110 default:
99 printk(KERN_ERR "oops trying to write PMC%d\n", idx); 111 printk(KERN_ERR "oops trying to write PMC%d\n", idx);
100 } 112 }
@@ -120,6 +132,12 @@ static void write_pmlca(int idx, unsigned long val)
120 case 3: 132 case 3:
121 mtpmr(PMRN_PMLCA3, val); 133 mtpmr(PMRN_PMLCA3, val);
122 break; 134 break;
135 case 4:
136 mtpmr(PMRN_PMLCA4, val);
137 break;
138 case 5:
139 mtpmr(PMRN_PMLCA5, val);
140 break;
123 default: 141 default:
124 printk(KERN_ERR "oops trying to write PMLCA%d\n", idx); 142 printk(KERN_ERR "oops trying to write PMLCA%d\n", idx);
125 } 143 }
@@ -145,6 +163,12 @@ static void write_pmlcb(int idx, unsigned long val)
145 case 3: 163 case 3:
146 mtpmr(PMRN_PMLCB3, val); 164 mtpmr(PMRN_PMLCB3, val);
147 break; 165 break;
166 case 4:
167 mtpmr(PMRN_PMLCB4, val);
168 break;
169 case 5:
170 mtpmr(PMRN_PMLCB5, val);
171 break;
148 default: 172 default:
149 printk(KERN_ERR "oops trying to write PMLCB%d\n", idx); 173 printk(KERN_ERR "oops trying to write PMLCB%d\n", idx);
150 } 174 }
@@ -462,6 +486,12 @@ static int fsl_emb_pmu_event_init(struct perf_event *event)
462 int num_restricted; 486 int num_restricted;
463 int i; 487 int i;
464 488
489 if (ppmu->n_counter > MAX_HWEVENTS) {
490 WARN(1, "No. of perf counters (%d) is higher than max array size(%d)\n",
491 ppmu->n_counter, MAX_HWEVENTS);
492 ppmu->n_counter = MAX_HWEVENTS;
493 }
494
465 switch (event->attr.type) { 495 switch (event->attr.type) {
466 case PERF_TYPE_HARDWARE: 496 case PERF_TYPE_HARDWARE:
467 ev = event->attr.config; 497 ev = event->attr.config;
diff --git a/arch/powerpc/perf/e6500-pmu.c b/arch/powerpc/perf/e6500-pmu.c
new file mode 100644
index 000000000000..3d877aa777b5
--- /dev/null
+++ b/arch/powerpc/perf/e6500-pmu.c
@@ -0,0 +1,121 @@
1/*
2 * Performance counter support for e6500 family processors.
3 *
4 * Author: Priyanka Jain, Priyanka.Jain@freescale.com
5 * Based on e500-pmu.c
6 * Copyright 2013 Freescale Semiconductor, Inc.
7 * Copyright 2008-2009 Paul Mackerras, IBM Corporation.
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 <linux/string.h>
16#include <linux/perf_event.h>
17#include <asm/reg.h>
18#include <asm/cputable.h>
19
20/*
21 * Map of generic hardware event types to hardware events
22 * Zero if unsupported
23 */
24static int e6500_generic_events[] = {
25 [PERF_COUNT_HW_CPU_CYCLES] = 1,
26 [PERF_COUNT_HW_INSTRUCTIONS] = 2,
27 [PERF_COUNT_HW_CACHE_MISSES] = 221,
28 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 12,
29 [PERF_COUNT_HW_BRANCH_MISSES] = 15,
30};
31
32#define C(x) PERF_COUNT_HW_CACHE_##x
33
34/*
35 * Table of generalized cache-related events.
36 * 0 means not supported, -1 means nonsensical, other values
37 * are event codes.
38 */
39static int e6500_cache_events[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
40 [C(L1D)] = {
41 /*RESULT_ACCESS RESULT_MISS */
42 [C(OP_READ)] = { 27, 222 },
43 [C(OP_WRITE)] = { 28, 223 },
44 [C(OP_PREFETCH)] = { 29, 0 },
45 },
46 [C(L1I)] = {
47 /*RESULT_ACCESS RESULT_MISS */
48 [C(OP_READ)] = { 2, 254 },
49 [C(OP_WRITE)] = { -1, -1 },
50 [C(OP_PREFETCH)] = { 37, 0 },
51 },
52 /*
53 * Assuming LL means L2, it's not a good match for this model.
54 * It does not have separate read/write events (but it does have
55 * separate instruction/data events).
56 */
57 [C(LL)] = {
58 /*RESULT_ACCESS RESULT_MISS */
59 [C(OP_READ)] = { 0, 0 },
60 [C(OP_WRITE)] = { 0, 0 },
61 [C(OP_PREFETCH)] = { 0, 0 },
62 },
63 /*
64 * There are data/instruction MMU misses, but that's a miss on
65 * the chip's internal level-one TLB which is probably not
66 * what the user wants. Instead, unified level-two TLB misses
67 * are reported here.
68 */
69 [C(DTLB)] = {
70 /*RESULT_ACCESS RESULT_MISS */
71 [C(OP_READ)] = { 26, 66 },
72 [C(OP_WRITE)] = { -1, -1 },
73 [C(OP_PREFETCH)] = { -1, -1 },
74 },
75 [C(BPU)] = {
76 /*RESULT_ACCESS RESULT_MISS */
77 [C(OP_READ)] = { 12, 15 },
78 [C(OP_WRITE)] = { -1, -1 },
79 [C(OP_PREFETCH)] = { -1, -1 },
80 },
81 [C(NODE)] = {
82 /* RESULT_ACCESS RESULT_MISS */
83 [C(OP_READ)] = { -1, -1 },
84 [C(OP_WRITE)] = { -1, -1 },
85 [C(OP_PREFETCH)] = { -1, -1 },
86 },
87};
88
89static int num_events = 512;
90
91/* Upper half of event id is PMLCb, for threshold events */
92static u64 e6500_xlate_event(u64 event_id)
93{
94 u32 event_low = (u32)event_id;
95 if (event_low >= num_events ||
96 (event_id & (FSL_EMB_EVENT_THRESHMUL | FSL_EMB_EVENT_THRESH)))
97 return 0;
98
99 return FSL_EMB_EVENT_VALID;
100}
101
102static struct fsl_emb_pmu e6500_pmu = {
103 .name = "e6500 family",
104 .n_counter = 6,
105 .n_restricted = 0,
106 .xlate_event = e6500_xlate_event,
107 .n_generic = ARRAY_SIZE(e6500_generic_events),
108 .generic_events = e6500_generic_events,
109 .cache_events = &e6500_cache_events,
110};
111
112static int init_e6500_pmu(void)
113{
114 if (!cur_cpu_spec->oprofile_cpu_type ||
115 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc/e6500"))
116 return -ENODEV;
117
118 return register_fsl_emb_pmu(&e6500_pmu);
119}
120
121early_initcall(init_e6500_pmu);
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_pic.c b/arch/powerpc/platforms/52xx/mpc52xx_pic.c
index b89ef65392dc..b69221ba07fd 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_pic.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_pic.c
@@ -373,8 +373,9 @@ static int mpc52xx_irqhost_map(struct irq_domain *h, unsigned int virq,
373 case MPC52xx_IRQ_L1_PERP: irqchip = &mpc52xx_periph_irqchip; break; 373 case MPC52xx_IRQ_L1_PERP: irqchip = &mpc52xx_periph_irqchip; break;
374 case MPC52xx_IRQ_L1_SDMA: irqchip = &mpc52xx_sdma_irqchip; break; 374 case MPC52xx_IRQ_L1_SDMA: irqchip = &mpc52xx_sdma_irqchip; break;
375 case MPC52xx_IRQ_L1_CRIT: 375 case MPC52xx_IRQ_L1_CRIT:
376 default:
376 pr_warn("%s: Critical IRQ #%d is unsupported! Nopping it.\n", 377 pr_warn("%s: Critical IRQ #%d is unsupported! Nopping it.\n",
377 __func__, l2irq); 378 __func__, l1irq);
378 irq_set_chip(virq, &no_irq_chip); 379 irq_set_chip(virq, &no_irq_chip);
379 return 0; 380 return 0;
380 } 381 }
diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
index efdd37c775ad..de2eb9320993 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -32,6 +32,12 @@ config BSC9131_RDB
32 StarCore SC3850 DSP 32 StarCore SC3850 DSP
33 Manufacturer : Freescale Semiconductor, Inc 33 Manufacturer : Freescale Semiconductor, Inc
34 34
35config C293_PCIE
36 bool "Freescale C293PCIE"
37 select DEFAULT_UIMAGE
38 help
39 This option enables support for the C293PCIE board
40
35config MPC8540_ADS 41config MPC8540_ADS
36 bool "Freescale MPC8540 ADS" 42 bool "Freescale MPC8540 ADS"
37 select DEFAULT_UIMAGE 43 select DEFAULT_UIMAGE
@@ -112,10 +118,10 @@ config P1022_RDK
112 reference board. 118 reference board.
113 119
114config P1023_RDS 120config P1023_RDS
115 bool "Freescale P1023 RDS" 121 bool "Freescale P1023 RDS/RDB"
116 select DEFAULT_UIMAGE 122 select DEFAULT_UIMAGE
117 help 123 help
118 This option enables support for the P1023 RDS board 124 This option enables support for the P1023 RDS and RDB boards
119 125
120config SOCRATES 126config SOCRATES
121 bool "Socrates" 127 bool "Socrates"
diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index 2eab37ea4a9d..53c9f75a6907 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_SMP) += smp.o
6obj-y += common.o 6obj-y += common.o
7 7
8obj-$(CONFIG_BSC9131_RDB) += bsc913x_rdb.o 8obj-$(CONFIG_BSC9131_RDB) += bsc913x_rdb.o
9obj-$(CONFIG_C293_PCIE) += c293pcie.o
9obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o 10obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o
10obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o 11obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o
11obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o 12obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o
diff --git a/arch/powerpc/platforms/85xx/c293pcie.c b/arch/powerpc/platforms/85xx/c293pcie.c
new file mode 100644
index 000000000000..6208e49142bf
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/c293pcie.c
@@ -0,0 +1,75 @@
1/*
2 * C293PCIE Board Setup
3 *
4 * Copyright 2013 Freescale Semiconductor Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/stddef.h>
13#include <linux/kernel.h>
14#include <linux/of_platform.h>
15
16#include <asm/machdep.h>
17#include <asm/udbg.h>
18#include <asm/mpic.h>
19
20#include <sysdev/fsl_soc.h>
21#include <sysdev/fsl_pci.h>
22
23#include "mpc85xx.h"
24
25void __init c293_pcie_pic_init(void)
26{
27 struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
28 MPIC_SINGLE_DEST_CPU, 0, 256, " OpenPIC ");
29
30 BUG_ON(mpic == NULL);
31
32 mpic_init(mpic);
33}
34
35
36/*
37 * Setup the architecture
38 */
39static void __init c293_pcie_setup_arch(void)
40{
41 if (ppc_md.progress)
42 ppc_md.progress("c293_pcie_setup_arch()", 0);
43
44 fsl_pci_assign_primary();
45
46 printk(KERN_INFO "C293 PCIE board from Freescale Semiconductor\n");
47}
48
49machine_arch_initcall(c293_pcie, mpc85xx_common_publish_devices);
50
51/*
52 * Called very early, device-tree isn't unflattened
53 */
54static int __init c293_pcie_probe(void)
55{
56 unsigned long root = of_get_flat_dt_root();
57
58 if (of_flat_dt_is_compatible(root, "fsl,C293PCIE"))
59 return 1;
60 return 0;
61}
62
63define_machine(c293_pcie) {
64 .name = "C293 PCIE",
65 .probe = c293_pcie_probe,
66 .setup_arch = c293_pcie_setup_arch,
67 .init_IRQ = c293_pcie_pic_init,
68#ifdef CONFIG_PCI
69 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
70#endif
71 .get_irq = mpic_get_irq,
72 .restart = fsl_rstcr_restart,
73 .calibrate_decr = generic_calibrate_decr,
74 .progress = udbg_progress,
75};
diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
index c59c617eee93..aa3690bae415 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ b/arch/powerpc/platforms/85xx/corenet_ds.c
@@ -53,12 +53,6 @@ void __init corenet_ds_setup_arch(void)
53{ 53{
54 mpc85xx_smp_init(); 54 mpc85xx_smp_init();
55 55
56#if defined(CONFIG_PCI) && defined(CONFIG_PPC64)
57 pci_devs_phb_init();
58#endif
59
60 fsl_pci_assign_primary();
61
62 swiotlb_detect_4g(); 56 swiotlb_detect_4g();
63 57
64 pr_info("%s board from Freescale Semiconductor\n", ppc_md.name); 58 pr_info("%s board from Freescale Semiconductor\n", ppc_md.name);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
index ede8771d6f02..53b6fb0a3d56 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_rdb.c
@@ -160,6 +160,7 @@ machine_arch_initcall(p2020_rdb_pc, mpc85xx_common_publish_devices);
160machine_arch_initcall(p1020_mbg_pc, mpc85xx_common_publish_devices); 160machine_arch_initcall(p1020_mbg_pc, mpc85xx_common_publish_devices);
161machine_arch_initcall(p1020_rdb, mpc85xx_common_publish_devices); 161machine_arch_initcall(p1020_rdb, mpc85xx_common_publish_devices);
162machine_arch_initcall(p1020_rdb_pc, mpc85xx_common_publish_devices); 162machine_arch_initcall(p1020_rdb_pc, mpc85xx_common_publish_devices);
163machine_arch_initcall(p1020_rdb_pd, mpc85xx_common_publish_devices);
163machine_arch_initcall(p1020_utm_pc, mpc85xx_common_publish_devices); 164machine_arch_initcall(p1020_utm_pc, mpc85xx_common_publish_devices);
164machine_arch_initcall(p1021_rdb_pc, mpc85xx_common_publish_devices); 165machine_arch_initcall(p1021_rdb_pc, mpc85xx_common_publish_devices);
165machine_arch_initcall(p1025_rdb, mpc85xx_common_publish_devices); 166machine_arch_initcall(p1025_rdb, mpc85xx_common_publish_devices);
@@ -193,6 +194,13 @@ static int __init p1020_rdb_pc_probe(void)
193 return of_flat_dt_is_compatible(root, "fsl,P1020RDB-PC"); 194 return of_flat_dt_is_compatible(root, "fsl,P1020RDB-PC");
194} 195}
195 196
197static int __init p1020_rdb_pd_probe(void)
198{
199 unsigned long root = of_get_flat_dt_root();
200
201 return of_flat_dt_is_compatible(root, "fsl,P1020RDB-PD");
202}
203
196static int __init p1021_rdb_pc_probe(void) 204static int __init p1021_rdb_pc_probe(void)
197{ 205{
198 unsigned long root = of_get_flat_dt_root(); 206 unsigned long root = of_get_flat_dt_root();
@@ -351,6 +359,20 @@ define_machine(p1020_rdb_pc) {
351 .progress = udbg_progress, 359 .progress = udbg_progress,
352}; 360};
353 361
362define_machine(p1020_rdb_pd) {
363 .name = "P1020RDB-PD",
364 .probe = p1020_rdb_pd_probe,
365 .setup_arch = mpc85xx_rdb_setup_arch,
366 .init_IRQ = mpc85xx_rdb_pic_init,
367#ifdef CONFIG_PCI
368 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
369#endif
370 .get_irq = mpic_get_irq,
371 .restart = fsl_rstcr_restart,
372 .calibrate_decr = generic_calibrate_decr,
373 .progress = udbg_progress,
374};
375
354define_machine(p1024_rdb) { 376define_machine(p1024_rdb) {
355 .name = "P1024 RDB", 377 .name = "P1024 RDB",
356 .probe = p1024_rdb_probe, 378 .probe = p1024_rdb_probe,
diff --git a/arch/powerpc/platforms/85xx/p1023_rds.c b/arch/powerpc/platforms/85xx/p1023_rds.c
index 9cc60a738834..2ae9d490c3d9 100644
--- a/arch/powerpc/platforms/85xx/p1023_rds.c
+++ b/arch/powerpc/platforms/85xx/p1023_rds.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright 2010-2011 Freescale Semiconductor, Inc. 2 * Copyright 2010-2011, 2013 Freescale Semiconductor, Inc.
3 * 3 *
4 * Author: Roy Zang <tie-fei.zang@freescale.com> 4 * Author: Roy Zang <tie-fei.zang@freescale.com>
5 * 5 *
@@ -86,6 +86,7 @@ static void __init mpc85xx_rds_setup_arch(void)
86} 86}
87 87
88machine_arch_initcall(p1023_rds, mpc85xx_common_publish_devices); 88machine_arch_initcall(p1023_rds, mpc85xx_common_publish_devices);
89machine_arch_initcall(p1023_rdb, mpc85xx_common_publish_devices);
89 90
90static void __init mpc85xx_rds_pic_init(void) 91static void __init mpc85xx_rds_pic_init(void)
91{ 92{
@@ -106,6 +107,14 @@ static int __init p1023_rds_probe(void)
106 107
107} 108}
108 109
110static int __init p1023_rdb_probe(void)
111{
112 unsigned long root = of_get_flat_dt_root();
113
114 return of_flat_dt_is_compatible(root, "fsl,P1023RDB");
115
116}
117
109define_machine(p1023_rds) { 118define_machine(p1023_rds) {
110 .name = "P1023 RDS", 119 .name = "P1023 RDS",
111 .probe = p1023_rds_probe, 120 .probe = p1023_rds_probe,
@@ -120,3 +129,16 @@ define_machine(p1023_rds) {
120#endif 129#endif
121}; 130};
122 131
132define_machine(p1023_rdb) {
133 .name = "P1023 RDB",
134 .probe = p1023_rdb_probe,
135 .setup_arch = mpc85xx_rds_setup_arch,
136 .init_IRQ = mpc85xx_rds_pic_init,
137 .get_irq = mpic_get_irq,
138 .restart = fsl_rstcr_restart,
139 .calibrate_decr = generic_calibrate_decr,
140 .progress = udbg_progress,
141#ifdef CONFIG_PCI
142 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
143#endif
144};
diff --git a/arch/powerpc/platforms/85xx/smp.c b/arch/powerpc/platforms/85xx/smp.c
index 5ced4f5bb2b2..281b7f01df63 100644
--- a/arch/powerpc/platforms/85xx/smp.c
+++ b/arch/powerpc/platforms/85xx/smp.c
@@ -69,7 +69,32 @@ static void mpc85xx_give_timebase(void)
69 tb_req = 0; 69 tb_req = 0;
70 70
71 mpc85xx_timebase_freeze(1); 71 mpc85xx_timebase_freeze(1);
72#ifdef CONFIG_PPC64
73 /*
74 * e5500/e6500 have a workaround for erratum A-006958 in place
75 * that will reread the timebase until TBL is non-zero.
76 * That would be a bad thing when the timebase is frozen.
77 *
78 * Thus, we read it manually, and instead of checking that
79 * TBL is non-zero, we ensure that TB does not change. We don't
80 * do that for the main mftb implementation, because it requires
81 * a scratch register
82 */
83 {
84 u64 prev;
85
86 asm volatile("mfspr %0, %1" : "=r" (timebase) :
87 "i" (SPRN_TBRL));
88
89 do {
90 prev = timebase;
91 asm volatile("mfspr %0, %1" : "=r" (timebase) :
92 "i" (SPRN_TBRL));
93 } while (prev != timebase);
94 }
95#else
72 timebase = get_tb(); 96 timebase = get_tb();
97#endif
73 mb(); 98 mb();
74 tb_valid = 1; 99 tb_valid = 1;
75 100
@@ -255,6 +280,7 @@ out:
255 280
256struct smp_ops_t smp_85xx_ops = { 281struct smp_ops_t smp_85xx_ops = {
257 .kick_cpu = smp_85xx_kick_cpu, 282 .kick_cpu = smp_85xx_kick_cpu,
283 .cpu_bootable = smp_generic_cpu_bootable,
258#ifdef CONFIG_HOTPLUG_CPU 284#ifdef CONFIG_HOTPLUG_CPU
259 .cpu_disable = generic_cpu_disable, 285 .cpu_disable = generic_cpu_disable,
260 .cpu_die = generic_cpu_die, 286 .cpu_die = generic_cpu_die,
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
index d703775bda30..bf9c6d4cd26c 100644
--- a/arch/powerpc/platforms/Kconfig
+++ b/arch/powerpc/platforms/Kconfig
@@ -202,17 +202,12 @@ config PPC_P7_NAP
202 bool 202 bool
203 default n 203 default n
204 204
205config PPC_INDIRECT_IO
206 bool
207 select GENERIC_IOMAP
208
209config PPC_INDIRECT_PIO 205config PPC_INDIRECT_PIO
210 bool 206 bool
211 select PPC_INDIRECT_IO 207 select GENERIC_IOMAP
212 208
213config PPC_INDIRECT_MMIO 209config PPC_INDIRECT_MMIO
214 bool 210 bool
215 select PPC_INDIRECT_IO
216 211
217config PPC_IO_WORKAROUNDS 212config PPC_IO_WORKAROUNDS
218 bool 213 bool
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index 47d9a03dd415..6704e2e20e6b 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -96,18 +96,31 @@ config GENERIC_CPU
96 96
97config CELL_CPU 97config CELL_CPU
98 bool "Cell Broadband Engine" 98 bool "Cell Broadband Engine"
99 depends on PPC_BOOK3S_64
99 100
100config POWER4_CPU 101config POWER4_CPU
101 bool "POWER4" 102 bool "POWER4"
103 depends on PPC_BOOK3S_64
102 104
103config POWER5_CPU 105config POWER5_CPU
104 bool "POWER5" 106 bool "POWER5"
107 depends on PPC_BOOK3S_64
105 108
106config POWER6_CPU 109config POWER6_CPU
107 bool "POWER6" 110 bool "POWER6"
111 depends on PPC_BOOK3S_64
108 112
109config POWER7_CPU 113config POWER7_CPU
110 bool "POWER7" 114 bool "POWER7"
115 depends on PPC_BOOK3S_64
116
117config E5500_CPU
118 bool "Freescale e5500"
119 depends on E500
120
121config E6500_CPU
122 bool "Freescale e6500"
123 depends on E500
111 124
112endchoice 125endchoice
113 126
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index 946306b1bb4e..b53560660b72 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -697,7 +697,7 @@ static int __init cell_iommu_get_window(struct device_node *np,
697 unsigned long *base, 697 unsigned long *base,
698 unsigned long *size) 698 unsigned long *size)
699{ 699{
700 const void *dma_window; 700 const __be32 *dma_window;
701 unsigned long index; 701 unsigned long index;
702 702
703 /* Use ibm,dma-window if available, else, hard code ! */ 703 /* Use ibm,dma-window if available, else, hard code ! */
diff --git a/arch/powerpc/platforms/cell/smp.c b/arch/powerpc/platforms/cell/smp.c
index f75f6fcac729..90745eaa45fe 100644
--- a/arch/powerpc/platforms/cell/smp.c
+++ b/arch/powerpc/platforms/cell/smp.c
@@ -136,25 +136,12 @@ static int smp_cell_kick_cpu(int nr)
136 return 0; 136 return 0;
137} 137}
138 138
139static int smp_cell_cpu_bootable(unsigned int nr)
140{
141 /* Special case - we inhibit secondary thread startup
142 * during boot if the user requests it. Odd-numbered
143 * cpus are assumed to be secondary threads.
144 */
145 if (system_state == SYSTEM_BOOTING &&
146 cpu_has_feature(CPU_FTR_SMT) &&
147 !smt_enabled_at_boot && cpu_thread_in_core(nr) != 0)
148 return 0;
149
150 return 1;
151}
152static struct smp_ops_t bpa_iic_smp_ops = { 139static struct smp_ops_t bpa_iic_smp_ops = {
153 .message_pass = iic_message_pass, 140 .message_pass = iic_message_pass,
154 .probe = smp_iic_probe, 141 .probe = smp_iic_probe,
155 .kick_cpu = smp_cell_kick_cpu, 142 .kick_cpu = smp_cell_kick_cpu,
156 .setup_cpu = smp_cell_setup_cpu, 143 .setup_cpu = smp_cell_setup_cpu,
157 .cpu_bootable = smp_cell_cpu_bootable, 144 .cpu_bootable = smp_generic_cpu_bootable,
158}; 145};
159 146
160/* This is called very early */ 147/* This is called very early */
diff --git a/arch/powerpc/platforms/powernv/Kconfig b/arch/powerpc/platforms/powernv/Kconfig
index c24684c818ab..6fae5eb99ea6 100644
--- a/arch/powerpc/platforms/powernv/Kconfig
+++ b/arch/powerpc/platforms/powernv/Kconfig
@@ -7,6 +7,8 @@ config PPC_POWERNV
7 select PPC_P7_NAP 7 select PPC_P7_NAP
8 select PPC_PCI_CHOICE if EMBEDDED 8 select PPC_PCI_CHOICE if EMBEDDED
9 select EPAPR_BOOT 9 select EPAPR_BOOT
10 select PPC_INDIRECT_PIO
11 select PPC_UDBG_16550
10 default y 12 default y
11 13
12config POWERNV_MSI 14config POWERNV_MSI
diff --git a/arch/powerpc/platforms/powernv/Makefile b/arch/powerpc/platforms/powernv/Makefile
index 7fe595152478..300c437d713c 100644
--- a/arch/powerpc/platforms/powernv/Makefile
+++ b/arch/powerpc/platforms/powernv/Makefile
@@ -1,5 +1,5 @@
1obj-y += setup.o opal-takeover.o opal-wrappers.o opal.o 1obj-y += setup.o opal-takeover.o opal-wrappers.o opal.o
2obj-y += opal-rtc.o opal-nvram.o 2obj-y += opal-rtc.o opal-nvram.o opal-lpc.o
3 3
4obj-$(CONFIG_SMP) += smp.o 4obj-$(CONFIG_SMP) += smp.o
5obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o pci-ioda.o 5obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o pci-ioda.o
diff --git a/arch/powerpc/platforms/powernv/eeh-ioda.c b/arch/powerpc/platforms/powernv/eeh-ioda.c
index 0cd1c4a71755..cf42e74514fa 100644
--- a/arch/powerpc/platforms/powernv/eeh-ioda.c
+++ b/arch/powerpc/platforms/powernv/eeh-ioda.c
@@ -36,13 +36,6 @@
36#include "powernv.h" 36#include "powernv.h"
37#include "pci.h" 37#include "pci.h"
38 38
39/* Debugging option */
40#ifdef IODA_EEH_DBG_ON
41#define IODA_EEH_DBG(args...) pr_info(args)
42#else
43#define IODA_EEH_DBG(args...)
44#endif
45
46static char *hub_diag = NULL; 39static char *hub_diag = NULL;
47static int ioda_eeh_nb_init = 0; 40static int ioda_eeh_nb_init = 0;
48 41
@@ -823,17 +816,17 @@ static int ioda_eeh_next_error(struct eeh_pe **pe)
823 816
824 /* If OPAL API returns error, we needn't proceed */ 817 /* If OPAL API returns error, we needn't proceed */
825 if (rc != OPAL_SUCCESS) { 818 if (rc != OPAL_SUCCESS) {
826 IODA_EEH_DBG("%s: Invalid return value on " 819 pr_devel("%s: Invalid return value on "
827 "PHB#%x (0x%lx) from opal_pci_next_error", 820 "PHB#%x (0x%lx) from opal_pci_next_error",
828 __func__, hose->global_number, rc); 821 __func__, hose->global_number, rc);
829 continue; 822 continue;
830 } 823 }
831 824
832 /* If the PHB doesn't have error, stop processing */ 825 /* If the PHB doesn't have error, stop processing */
833 if (err_type == OPAL_EEH_NO_ERROR || 826 if (err_type == OPAL_EEH_NO_ERROR ||
834 severity == OPAL_EEH_SEV_NO_ERROR) { 827 severity == OPAL_EEH_SEV_NO_ERROR) {
835 IODA_EEH_DBG("%s: No error found on PHB#%x\n", 828 pr_devel("%s: No error found on PHB#%x\n",
836 __func__, hose->global_number); 829 __func__, hose->global_number);
837 continue; 830 continue;
838 } 831 }
839 832
@@ -842,8 +835,9 @@ static int ioda_eeh_next_error(struct eeh_pe **pe)
842 * highest priority reported upon multiple errors on the 835 * highest priority reported upon multiple errors on the
843 * specific PHB. 836 * specific PHB.
844 */ 837 */
845 IODA_EEH_DBG("%s: Error (%d, %d, %d) on PHB#%x\n", 838 pr_devel("%s: Error (%d, %d, %llu) on PHB#%x\n",
846 err_type, severity, pe_no, hose->global_number); 839 __func__, err_type, severity,
840 frozen_pe_no, hose->global_number);
847 switch (err_type) { 841 switch (err_type) {
848 case OPAL_EEH_IOC_ERROR: 842 case OPAL_EEH_IOC_ERROR:
849 if (severity == OPAL_EEH_SEV_IOC_DEAD) { 843 if (severity == OPAL_EEH_SEV_IOC_DEAD) {
diff --git a/arch/powerpc/platforms/powernv/opal-lpc.c b/arch/powerpc/platforms/powernv/opal-lpc.c
new file mode 100644
index 000000000000..a7614bb14e17
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/opal-lpc.c
@@ -0,0 +1,203 @@
1/*
2 * PowerNV LPC bus handling.
3 *
4 * Copyright 2013 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#include <linux/kernel.h>
13#include <linux/of.h>
14#include <linux/bug.h>
15
16#include <asm/machdep.h>
17#include <asm/firmware.h>
18#include <asm/xics.h>
19#include <asm/opal.h>
20
21static int opal_lpc_chip_id = -1;
22
23static u8 opal_lpc_inb(unsigned long port)
24{
25 int64_t rc;
26 uint32_t data;
27
28 if (opal_lpc_chip_id < 0 || port > 0xffff)
29 return 0xff;
30 rc = opal_lpc_read(opal_lpc_chip_id, OPAL_LPC_IO, port, &data, 1);
31 return rc ? 0xff : data;
32}
33
34static __le16 __opal_lpc_inw(unsigned long port)
35{
36 int64_t rc;
37 uint32_t data;
38
39 if (opal_lpc_chip_id < 0 || port > 0xfffe)
40 return 0xffff;
41 if (port & 1)
42 return (__le16)opal_lpc_inb(port) << 8 | opal_lpc_inb(port + 1);
43 rc = opal_lpc_read(opal_lpc_chip_id, OPAL_LPC_IO, port, &data, 2);
44 return rc ? 0xffff : data;
45}
46static u16 opal_lpc_inw(unsigned long port)
47{
48 return le16_to_cpu(__opal_lpc_inw(port));
49}
50
51static __le32 __opal_lpc_inl(unsigned long port)
52{
53 int64_t rc;
54 uint32_t data;
55
56 if (opal_lpc_chip_id < 0 || port > 0xfffc)
57 return 0xffffffff;
58 if (port & 3)
59 return (__le32)opal_lpc_inb(port ) << 24 |
60 (__le32)opal_lpc_inb(port + 1) << 16 |
61 (__le32)opal_lpc_inb(port + 2) << 8 |
62 opal_lpc_inb(port + 3);
63 rc = opal_lpc_read(opal_lpc_chip_id, OPAL_LPC_IO, port, &data, 4);
64 return rc ? 0xffffffff : data;
65}
66
67static u32 opal_lpc_inl(unsigned long port)
68{
69 return le32_to_cpu(__opal_lpc_inl(port));
70}
71
72static void opal_lpc_outb(u8 val, unsigned long port)
73{
74 if (opal_lpc_chip_id < 0 || port > 0xffff)
75 return;
76 opal_lpc_write(opal_lpc_chip_id, OPAL_LPC_IO, port, val, 1);
77}
78
79static void __opal_lpc_outw(__le16 val, unsigned long port)
80{
81 if (opal_lpc_chip_id < 0 || port > 0xfffe)
82 return;
83 if (port & 1) {
84 opal_lpc_outb(val >> 8, port);
85 opal_lpc_outb(val , port + 1);
86 return;
87 }
88 opal_lpc_write(opal_lpc_chip_id, OPAL_LPC_IO, port, val, 2);
89}
90
91static void opal_lpc_outw(u16 val, unsigned long port)
92{
93 __opal_lpc_outw(cpu_to_le16(val), port);
94}
95
96static void __opal_lpc_outl(__le32 val, unsigned long port)
97{
98 if (opal_lpc_chip_id < 0 || port > 0xfffc)
99 return;
100 if (port & 3) {
101 opal_lpc_outb(val >> 24, port);
102 opal_lpc_outb(val >> 16, port + 1);
103 opal_lpc_outb(val >> 8, port + 2);
104 opal_lpc_outb(val , port + 3);
105 return;
106 }
107 opal_lpc_write(opal_lpc_chip_id, OPAL_LPC_IO, port, val, 4);
108}
109
110static void opal_lpc_outl(u32 val, unsigned long port)
111{
112 __opal_lpc_outl(cpu_to_le32(val), port);
113}
114
115static void opal_lpc_insb(unsigned long p, void *b, unsigned long c)
116{
117 u8 *ptr = b;
118
119 while(c--)
120 *(ptr++) = opal_lpc_inb(p);
121}
122
123static void opal_lpc_insw(unsigned long p, void *b, unsigned long c)
124{
125 __le16 *ptr = b;
126
127 while(c--)
128 *(ptr++) = __opal_lpc_inw(p);
129}
130
131static void opal_lpc_insl(unsigned long p, void *b, unsigned long c)
132{
133 __le32 *ptr = b;
134
135 while(c--)
136 *(ptr++) = __opal_lpc_inl(p);
137}
138
139static void opal_lpc_outsb(unsigned long p, const void *b, unsigned long c)
140{
141 const u8 *ptr = b;
142
143 while(c--)
144 opal_lpc_outb(*(ptr++), p);
145}
146
147static void opal_lpc_outsw(unsigned long p, const void *b, unsigned long c)
148{
149 const __le16 *ptr = b;
150
151 while(c--)
152 __opal_lpc_outw(*(ptr++), p);
153}
154
155static void opal_lpc_outsl(unsigned long p, const void *b, unsigned long c)
156{
157 const __le32 *ptr = b;
158
159 while(c--)
160 __opal_lpc_outl(*(ptr++), p);
161}
162
163static const struct ppc_pci_io opal_lpc_io = {
164 .inb = opal_lpc_inb,
165 .inw = opal_lpc_inw,
166 .inl = opal_lpc_inl,
167 .outb = opal_lpc_outb,
168 .outw = opal_lpc_outw,
169 .outl = opal_lpc_outl,
170 .insb = opal_lpc_insb,
171 .insw = opal_lpc_insw,
172 .insl = opal_lpc_insl,
173 .outsb = opal_lpc_outsb,
174 .outsw = opal_lpc_outsw,
175 .outsl = opal_lpc_outsl,
176};
177
178void opal_lpc_init(void)
179{
180 struct device_node *np;
181
182 /*
183 * Look for a Power8 LPC bus tagged as "primary",
184 * we currently support only one though the OPAL APIs
185 * support any number.
186 */
187 for_each_compatible_node(np, NULL, "ibm,power8-lpc") {
188 if (!of_device_is_available(np))
189 continue;
190 if (!of_get_property(np, "primary", NULL))
191 continue;
192 opal_lpc_chip_id = of_get_ibm_chip_id(np);
193 break;
194 }
195 if (opal_lpc_chip_id < 0)
196 return;
197
198 /* Setup special IO ops */
199 ppc_pci_io = opal_lpc_io;
200 isa_io_special = true;
201
202 pr_info("OPAL: Power8 LPC bus found, chip ID %d\n", opal_lpc_chip_id);
203}
diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S b/arch/powerpc/platforms/powernv/opal-wrappers.S
index e88863ffb135..8f3844535fbb 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -111,3 +111,8 @@ OPAL_CALL(opal_pci_next_error, OPAL_PCI_NEXT_ERROR);
111OPAL_CALL(opal_pci_poll, OPAL_PCI_POLL); 111OPAL_CALL(opal_pci_poll, OPAL_PCI_POLL);
112OPAL_CALL(opal_pci_msi_eoi, OPAL_PCI_MSI_EOI); 112OPAL_CALL(opal_pci_msi_eoi, OPAL_PCI_MSI_EOI);
113OPAL_CALL(opal_pci_get_phb_diag_data2, OPAL_PCI_GET_PHB_DIAG_DATA2); 113OPAL_CALL(opal_pci_get_phb_diag_data2, OPAL_PCI_GET_PHB_DIAG_DATA2);
114OPAL_CALL(opal_xscom_read, OPAL_XSCOM_READ);
115OPAL_CALL(opal_xscom_write, OPAL_XSCOM_WRITE);
116OPAL_CALL(opal_lpc_read, OPAL_LPC_READ);
117OPAL_CALL(opal_lpc_write, OPAL_LPC_WRITE);
118OPAL_CALL(opal_return_cpu, OPAL_RETURN_CPU);
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index 106301fd2fa5..2911abe550f1 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -380,18 +380,20 @@ static int __init opal_init(void)
380 pr_warn("opal: Node not found\n"); 380 pr_warn("opal: Node not found\n");
381 return -ENODEV; 381 return -ENODEV;
382 } 382 }
383
384 /* Register OPAL consoles if any ports */
383 if (firmware_has_feature(FW_FEATURE_OPALv2)) 385 if (firmware_has_feature(FW_FEATURE_OPALv2))
384 consoles = of_find_node_by_path("/ibm,opal/consoles"); 386 consoles = of_find_node_by_path("/ibm,opal/consoles");
385 else 387 else
386 consoles = of_node_get(opal_node); 388 consoles = of_node_get(opal_node);
387 389 if (consoles) {
388 /* Register serial ports */ 390 for_each_child_of_node(consoles, np) {
389 for_each_child_of_node(consoles, np) { 391 if (strcmp(np->name, "serial"))
390 if (strcmp(np->name, "serial")) 392 continue;
391 continue; 393 of_platform_device_create(np, NULL, NULL);
392 of_platform_device_create(np, NULL, NULL); 394 }
395 of_node_put(consoles);
393 } 396 }
394 of_node_put(consoles);
395 397
396 /* Find all OPAL interrupts and request them */ 398 /* Find all OPAL interrupts and request them */
397 irqs = of_get_property(opal_node, "opal-interrupts", &irqlen); 399 irqs = of_get_property(opal_node, "opal-interrupts", &irqlen);
@@ -422,7 +424,7 @@ void opal_shutdown(void)
422 424
423 for (i = 0; i < opal_irq_count; i++) { 425 for (i = 0; i < opal_irq_count; i++) {
424 if (opal_irqs[i]) 426 if (opal_irqs[i])
425 free_irq(opal_irqs[i], 0); 427 free_irq(opal_irqs[i], NULL);
426 opal_irqs[i] = 0; 428 opal_irqs[i] = 0;
427 } 429 }
428} 430}
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index d8140b125e62..74a5a5773b1f 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1104,16 +1104,16 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np,
1104 u64 hub_id, int ioda_type) 1104 u64 hub_id, int ioda_type)
1105{ 1105{
1106 struct pci_controller *hose; 1106 struct pci_controller *hose;
1107 static int primary = 1;
1108 struct pnv_phb *phb; 1107 struct pnv_phb *phb;
1109 unsigned long size, m32map_off, iomap_off, pemap_off; 1108 unsigned long size, m32map_off, iomap_off, pemap_off;
1110 const u64 *prop64; 1109 const u64 *prop64;
1111 const u32 *prop32; 1110 const u32 *prop32;
1111 int len;
1112 u64 phb_id; 1112 u64 phb_id;
1113 void *aux; 1113 void *aux;
1114 long rc; 1114 long rc;
1115 1115
1116 pr_info(" Initializing IODA%d OPAL PHB %s\n", ioda_type, np->full_name); 1116 pr_info("Initializing IODA%d OPAL PHB %s\n", ioda_type, np->full_name);
1117 1117
1118 prop64 = of_get_property(np, "ibm,opal-phbid", NULL); 1118 prop64 = of_get_property(np, "ibm,opal-phbid", NULL);
1119 if (!prop64) { 1119 if (!prop64) {
@@ -1124,20 +1124,31 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np,
1124 pr_debug(" PHB-ID : 0x%016llx\n", phb_id); 1124 pr_debug(" PHB-ID : 0x%016llx\n", phb_id);
1125 1125
1126 phb = alloc_bootmem(sizeof(struct pnv_phb)); 1126 phb = alloc_bootmem(sizeof(struct pnv_phb));
1127 if (phb) { 1127 if (!phb) {
1128 memset(phb, 0, sizeof(struct pnv_phb)); 1128 pr_err(" Out of memory !\n");
1129 phb->hose = hose = pcibios_alloc_controller(np); 1129 return;
1130 } 1130 }
1131 if (!phb || !phb->hose) { 1131
1132 pr_err("PCI: Failed to allocate PCI controller for %s\n", 1132 /* Allocate PCI controller */
1133 memset(phb, 0, sizeof(struct pnv_phb));
1134 phb->hose = hose = pcibios_alloc_controller(np);
1135 if (!phb->hose) {
1136 pr_err(" Can't allocate PCI controller for %s\n",
1133 np->full_name); 1137 np->full_name);
1138 free_bootmem((unsigned long)phb, sizeof(struct pnv_phb));
1134 return; 1139 return;
1135 } 1140 }
1136 1141
1137 spin_lock_init(&phb->lock); 1142 spin_lock_init(&phb->lock);
1138 /* XXX Use device-tree */ 1143 prop32 = of_get_property(np, "bus-range", &len);
1139 hose->first_busno = 0; 1144 if (prop32 && len == 8) {
1140 hose->last_busno = 0xff; 1145 hose->first_busno = prop32[0];
1146 hose->last_busno = prop32[1];
1147 } else {
1148 pr_warn(" Broken <bus-range> on %s\n", np->full_name);
1149 hose->first_busno = 0;
1150 hose->last_busno = 0xff;
1151 }
1141 hose->private_data = phb; 1152 hose->private_data = phb;
1142 phb->hub_id = hub_id; 1153 phb->hub_id = hub_id;
1143 phb->opal_id = phb_id; 1154 phb->opal_id = phb_id;
@@ -1152,8 +1163,7 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np,
1152 phb->model = PNV_PHB_MODEL_UNKNOWN; 1163 phb->model = PNV_PHB_MODEL_UNKNOWN;
1153 1164
1154 /* Parse 32-bit and IO ranges (if any) */ 1165 /* Parse 32-bit and IO ranges (if any) */
1155 pci_process_bridge_OF_ranges(phb->hose, np, primary); 1166 pci_process_bridge_OF_ranges(hose, np, !hose->global_number);
1156 primary = 0;
1157 1167
1158 /* Get registers */ 1168 /* Get registers */
1159 phb->regs = of_iomap(np, 0); 1169 phb->regs = of_iomap(np, 0);
@@ -1177,22 +1187,23 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np,
1177 phb->ioda.io_segsize = phb->ioda.io_size / phb->ioda.total_pe; 1187 phb->ioda.io_segsize = phb->ioda.io_size / phb->ioda.total_pe;
1178 phb->ioda.io_pci_base = 0; /* XXX calculate this ? */ 1188 phb->ioda.io_pci_base = 0; /* XXX calculate this ? */
1179 1189
1180 /* Allocate aux data & arrays 1190 /* Allocate aux data & arrays. We don't have IO ports on PHB3 */
1181 *
1182 * XXX TODO: Don't allocate io segmap on PHB3
1183 */
1184 size = _ALIGN_UP(phb->ioda.total_pe / 8, sizeof(unsigned long)); 1191 size = _ALIGN_UP(phb->ioda.total_pe / 8, sizeof(unsigned long));
1185 m32map_off = size; 1192 m32map_off = size;
1186 size += phb->ioda.total_pe * sizeof(phb->ioda.m32_segmap[0]); 1193 size += phb->ioda.total_pe * sizeof(phb->ioda.m32_segmap[0]);
1187 iomap_off = size; 1194 iomap_off = size;
1188 size += phb->ioda.total_pe * sizeof(phb->ioda.io_segmap[0]); 1195 if (phb->type == PNV_PHB_IODA1) {
1196 iomap_off = size;
1197 size += phb->ioda.total_pe * sizeof(phb->ioda.io_segmap[0]);
1198 }
1189 pemap_off = size; 1199 pemap_off = size;
1190 size += phb->ioda.total_pe * sizeof(struct pnv_ioda_pe); 1200 size += phb->ioda.total_pe * sizeof(struct pnv_ioda_pe);
1191 aux = alloc_bootmem(size); 1201 aux = alloc_bootmem(size);
1192 memset(aux, 0, size); 1202 memset(aux, 0, size);
1193 phb->ioda.pe_alloc = aux; 1203 phb->ioda.pe_alloc = aux;
1194 phb->ioda.m32_segmap = aux + m32map_off; 1204 phb->ioda.m32_segmap = aux + m32map_off;
1195 phb->ioda.io_segmap = aux + iomap_off; 1205 if (phb->type == PNV_PHB_IODA1)
1206 phb->ioda.io_segmap = aux + iomap_off;
1196 phb->ioda.pe_array = aux + pemap_off; 1207 phb->ioda.pe_array = aux + pemap_off;
1197 set_bit(0, phb->ioda.pe_alloc); 1208 set_bit(0, phb->ioda.pe_alloc);
1198 1209
diff --git a/arch/powerpc/platforms/powernv/powernv.h b/arch/powerpc/platforms/powernv/powernv.h
index a1c6f83fc391..de6819be1f95 100644
--- a/arch/powerpc/platforms/powernv/powernv.h
+++ b/arch/powerpc/platforms/powernv/powernv.h
@@ -15,4 +15,6 @@ static inline void pnv_pci_init(void) { }
15static inline void pnv_pci_shutdown(void) { } 15static inline void pnv_pci_shutdown(void) { }
16#endif 16#endif
17 17
18extern void pnv_lpc_init(void);
19
18#endif /* _POWERNV_H */ 20#endif /* _POWERNV_H */
diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
index 84438af96c05..e239dcfa224c 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -31,6 +31,7 @@
31#include <asm/xics.h> 31#include <asm/xics.h>
32#include <asm/rtas.h> 32#include <asm/rtas.h>
33#include <asm/opal.h> 33#include <asm/opal.h>
34#include <asm/kexec.h>
34 35
35#include "powernv.h" 36#include "powernv.h"
36 37
@@ -54,6 +55,12 @@ static void __init pnv_setup_arch(void)
54 55
55static void __init pnv_init_early(void) 56static void __init pnv_init_early(void)
56{ 57{
58 /*
59 * Initialize the LPC bus now so that legacy serial
60 * ports can be found on it
61 */
62 opal_lpc_init();
63
57#ifdef CONFIG_HVC_OPAL 64#ifdef CONFIG_HVC_OPAL
58 if (firmware_has_feature(FW_FEATURE_OPAL)) 65 if (firmware_has_feature(FW_FEATURE_OPAL))
59 hvc_opal_init_early(); 66 hvc_opal_init_early();
@@ -147,6 +154,16 @@ static void pnv_shutdown(void)
147static void pnv_kexec_cpu_down(int crash_shutdown, int secondary) 154static void pnv_kexec_cpu_down(int crash_shutdown, int secondary)
148{ 155{
149 xics_kexec_teardown_cpu(secondary); 156 xics_kexec_teardown_cpu(secondary);
157
158 /* Return secondary CPUs to firmware on OPAL v3 */
159 if (firmware_has_feature(FW_FEATURE_OPALv3) && secondary) {
160 mb();
161 get_paca()->kexec_state = KEXEC_STATE_REAL_MODE;
162 mb();
163
164 /* Return the CPU to OPAL */
165 opal_return_cpu();
166 }
150} 167}
151#endif /* CONFIG_KEXEC */ 168#endif /* CONFIG_KEXEC */
152 169
diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c
index 89e3857af4e0..908672bdcea6 100644
--- a/arch/powerpc/platforms/powernv/smp.c
+++ b/arch/powerpc/platforms/powernv/smp.c
@@ -46,22 +46,6 @@ static void pnv_smp_setup_cpu(int cpu)
46 xics_setup_cpu(); 46 xics_setup_cpu();
47} 47}
48 48
49static int pnv_smp_cpu_bootable(unsigned int nr)
50{
51 /* Special case - we inhibit secondary thread startup
52 * during boot if the user requests it.
53 */
54 if (system_state == SYSTEM_BOOTING && cpu_has_feature(CPU_FTR_SMT)) {
55 if (!smt_enabled_at_boot && cpu_thread_in_core(nr) != 0)
56 return 0;
57 if (smt_enabled_at_boot
58 && cpu_thread_in_core(nr) >= smt_enabled_at_boot)
59 return 0;
60 }
61
62 return 1;
63}
64
65int pnv_smp_kick_cpu(int nr) 49int pnv_smp_kick_cpu(int nr)
66{ 50{
67 unsigned int pcpu = get_hard_smp_processor_id(nr); 51 unsigned int pcpu = get_hard_smp_processor_id(nr);
@@ -195,7 +179,7 @@ static struct smp_ops_t pnv_smp_ops = {
195 .probe = xics_smp_probe, 179 .probe = xics_smp_probe,
196 .kick_cpu = pnv_smp_kick_cpu, 180 .kick_cpu = pnv_smp_kick_cpu,
197 .setup_cpu = pnv_smp_setup_cpu, 181 .setup_cpu = pnv_smp_setup_cpu,
198 .cpu_bootable = pnv_smp_cpu_bootable, 182 .cpu_bootable = smp_generic_cpu_bootable,
199#ifdef CONFIG_HOTPLUG_CPU 183#ifdef CONFIG_HOTPLUG_CPU
200 .cpu_disable = pnv_smp_cpu_disable, 184 .cpu_disable = pnv_smp_cpu_disable,
201 .cpu_die = generic_cpu_die, 185 .cpu_die = generic_cpu_die,
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile
index 8ae010381316..6c61ec5ee914 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_CMM) += cmm.o
22obj-$(CONFIG_DTL) += dtl.o 22obj-$(CONFIG_DTL) += dtl.o
23obj-$(CONFIG_IO_EVENT_IRQ) += io_event_irq.o 23obj-$(CONFIG_IO_EVENT_IRQ) += io_event_irq.o
24obj-$(CONFIG_PSERIES_IDLE) += processor_idle.o 24obj-$(CONFIG_PSERIES_IDLE) += processor_idle.o
25obj-$(CONFIG_LPARCFG) += lparcfg.o
25 26
26ifeq ($(CONFIG_PPC_PSERIES),y) 27ifeq ($(CONFIG_PPC_PSERIES),y)
27obj-$(CONFIG_SUSPEND) += suspend.o 28obj-$(CONFIG_SUSPEND) += suspend.o
diff --git a/arch/powerpc/platforms/pseries/cmm.c b/arch/powerpc/platforms/pseries/cmm.c
index c638535753df..1e561bef459b 100644
--- a/arch/powerpc/platforms/pseries/cmm.c
+++ b/arch/powerpc/platforms/pseries/cmm.c
@@ -40,8 +40,7 @@
40#include <asm/pgalloc.h> 40#include <asm/pgalloc.h>
41#include <asm/uaccess.h> 41#include <asm/uaccess.h>
42#include <linux/memory.h> 42#include <linux/memory.h>
43 43#include <asm/plpar_wrappers.h>
44#include "plpar_wrappers.h"
45 44
46#define CMM_DRIVER_VERSION "1.0.0" 45#define CMM_DRIVER_VERSION "1.0.0"
47#define CMM_DEFAULT_DELAY 1 46#define CMM_DEFAULT_DELAY 1
diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index a1a7b9a67ffd..7cfdaae1721a 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -63,26 +63,32 @@ static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa)
63 return prop; 63 return prop;
64} 64}
65 65
66static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa) 66static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa,
67 const char *path)
67{ 68{
68 struct device_node *dn; 69 struct device_node *dn;
69 char *name; 70 char *name;
70 71
72 /* If parent node path is "/" advance path to NULL terminator to
73 * prevent double leading slashs in full_name.
74 */
75 if (!path[1])
76 path++;
77
71 dn = kzalloc(sizeof(*dn), GFP_KERNEL); 78 dn = kzalloc(sizeof(*dn), GFP_KERNEL);
72 if (!dn) 79 if (!dn)
73 return NULL; 80 return NULL;
74 81
75 /* The configure connector reported name does not contain a
76 * preceding '/', so we allocate a buffer large enough to
77 * prepend this to the full_name.
78 */
79 name = (char *)ccwa + ccwa->name_offset; 82 name = (char *)ccwa + ccwa->name_offset;
80 dn->full_name = kasprintf(GFP_KERNEL, "/%s", name); 83 dn->full_name = kasprintf(GFP_KERNEL, "%s/%s", path, name);
81 if (!dn->full_name) { 84 if (!dn->full_name) {
82 kfree(dn); 85 kfree(dn);
83 return NULL; 86 return NULL;
84 } 87 }
85 88
89 of_node_set_flag(dn, OF_DYNAMIC);
90 kref_init(&dn->kref);
91
86 return dn; 92 return dn;
87} 93}
88 94
@@ -120,7 +126,8 @@ void dlpar_free_cc_nodes(struct device_node *dn)
120#define CALL_AGAIN -2 126#define CALL_AGAIN -2
121#define ERR_CFG_USE -9003 127#define ERR_CFG_USE -9003
122 128
123struct device_node *dlpar_configure_connector(u32 drc_index) 129struct device_node *dlpar_configure_connector(u32 drc_index,
130 struct device_node *parent)
124{ 131{
125 struct device_node *dn; 132 struct device_node *dn;
126 struct device_node *first_dn = NULL; 133 struct device_node *first_dn = NULL;
@@ -129,6 +136,7 @@ struct device_node *dlpar_configure_connector(u32 drc_index)
129 struct property *last_property = NULL; 136 struct property *last_property = NULL;
130 struct cc_workarea *ccwa; 137 struct cc_workarea *ccwa;
131 char *data_buf; 138 char *data_buf;
139 const char *parent_path = parent->full_name;
132 int cc_token; 140 int cc_token;
133 int rc = -1; 141 int rc = -1;
134 142
@@ -162,7 +170,7 @@ struct device_node *dlpar_configure_connector(u32 drc_index)
162 break; 170 break;
163 171
164 case NEXT_SIBLING: 172 case NEXT_SIBLING:
165 dn = dlpar_parse_cc_node(ccwa); 173 dn = dlpar_parse_cc_node(ccwa, parent_path);
166 if (!dn) 174 if (!dn)
167 goto cc_error; 175 goto cc_error;
168 176
@@ -172,13 +180,17 @@ struct device_node *dlpar_configure_connector(u32 drc_index)
172 break; 180 break;
173 181
174 case NEXT_CHILD: 182 case NEXT_CHILD:
175 dn = dlpar_parse_cc_node(ccwa); 183 if (first_dn)
184 parent_path = last_dn->full_name;
185
186 dn = dlpar_parse_cc_node(ccwa, parent_path);
176 if (!dn) 187 if (!dn)
177 goto cc_error; 188 goto cc_error;
178 189
179 if (!first_dn) 190 if (!first_dn) {
191 dn->parent = parent;
180 first_dn = dn; 192 first_dn = dn;
181 else { 193 } else {
182 dn->parent = last_dn; 194 dn->parent = last_dn;
183 if (last_dn) 195 if (last_dn)
184 last_dn->child = dn; 196 last_dn->child = dn;
@@ -202,6 +214,7 @@ struct device_node *dlpar_configure_connector(u32 drc_index)
202 214
203 case PREV_PARENT: 215 case PREV_PARENT:
204 last_dn = last_dn->parent; 216 last_dn = last_dn->parent;
217 parent_path = last_dn->parent->full_name;
205 break; 218 break;
206 219
207 case CALL_AGAIN: 220 case CALL_AGAIN:
@@ -256,8 +269,6 @@ int dlpar_attach_node(struct device_node *dn)
256{ 269{
257 int rc; 270 int rc;
258 271
259 of_node_set_flag(dn, OF_DYNAMIC);
260 kref_init(&dn->kref);
261 dn->parent = derive_parent(dn->full_name); 272 dn->parent = derive_parent(dn->full_name);
262 if (!dn->parent) 273 if (!dn->parent)
263 return -ENOMEM; 274 return -ENOMEM;
@@ -275,8 +286,15 @@ int dlpar_attach_node(struct device_node *dn)
275 286
276int dlpar_detach_node(struct device_node *dn) 287int dlpar_detach_node(struct device_node *dn)
277{ 288{
289 struct device_node *child;
278 int rc; 290 int rc;
279 291
292 child = of_get_next_child(dn, NULL);
293 while (child) {
294 dlpar_detach_node(child);
295 child = of_get_next_child(dn, child);
296 }
297
280 rc = of_detach_node(dn); 298 rc = of_detach_node(dn);
281 if (rc) 299 if (rc)
282 return rc; 300 return rc;
@@ -382,9 +400,8 @@ out:
382 400
383static ssize_t dlpar_cpu_probe(const char *buf, size_t count) 401static ssize_t dlpar_cpu_probe(const char *buf, size_t count)
384{ 402{
385 struct device_node *dn; 403 struct device_node *dn, *parent;
386 unsigned long drc_index; 404 unsigned long drc_index;
387 char *cpu_name;
388 int rc; 405 int rc;
389 406
390 cpu_hotplug_driver_lock(); 407 cpu_hotplug_driver_lock();
@@ -394,25 +411,19 @@ static ssize_t dlpar_cpu_probe(const char *buf, size_t count)
394 goto out; 411 goto out;
395 } 412 }
396 413
397 dn = dlpar_configure_connector(drc_index); 414 parent = of_find_node_by_path("/cpus");
398 if (!dn) { 415 if (!parent) {
399 rc = -EINVAL; 416 rc = -ENODEV;
400 goto out; 417 goto out;
401 } 418 }
402 419
403 /* configure-connector reports cpus as living in the base 420 dn = dlpar_configure_connector(drc_index, parent);
404 * directory of the device tree. CPUs actually live in the 421 if (!dn) {
405 * cpus directory so we need to fixup the full_name. 422 rc = -EINVAL;
406 */
407 cpu_name = kasprintf(GFP_KERNEL, "/cpus%s", dn->full_name);
408 if (!cpu_name) {
409 dlpar_free_cc_nodes(dn);
410 rc = -ENOMEM;
411 goto out; 423 goto out;
412 } 424 }
413 425
414 kfree(dn->full_name); 426 of_node_put(parent);
415 dn->full_name = cpu_name;
416 427
417 rc = dlpar_acquire_drc(drc_index); 428 rc = dlpar_acquire_drc(drc_index);
418 if (rc) { 429 if (rc) {
diff --git a/arch/powerpc/platforms/pseries/dtl.c b/arch/powerpc/platforms/pseries/dtl.c
index 0cc0ac07a55d..5db66f1fbc26 100644
--- a/arch/powerpc/platforms/pseries/dtl.c
+++ b/arch/powerpc/platforms/pseries/dtl.c
@@ -29,8 +29,7 @@
29#include <asm/firmware.h> 29#include <asm/firmware.h>
30#include <asm/lppaca.h> 30#include <asm/lppaca.h>
31#include <asm/debug.h> 31#include <asm/debug.h>
32 32#include <asm/plpar_wrappers.h>
33#include "plpar_wrappers.h"
34 33
35struct dtl { 34struct dtl {
36 struct dtl_entry *buf; 35 struct dtl_entry *buf;
@@ -87,7 +86,7 @@ static void consume_dtle(struct dtl_entry *dtle, u64 index)
87 barrier(); 86 barrier();
88 87
89 /* check for hypervisor ring buffer overflow, ignore this entry if so */ 88 /* check for hypervisor ring buffer overflow, ignore this entry if so */
90 if (index + N_DISPATCH_LOG < vpa->dtl_idx) 89 if (index + N_DISPATCH_LOG < be64_to_cpu(vpa->dtl_idx))
91 return; 90 return;
92 91
93 ++wp; 92 ++wp;
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index 217ca5c75b20..82789e79e539 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -30,7 +30,8 @@
30#include <asm/machdep.h> 30#include <asm/machdep.h>
31#include <asm/vdso_datapage.h> 31#include <asm/vdso_datapage.h>
32#include <asm/xics.h> 32#include <asm/xics.h>
33#include "plpar_wrappers.h" 33#include <asm/plpar_wrappers.h>
34
34#include "offline_states.h" 35#include "offline_states.h"
35 36
36/* This version can't take the spinlock, because it never returns */ 37/* This version can't take the spinlock, because it never returns */
@@ -123,7 +124,7 @@ static void pseries_mach_cpu_die(void)
123 cede_latency_hint = 2; 124 cede_latency_hint = 2;
124 125
125 get_lppaca()->idle = 1; 126 get_lppaca()->idle = 1;
126 if (!get_lppaca()->shared_proc) 127 if (!lppaca_shared_proc(get_lppaca()))
127 get_lppaca()->donate_dedicated_cpu = 1; 128 get_lppaca()->donate_dedicated_cpu = 1;
128 129
129 while (get_preferred_offline_state(cpu) == CPU_STATE_INACTIVE) { 130 while (get_preferred_offline_state(cpu) == CPU_STATE_INACTIVE) {
@@ -137,7 +138,7 @@ static void pseries_mach_cpu_die(void)
137 138
138 local_irq_disable(); 139 local_irq_disable();
139 140
140 if (!get_lppaca()->shared_proc) 141 if (!lppaca_shared_proc(get_lppaca()))
141 get_lppaca()->donate_dedicated_cpu = 0; 142 get_lppaca()->donate_dedicated_cpu = 0;
142 get_lppaca()->idle = 0; 143 get_lppaca()->idle = 0;
143 144
diff --git a/arch/powerpc/platforms/pseries/hvconsole.c b/arch/powerpc/platforms/pseries/hvconsole.c
index b344f94b0400..849b29b3e9ae 100644
--- a/arch/powerpc/platforms/pseries/hvconsole.c
+++ b/arch/powerpc/platforms/pseries/hvconsole.c
@@ -28,7 +28,7 @@
28#include <linux/errno.h> 28#include <linux/errno.h>
29#include <asm/hvcall.h> 29#include <asm/hvcall.h>
30#include <asm/hvconsole.h> 30#include <asm/hvconsole.h>
31#include "plpar_wrappers.h" 31#include <asm/plpar_wrappers.h>
32 32
33/** 33/**
34 * hvc_get_chars - retrieve characters from firmware for denoted vterm adatper 34 * hvc_get_chars - retrieve characters from firmware for denoted vterm adatper
@@ -40,10 +40,16 @@
40 */ 40 */
41int hvc_get_chars(uint32_t vtermno, char *buf, int count) 41int hvc_get_chars(uint32_t vtermno, char *buf, int count)
42{ 42{
43 unsigned long got; 43 long ret;
44 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
45 unsigned long *lbuf = (unsigned long *)buf;
46
47 ret = plpar_hcall(H_GET_TERM_CHAR, retbuf, vtermno);
48 lbuf[0] = be64_to_cpu(retbuf[1]);
49 lbuf[1] = be64_to_cpu(retbuf[2]);
44 50
45 if (plpar_get_term_char(vtermno, &got, buf) == H_SUCCESS) 51 if (ret == H_SUCCESS)
46 return got; 52 return retbuf[0];
47 53
48 return 0; 54 return 0;
49} 55}
@@ -69,8 +75,9 @@ int hvc_put_chars(uint32_t vtermno, const char *buf, int count)
69 if (count > MAX_VIO_PUT_CHARS) 75 if (count > MAX_VIO_PUT_CHARS)
70 count = MAX_VIO_PUT_CHARS; 76 count = MAX_VIO_PUT_CHARS;
71 77
72 ret = plpar_hcall_norets(H_PUT_TERM_CHAR, vtermno, count, lbuf[0], 78 ret = plpar_hcall_norets(H_PUT_TERM_CHAR, vtermno, count,
73 lbuf[1]); 79 cpu_to_be64(lbuf[0]),
80 cpu_to_be64(lbuf[1]));
74 if (ret == H_SUCCESS) 81 if (ret == H_SUCCESS)
75 return count; 82 return count;
76 if (ret == H_BUSY) 83 if (ret == H_BUSY)
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 23fc1dcf4434..0307901e4132 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -48,8 +48,7 @@
48#include <asm/ppc-pci.h> 48#include <asm/ppc-pci.h>
49#include <asm/udbg.h> 49#include <asm/udbg.h>
50#include <asm/mmzone.h> 50#include <asm/mmzone.h>
51 51#include <asm/plpar_wrappers.h>
52#include "plpar_wrappers.h"
53 52
54 53
55static void tce_invalidate_pSeries_sw(struct iommu_table *tbl, 54static void tce_invalidate_pSeries_sw(struct iommu_table *tbl,
@@ -530,7 +529,7 @@ static void iommu_table_setparms(struct pci_controller *phb,
530static void iommu_table_setparms_lpar(struct pci_controller *phb, 529static void iommu_table_setparms_lpar(struct pci_controller *phb,
531 struct device_node *dn, 530 struct device_node *dn,
532 struct iommu_table *tbl, 531 struct iommu_table *tbl,
533 const void *dma_window) 532 const __be32 *dma_window)
534{ 533{
535 unsigned long offset, size; 534 unsigned long offset, size;
536 535
@@ -630,7 +629,7 @@ static void pci_dma_bus_setup_pSeriesLP(struct pci_bus *bus)
630 struct iommu_table *tbl; 629 struct iommu_table *tbl;
631 struct device_node *dn, *pdn; 630 struct device_node *dn, *pdn;
632 struct pci_dn *ppci; 631 struct pci_dn *ppci;
633 const void *dma_window = NULL; 632 const __be32 *dma_window = NULL;
634 633
635 dn = pci_bus_to_OF_node(bus); 634 dn = pci_bus_to_OF_node(bus);
636 635
@@ -1152,7 +1151,7 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
1152{ 1151{
1153 struct device_node *pdn, *dn; 1152 struct device_node *pdn, *dn;
1154 struct iommu_table *tbl; 1153 struct iommu_table *tbl;
1155 const void *dma_window = NULL; 1154 const __be32 *dma_window = NULL;
1156 struct pci_dn *pci; 1155 struct pci_dn *pci;
1157 1156
1158 pr_debug("pci_dma_dev_setup_pSeriesLP: %s\n", pci_name(dev)); 1157 pr_debug("pci_dma_dev_setup_pSeriesLP: %s\n", pci_name(dev));
@@ -1201,7 +1200,7 @@ static int dma_set_mask_pSeriesLP(struct device *dev, u64 dma_mask)
1201 bool ddw_enabled = false; 1200 bool ddw_enabled = false;
1202 struct device_node *pdn, *dn; 1201 struct device_node *pdn, *dn;
1203 struct pci_dev *pdev; 1202 struct pci_dev *pdev;
1204 const void *dma_window = NULL; 1203 const __be32 *dma_window = NULL;
1205 u64 dma_offset; 1204 u64 dma_offset;
1206 1205
1207 if (!dev->dma_mask) 1206 if (!dev->dma_mask)
diff --git a/arch/powerpc/platforms/pseries/kexec.c b/arch/powerpc/platforms/pseries/kexec.c
index 7d94bdc63d50..13fa95b3aa8b 100644
--- a/arch/powerpc/platforms/pseries/kexec.c
+++ b/arch/powerpc/platforms/pseries/kexec.c
@@ -17,9 +17,9 @@
17#include <asm/mpic.h> 17#include <asm/mpic.h>
18#include <asm/xics.h> 18#include <asm/xics.h>
19#include <asm/smp.h> 19#include <asm/smp.h>
20#include <asm/plpar_wrappers.h>
20 21
21#include "pseries.h" 22#include "pseries.h"
22#include "plpar_wrappers.h"
23 23
24static void pseries_kexec_cpu_down(int crash_shutdown, int secondary) 24static void pseries_kexec_cpu_down(int crash_shutdown, int secondary)
25{ 25{
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 8bad880bd177..356bc75ca74f 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -41,8 +41,8 @@
41#include <asm/smp.h> 41#include <asm/smp.h>
42#include <asm/trace.h> 42#include <asm/trace.h>
43#include <asm/firmware.h> 43#include <asm/firmware.h>
44#include <asm/plpar_wrappers.h>
44 45
45#include "plpar_wrappers.h"
46#include "pseries.h" 46#include "pseries.h"
47 47
48/* Flag bits for H_BULK_REMOVE */ 48/* Flag bits for H_BULK_REMOVE */
@@ -68,6 +68,12 @@ void vpa_init(int cpu)
68 struct paca_struct *pp; 68 struct paca_struct *pp;
69 struct dtl_entry *dtl; 69 struct dtl_entry *dtl;
70 70
71 /*
72 * The spec says it "may be problematic" if CPU x registers the VPA of
73 * CPU y. We should never do that, but wail if we ever do.
74 */
75 WARN_ON(cpu != smp_processor_id());
76
71 if (cpu_has_feature(CPU_FTR_ALTIVEC)) 77 if (cpu_has_feature(CPU_FTR_ALTIVEC))
72 lppaca_of(cpu).vmxregs_in_use = 1; 78 lppaca_of(cpu).vmxregs_in_use = 1;
73 79
@@ -106,7 +112,7 @@ void vpa_init(int cpu)
106 lppaca_of(cpu).dtl_idx = 0; 112 lppaca_of(cpu).dtl_idx = 0;
107 113
108 /* hypervisor reads buffer length from this field */ 114 /* hypervisor reads buffer length from this field */
109 dtl->enqueue_to_dispatch_time = DISPATCH_LOG_BYTES; 115 dtl->enqueue_to_dispatch_time = cpu_to_be32(DISPATCH_LOG_BYTES);
110 ret = register_dtl(hwcpu, __pa(dtl)); 116 ret = register_dtl(hwcpu, __pa(dtl));
111 if (ret) 117 if (ret)
112 pr_err("WARNING: DTL registration of cpu %d (hw %d) " 118 pr_err("WARNING: DTL registration of cpu %d (hw %d) "
@@ -724,7 +730,7 @@ int h_get_mpp(struct hvcall_mpp_data *mpp_data)
724 730
725 mpp_data->mem_weight = (retbuf[3] >> 7 * 8) & 0xff; 731 mpp_data->mem_weight = (retbuf[3] >> 7 * 8) & 0xff;
726 mpp_data->unallocated_mem_weight = (retbuf[3] >> 6 * 8) & 0xff; 732 mpp_data->unallocated_mem_weight = (retbuf[3] >> 6 * 8) & 0xff;
727 mpp_data->unallocated_entitlement = retbuf[3] & 0xffffffffffff; 733 mpp_data->unallocated_entitlement = retbuf[3] & 0xffffffffffffUL;
728 734
729 mpp_data->pool_size = retbuf[4]; 735 mpp_data->pool_size = retbuf[4];
730 mpp_data->loan_request = retbuf[5]; 736 mpp_data->loan_request = retbuf[5];
diff --git a/arch/powerpc/kernel/lparcfg.c b/arch/powerpc/platforms/pseries/lparcfg.c
index e2a0a162299b..e738007eae64 100644
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/platforms/pseries/lparcfg.c
@@ -171,7 +171,7 @@ static void parse_ppp_data(struct seq_file *m)
171 ppp_data.active_system_procs); 171 ppp_data.active_system_procs);
172 172
173 /* pool related entries are appropriate for shared configs */ 173 /* pool related entries are appropriate for shared configs */
174 if (lppaca_of(0).shared_proc) { 174 if (lppaca_shared_proc(get_lppaca())) {
175 unsigned long pool_idle_time, pool_procs; 175 unsigned long pool_idle_time, pool_procs;
176 176
177 seq_printf(m, "pool=%d\n", ppp_data.pool_num); 177 seq_printf(m, "pool=%d\n", ppp_data.pool_num);
@@ -393,8 +393,8 @@ static void pseries_cmo_data(struct seq_file *m)
393 return; 393 return;
394 394
395 for_each_possible_cpu(cpu) { 395 for_each_possible_cpu(cpu) {
396 cmo_faults += lppaca_of(cpu).cmo_faults; 396 cmo_faults += be64_to_cpu(lppaca_of(cpu).cmo_faults);
397 cmo_fault_time += lppaca_of(cpu).cmo_fault_time; 397 cmo_fault_time += be64_to_cpu(lppaca_of(cpu).cmo_fault_time);
398 } 398 }
399 399
400 seq_printf(m, "cmo_faults=%lu\n", cmo_faults); 400 seq_printf(m, "cmo_faults=%lu\n", cmo_faults);
@@ -412,8 +412,9 @@ static void splpar_dispatch_data(struct seq_file *m)
412 unsigned long dispatch_dispersions = 0; 412 unsigned long dispatch_dispersions = 0;
413 413
414 for_each_possible_cpu(cpu) { 414 for_each_possible_cpu(cpu) {
415 dispatches += lppaca_of(cpu).yield_count; 415 dispatches += be32_to_cpu(lppaca_of(cpu).yield_count);
416 dispatch_dispersions += lppaca_of(cpu).dispersion_count; 416 dispatch_dispersions +=
417 be32_to_cpu(lppaca_of(cpu).dispersion_count);
417 } 418 }
418 419
419 seq_printf(m, "dispatches=%lu\n", dispatches); 420 seq_printf(m, "dispatches=%lu\n", dispatches);
@@ -480,7 +481,8 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v)
480 seq_printf(m, "partition_potential_processors=%d\n", 481 seq_printf(m, "partition_potential_processors=%d\n",
481 partition_potential_processors); 482 partition_potential_processors);
482 483
483 seq_printf(m, "shared_processor_mode=%d\n", lppaca_of(0).shared_proc); 484 seq_printf(m, "shared_processor_mode=%d\n",
485 lppaca_shared_proc(get_lppaca()));
484 486
485 seq_printf(m, "slb_size=%d\n", mmu_slb_size); 487 seq_printf(m, "slb_size=%d\n", mmu_slb_size);
486 488
diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c
index 3d01eee9ffb1..cde4e0a095ae 100644
--- a/arch/powerpc/platforms/pseries/mobility.c
+++ b/arch/powerpc/platforms/pseries/mobility.c
@@ -28,7 +28,7 @@ struct update_props_workarea {
28 u32 state; 28 u32 state;
29 u64 reserved; 29 u64 reserved;
30 u32 nprops; 30 u32 nprops;
31}; 31} __packed;
32 32
33#define NODE_ACTION_MASK 0xff000000 33#define NODE_ACTION_MASK 0xff000000
34#define NODE_COUNT_MASK 0x00ffffff 34#define NODE_COUNT_MASK 0x00ffffff
@@ -62,6 +62,7 @@ static int delete_dt_node(u32 phandle)
62 return -ENOENT; 62 return -ENOENT;
63 63
64 dlpar_detach_node(dn); 64 dlpar_detach_node(dn);
65 of_node_put(dn);
65 return 0; 66 return 0;
66} 67}
67 68
@@ -119,7 +120,7 @@ static int update_dt_property(struct device_node *dn, struct property **prop,
119 120
120 if (!more) { 121 if (!more) {
121 of_update_property(dn, new_prop); 122 of_update_property(dn, new_prop);
122 new_prop = NULL; 123 *prop = NULL;
123 } 124 }
124 125
125 return 0; 126 return 0;
@@ -130,7 +131,7 @@ static int update_dt_node(u32 phandle, s32 scope)
130 struct update_props_workarea *upwa; 131 struct update_props_workarea *upwa;
131 struct device_node *dn; 132 struct device_node *dn;
132 struct property *prop = NULL; 133 struct property *prop = NULL;
133 int i, rc; 134 int i, rc, rtas_rc;
134 char *prop_data; 135 char *prop_data;
135 char *rtas_buf; 136 char *rtas_buf;
136 int update_properties_token; 137 int update_properties_token;
@@ -154,25 +155,26 @@ static int update_dt_node(u32 phandle, s32 scope)
154 upwa->phandle = phandle; 155 upwa->phandle = phandle;
155 156
156 do { 157 do {
157 rc = mobility_rtas_call(update_properties_token, rtas_buf, 158 rtas_rc = mobility_rtas_call(update_properties_token, rtas_buf,
158 scope); 159 scope);
159 if (rc < 0) 160 if (rtas_rc < 0)
160 break; 161 break;
161 162
162 prop_data = rtas_buf + sizeof(*upwa); 163 prop_data = rtas_buf + sizeof(*upwa);
163 164
164 /* The first element of the buffer is the path of the node 165 /* On the first call to ibm,update-properties for a node the
165 * being updated in the form of a 8 byte string length 166 * the first property value descriptor contains an empty
166 * followed by the string. Skip past this to get to the 167 * property name, the property value length encoded as u32,
167 * properties being updated. 168 * and the property value is the node path being updated.
168 */ 169 */
169 vd = *prop_data++; 170 if (*prop_data == 0) {
170 prop_data += vd; 171 prop_data++;
172 vd = *(u32 *)prop_data;
173 prop_data += vd + sizeof(vd);
174 upwa->nprops--;
175 }
171 176
172 /* The path we skipped over is counted as one of the elements 177 for (i = 0; i < upwa->nprops; i++) {
173 * returned so start counting at one.
174 */
175 for (i = 1; i < upwa->nprops; i++) {
176 char *prop_name; 178 char *prop_name;
177 179
178 prop_name = prop_data; 180 prop_name = prop_data;
@@ -202,7 +204,7 @@ static int update_dt_node(u32 phandle, s32 scope)
202 prop_data += vd; 204 prop_data += vd;
203 } 205 }
204 } 206 }
205 } while (rc == 1); 207 } while (rtas_rc == 1);
206 208
207 of_node_put(dn); 209 of_node_put(dn);
208 kfree(rtas_buf); 210 kfree(rtas_buf);
@@ -215,17 +217,14 @@ static int add_dt_node(u32 parent_phandle, u32 drc_index)
215 struct device_node *parent_dn; 217 struct device_node *parent_dn;
216 int rc; 218 int rc;
217 219
218 dn = dlpar_configure_connector(drc_index); 220 parent_dn = of_find_node_by_phandle(parent_phandle);
219 if (!dn) 221 if (!parent_dn)
220 return -ENOENT; 222 return -ENOENT;
221 223
222 parent_dn = of_find_node_by_phandle(parent_phandle); 224 dn = dlpar_configure_connector(drc_index, parent_dn);
223 if (!parent_dn) { 225 if (!dn)
224 dlpar_free_cc_nodes(dn);
225 return -ENOENT; 226 return -ENOENT;
226 }
227 227
228 dn->parent = parent_dn;
229 rc = dlpar_attach_node(dn); 228 rc = dlpar_attach_node(dn);
230 if (rc) 229 if (rc)
231 dlpar_free_cc_nodes(dn); 230 dlpar_free_cc_nodes(dn);
diff --git a/arch/powerpc/platforms/pseries/processor_idle.c b/arch/powerpc/platforms/pseries/processor_idle.c
index 4644efa06941..a166e38bd683 100644
--- a/arch/powerpc/platforms/pseries/processor_idle.c
+++ b/arch/powerpc/platforms/pseries/processor_idle.c
@@ -18,9 +18,7 @@
18#include <asm/machdep.h> 18#include <asm/machdep.h>
19#include <asm/firmware.h> 19#include <asm/firmware.h>
20#include <asm/runlatch.h> 20#include <asm/runlatch.h>
21 21#include <asm/plpar_wrappers.h>
22#include "plpar_wrappers.h"
23#include "pseries.h"
24 22
25struct cpuidle_driver pseries_idle_driver = { 23struct cpuidle_driver pseries_idle_driver = {
26 .name = "pseries_idle", 24 .name = "pseries_idle",
@@ -45,7 +43,11 @@ static inline void idle_loop_prolog(unsigned long *in_purr)
45 43
46static inline void idle_loop_epilog(unsigned long in_purr) 44static inline void idle_loop_epilog(unsigned long in_purr)
47{ 45{
48 get_lppaca()->wait_state_cycles += mfspr(SPRN_PURR) - in_purr; 46 u64 wait_cycles;
47
48 wait_cycles = be64_to_cpu(get_lppaca()->wait_state_cycles);
49 wait_cycles += mfspr(SPRN_PURR) - in_purr;
50 get_lppaca()->wait_state_cycles = cpu_to_be64(wait_cycles);
49 get_lppaca()->idle = 0; 51 get_lppaca()->idle = 0;
50} 52}
51 53
@@ -308,7 +310,7 @@ static int pseries_idle_probe(void)
308 return -EPERM; 310 return -EPERM;
309 } 311 }
310 312
311 if (get_lppaca()->shared_proc) 313 if (lppaca_shared_proc(get_lppaca()))
312 cpuidle_state_table = shared_states; 314 cpuidle_state_table = shared_states;
313 else 315 else
314 cpuidle_state_table = dedicated_states; 316 cpuidle_state_table = dedicated_states;
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index c2a3a258001c..99219530ea4a 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -56,13 +56,10 @@ extern void hvc_vio_init_early(void);
56/* Dynamic logical Partitioning/Mobility */ 56/* Dynamic logical Partitioning/Mobility */
57extern void dlpar_free_cc_nodes(struct device_node *); 57extern void dlpar_free_cc_nodes(struct device_node *);
58extern void dlpar_free_cc_property(struct property *); 58extern void dlpar_free_cc_property(struct property *);
59extern struct device_node *dlpar_configure_connector(u32); 59extern struct device_node *dlpar_configure_connector(u32, struct device_node *);
60extern int dlpar_attach_node(struct device_node *); 60extern int dlpar_attach_node(struct device_node *);
61extern int dlpar_detach_node(struct device_node *); 61extern int dlpar_detach_node(struct device_node *);
62 62
63/* Snooze Delay, pseries_idle */
64DECLARE_PER_CPU(long, smt_snooze_delay);
65
66/* PCI root bridge prepare function override for pseries */ 63/* PCI root bridge prepare function override for pseries */
67struct pci_host_bridge; 64struct pci_host_bridge;
68int pseries_root_bridge_prepare(struct pci_host_bridge *bridge); 65int pseries_root_bridge_prepare(struct pci_host_bridge *bridge);
diff --git a/arch/powerpc/platforms/pseries/pseries_energy.c b/arch/powerpc/platforms/pseries/pseries_energy.c
index a91e6dadda2c..92767791f93b 100644
--- a/arch/powerpc/platforms/pseries/pseries_energy.c
+++ b/arch/powerpc/platforms/pseries/pseries_energy.c
@@ -108,8 +108,8 @@ err:
108 * energy consumption. 108 * energy consumption.
109 */ 109 */
110 110
111#define FLAGS_MODE1 0x004E200000080E01 111#define FLAGS_MODE1 0x004E200000080E01UL
112#define FLAGS_MODE2 0x004E200000080401 112#define FLAGS_MODE2 0x004E200000080401UL
113#define FLAGS_ACTIVATE 0x100 113#define FLAGS_ACTIVATE 0x100
114 114
115static ssize_t get_best_energy_list(char *page, int activate) 115static ssize_t get_best_energy_list(char *page, int activate)
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index c11c8238797c..d64feb3ea0be 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -66,8 +66,8 @@
66#include <asm/firmware.h> 66#include <asm/firmware.h>
67#include <asm/eeh.h> 67#include <asm/eeh.h>
68#include <asm/reg.h> 68#include <asm/reg.h>
69#include <asm/plpar_wrappers.h>
69 70
70#include "plpar_wrappers.h"
71#include "pseries.h" 71#include "pseries.h"
72 72
73int CMO_PrPSP = -1; 73int CMO_PrPSP = -1;
@@ -183,7 +183,7 @@ static void __init pseries_mpic_init_IRQ(void)
183 np = of_find_node_by_path("/"); 183 np = of_find_node_by_path("/");
184 naddr = of_n_addr_cells(np); 184 naddr = of_n_addr_cells(np);
185 opprop = of_get_property(np, "platform-open-pic", &opplen); 185 opprop = of_get_property(np, "platform-open-pic", &opplen);
186 if (opprop != 0) { 186 if (opprop != NULL) {
187 openpic_addr = of_read_number(opprop, naddr); 187 openpic_addr = of_read_number(opprop, naddr);
188 printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr); 188 printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr);
189 } 189 }
@@ -323,7 +323,7 @@ static int alloc_dispatch_logs(void)
323 get_paca()->lppaca_ptr->dtl_idx = 0; 323 get_paca()->lppaca_ptr->dtl_idx = 0;
324 324
325 /* hypervisor reads buffer length from this field */ 325 /* hypervisor reads buffer length from this field */
326 dtl->enqueue_to_dispatch_time = DISPATCH_LOG_BYTES; 326 dtl->enqueue_to_dispatch_time = cpu_to_be32(DISPATCH_LOG_BYTES);
327 ret = register_dtl(hard_smp_processor_id(), __pa(dtl)); 327 ret = register_dtl(hard_smp_processor_id(), __pa(dtl));
328 if (ret) 328 if (ret)
329 pr_err("WARNING: DTL registration of cpu %d (hw %d) failed " 329 pr_err("WARNING: DTL registration of cpu %d (hw %d) failed "
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index 306643cc9dbc..1c1771a40250 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -43,8 +43,8 @@
43#include <asm/cputhreads.h> 43#include <asm/cputhreads.h>
44#include <asm/xics.h> 44#include <asm/xics.h>
45#include <asm/dbell.h> 45#include <asm/dbell.h>
46#include <asm/plpar_wrappers.h>
46 47
47#include "plpar_wrappers.h"
48#include "pseries.h" 48#include "pseries.h"
49#include "offline_states.h" 49#include "offline_states.h"
50 50
@@ -187,22 +187,6 @@ static int smp_pSeries_kick_cpu(int nr)
187 return 0; 187 return 0;
188} 188}
189 189
190static int smp_pSeries_cpu_bootable(unsigned int nr)
191{
192 /* Special case - we inhibit secondary thread startup
193 * during boot if the user requests it.
194 */
195 if (system_state == SYSTEM_BOOTING && cpu_has_feature(CPU_FTR_SMT)) {
196 if (!smt_enabled_at_boot && cpu_thread_in_core(nr) != 0)
197 return 0;
198 if (smt_enabled_at_boot
199 && cpu_thread_in_core(nr) >= smt_enabled_at_boot)
200 return 0;
201 }
202
203 return 1;
204}
205
206/* Only used on systems that support multiple IPI mechanisms */ 190/* Only used on systems that support multiple IPI mechanisms */
207static void pSeries_cause_ipi_mux(int cpu, unsigned long data) 191static void pSeries_cause_ipi_mux(int cpu, unsigned long data)
208{ 192{
@@ -237,7 +221,7 @@ static struct smp_ops_t pSeries_xics_smp_ops = {
237 .probe = pSeries_smp_probe, 221 .probe = pSeries_smp_probe,
238 .kick_cpu = smp_pSeries_kick_cpu, 222 .kick_cpu = smp_pSeries_kick_cpu,
239 .setup_cpu = smp_xics_setup_cpu, 223 .setup_cpu = smp_xics_setup_cpu,
240 .cpu_bootable = smp_pSeries_cpu_bootable, 224 .cpu_bootable = smp_generic_cpu_bootable,
241}; 225};
242 226
243/* This is called very early */ 227/* This is called very early */
diff --git a/arch/powerpc/platforms/wsp/wsp.h b/arch/powerpc/platforms/wsp/wsp.h
index 62ef21afb89a..a563a8aaf812 100644
--- a/arch/powerpc/platforms/wsp/wsp.h
+++ b/arch/powerpc/platforms/wsp/wsp.h
@@ -17,7 +17,6 @@ extern void scom_init_wsp(void);
17extern void a2_setup_smp(void); 17extern void a2_setup_smp(void);
18extern int a2_scom_startup_cpu(unsigned int lcpu, int thr_idx, 18extern int a2_scom_startup_cpu(unsigned int lcpu, int thr_idx,
19 struct device_node *np); 19 struct device_node *np);
20extern int smp_a2_cpu_bootable(unsigned int nr);
21extern int smp_a2_kick_cpu(int nr); 20extern int smp_a2_kick_cpu(int nr);
22 21
23extern void opb_pic_init(void); 22extern void opb_pic_init(void);
diff --git a/arch/powerpc/sysdev/fsl_msi.c b/arch/powerpc/sysdev/fsl_msi.c
index ab02db3d02d8..77efbaec7b9c 100644
--- a/arch/powerpc/sysdev/fsl_msi.c
+++ b/arch/powerpc/sysdev/fsl_msi.c
@@ -28,6 +28,18 @@
28#include "fsl_msi.h" 28#include "fsl_msi.h"
29#include "fsl_pci.h" 29#include "fsl_pci.h"
30 30
31#define MSIIR_OFFSET_MASK 0xfffff
32#define MSIIR_IBS_SHIFT 0
33#define MSIIR_SRS_SHIFT 5
34#define MSIIR1_IBS_SHIFT 4
35#define MSIIR1_SRS_SHIFT 0
36#define MSI_SRS_MASK 0xf
37#define MSI_IBS_MASK 0x1f
38
39#define msi_hwirq(msi, msir_index, intr_index) \
40 ((msir_index) << (msi)->srs_shift | \
41 ((intr_index) << (msi)->ibs_shift))
42
31static LIST_HEAD(msi_head); 43static LIST_HEAD(msi_head);
32 44
33struct fsl_msi_feature { 45struct fsl_msi_feature {
@@ -80,18 +92,19 @@ static const struct irq_domain_ops fsl_msi_host_ops = {
80 92
81static int fsl_msi_init_allocator(struct fsl_msi *msi_data) 93static int fsl_msi_init_allocator(struct fsl_msi *msi_data)
82{ 94{
83 int rc; 95 int rc, hwirq;
84 96
85 rc = msi_bitmap_alloc(&msi_data->bitmap, NR_MSI_IRQS, 97 rc = msi_bitmap_alloc(&msi_data->bitmap, NR_MSI_IRQS_MAX,
86 msi_data->irqhost->of_node); 98 msi_data->irqhost->of_node);
87 if (rc) 99 if (rc)
88 return rc; 100 return rc;
89 101
90 rc = msi_bitmap_reserve_dt_hwirqs(&msi_data->bitmap); 102 /*
91 if (rc < 0) { 103 * Reserve all the hwirqs
92 msi_bitmap_free(&msi_data->bitmap); 104 * The available hwirqs will be released in fsl_msi_setup_hwirq()
93 return rc; 105 */
94 } 106 for (hwirq = 0; hwirq < NR_MSI_IRQS_MAX; hwirq++)
107 msi_bitmap_reserve_hwirq(&msi_data->bitmap, hwirq);
95 108
96 return 0; 109 return 0;
97} 110}
@@ -144,8 +157,9 @@ static void fsl_compose_msi_msg(struct pci_dev *pdev, int hwirq,
144 157
145 msg->data = hwirq; 158 msg->data = hwirq;
146 159
147 pr_debug("%s: allocated srs: %d, ibs: %d\n", 160 pr_debug("%s: allocated srs: %d, ibs: %d\n", __func__,
148 __func__, hwirq / IRQS_PER_MSI_REG, hwirq % IRQS_PER_MSI_REG); 161 (hwirq >> msi_data->srs_shift) & MSI_SRS_MASK,
162 (hwirq >> msi_data->ibs_shift) & MSI_IBS_MASK);
149} 163}
150 164
151static int fsl_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) 165static int fsl_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type)
@@ -255,7 +269,7 @@ static void fsl_msi_cascade(unsigned int irq, struct irq_desc *desc)
255 269
256 msir_index = cascade_data->index; 270 msir_index = cascade_data->index;
257 271
258 if (msir_index >= NR_MSI_REG) 272 if (msir_index >= NR_MSI_REG_MAX)
259 cascade_irq = NO_IRQ; 273 cascade_irq = NO_IRQ;
260 274
261 irqd_set_chained_irq_inprogress(idata); 275 irqd_set_chained_irq_inprogress(idata);
@@ -285,8 +299,8 @@ static void fsl_msi_cascade(unsigned int irq, struct irq_desc *desc)
285 intr_index = ffs(msir_value) - 1; 299 intr_index = ffs(msir_value) - 1;
286 300
287 cascade_irq = irq_linear_revmap(msi_data->irqhost, 301 cascade_irq = irq_linear_revmap(msi_data->irqhost,
288 msir_index * IRQS_PER_MSI_REG + 302 msi_hwirq(msi_data, msir_index,
289 intr_index + have_shift); 303 intr_index + have_shift));
290 if (cascade_irq != NO_IRQ) 304 if (cascade_irq != NO_IRQ)
291 generic_handle_irq(cascade_irq); 305 generic_handle_irq(cascade_irq);
292 have_shift += intr_index + 1; 306 have_shift += intr_index + 1;
@@ -316,7 +330,7 @@ static int fsl_of_msi_remove(struct platform_device *ofdev)
316 330
317 if (msi->list.prev != NULL) 331 if (msi->list.prev != NULL)
318 list_del(&msi->list); 332 list_del(&msi->list);
319 for (i = 0; i < NR_MSI_REG; i++) { 333 for (i = 0; i < NR_MSI_REG_MAX; i++) {
320 virq = msi->msi_virqs[i]; 334 virq = msi->msi_virqs[i];
321 if (virq != NO_IRQ) { 335 if (virq != NO_IRQ) {
322 cascade_data = irq_get_handler_data(virq); 336 cascade_data = irq_get_handler_data(virq);
@@ -339,7 +353,7 @@ static int fsl_msi_setup_hwirq(struct fsl_msi *msi, struct platform_device *dev,
339 int offset, int irq_index) 353 int offset, int irq_index)
340{ 354{
341 struct fsl_msi_cascade_data *cascade_data = NULL; 355 struct fsl_msi_cascade_data *cascade_data = NULL;
342 int virt_msir; 356 int virt_msir, i;
343 357
344 virt_msir = irq_of_parse_and_map(dev->dev.of_node, irq_index); 358 virt_msir = irq_of_parse_and_map(dev->dev.of_node, irq_index);
345 if (virt_msir == NO_IRQ) { 359 if (virt_msir == NO_IRQ) {
@@ -360,6 +374,11 @@ static int fsl_msi_setup_hwirq(struct fsl_msi *msi, struct platform_device *dev,
360 irq_set_handler_data(virt_msir, cascade_data); 374 irq_set_handler_data(virt_msir, cascade_data);
361 irq_set_chained_handler(virt_msir, fsl_msi_cascade); 375 irq_set_chained_handler(virt_msir, fsl_msi_cascade);
362 376
377 /* Release the hwirqs corresponding to this MSI register */
378 for (i = 0; i < IRQS_PER_MSI_REG; i++)
379 msi_bitmap_free_hwirqs(&msi->bitmap,
380 msi_hwirq(msi, offset, i), 1);
381
363 return 0; 382 return 0;
364} 383}
365 384
@@ -368,14 +387,12 @@ static int fsl_of_msi_probe(struct platform_device *dev)
368{ 387{
369 const struct of_device_id *match; 388 const struct of_device_id *match;
370 struct fsl_msi *msi; 389 struct fsl_msi *msi;
371 struct resource res; 390 struct resource res, msiir;
372 int err, i, j, irq_index, count; 391 int err, i, j, irq_index, count;
373 int rc;
374 const u32 *p; 392 const u32 *p;
375 const struct fsl_msi_feature *features; 393 const struct fsl_msi_feature *features;
376 int len; 394 int len;
377 u32 offset; 395 u32 offset;
378 static const u32 all_avail[] = { 0, NR_MSI_IRQS };
379 396
380 match = of_match_device(fsl_of_msi_ids, &dev->dev); 397 match = of_match_device(fsl_of_msi_ids, &dev->dev);
381 if (!match) 398 if (!match)
@@ -392,7 +409,7 @@ static int fsl_of_msi_probe(struct platform_device *dev)
392 platform_set_drvdata(dev, msi); 409 platform_set_drvdata(dev, msi);
393 410
394 msi->irqhost = irq_domain_add_linear(dev->dev.of_node, 411 msi->irqhost = irq_domain_add_linear(dev->dev.of_node,
395 NR_MSI_IRQS, &fsl_msi_host_ops, msi); 412 NR_MSI_IRQS_MAX, &fsl_msi_host_ops, msi);
396 413
397 if (msi->irqhost == NULL) { 414 if (msi->irqhost == NULL) {
398 dev_err(&dev->dev, "No memory for MSI irqhost\n"); 415 dev_err(&dev->dev, "No memory for MSI irqhost\n");
@@ -421,6 +438,16 @@ static int fsl_of_msi_probe(struct platform_device *dev)
421 } 438 }
422 msi->msiir_offset = 439 msi->msiir_offset =
423 features->msiir_offset + (res.start & 0xfffff); 440 features->msiir_offset + (res.start & 0xfffff);
441
442 /*
443 * First read the MSIIR/MSIIR1 offset from dts
444 * On failure use the hardcode MSIIR offset
445 */
446 if (of_address_to_resource(dev->dev.of_node, 1, &msiir))
447 msi->msiir_offset = features->msiir_offset +
448 (res.start & MSIIR_OFFSET_MASK);
449 else
450 msi->msiir_offset = msiir.start & MSIIR_OFFSET_MASK;
424 } 451 }
425 452
426 msi->feature = features->fsl_pic_ip; 453 msi->feature = features->fsl_pic_ip;
@@ -431,42 +458,66 @@ static int fsl_of_msi_probe(struct platform_device *dev)
431 */ 458 */
432 msi->phandle = dev->dev.of_node->phandle; 459 msi->phandle = dev->dev.of_node->phandle;
433 460
434 rc = fsl_msi_init_allocator(msi); 461 err = fsl_msi_init_allocator(msi);
435 if (rc) { 462 if (err) {
436 dev_err(&dev->dev, "Error allocating MSI bitmap\n"); 463 dev_err(&dev->dev, "Error allocating MSI bitmap\n");
437 goto error_out; 464 goto error_out;
438 } 465 }
439 466
440 p = of_get_property(dev->dev.of_node, "msi-available-ranges", &len); 467 p = of_get_property(dev->dev.of_node, "msi-available-ranges", &len);
441 if (p && len % (2 * sizeof(u32)) != 0) {
442 dev_err(&dev->dev, "%s: Malformed msi-available-ranges property\n",
443 __func__);
444 err = -EINVAL;
445 goto error_out;
446 }
447 468
448 if (!p) { 469 if (of_device_is_compatible(dev->dev.of_node, "fsl,mpic-msi-v4.3")) {
449 p = all_avail; 470 msi->srs_shift = MSIIR1_SRS_SHIFT;
450 len = sizeof(all_avail); 471 msi->ibs_shift = MSIIR1_IBS_SHIFT;
451 } 472 if (p)
473 dev_warn(&dev->dev, "%s: dose not support msi-available-ranges property\n",
474 __func__);
475
476 for (irq_index = 0; irq_index < NR_MSI_REG_MSIIR1;
477 irq_index++) {
478 err = fsl_msi_setup_hwirq(msi, dev,
479 irq_index, irq_index);
480 if (err)
481 goto error_out;
482 }
483 } else {
484 static const u32 all_avail[] =
485 { 0, NR_MSI_REG_MSIIR * IRQS_PER_MSI_REG };
452 486
453 for (irq_index = 0, i = 0; i < len / (2 * sizeof(u32)); i++) { 487 msi->srs_shift = MSIIR_SRS_SHIFT;
454 if (p[i * 2] % IRQS_PER_MSI_REG || 488 msi->ibs_shift = MSIIR_IBS_SHIFT;
455 p[i * 2 + 1] % IRQS_PER_MSI_REG) { 489
456 printk(KERN_WARNING "%s: %s: msi available range of %u at %u is not IRQ-aligned\n", 490 if (p && len % (2 * sizeof(u32)) != 0) {
457 __func__, dev->dev.of_node->full_name, 491 dev_err(&dev->dev, "%s: Malformed msi-available-ranges property\n",
458 p[i * 2 + 1], p[i * 2]); 492 __func__);
459 err = -EINVAL; 493 err = -EINVAL;
460 goto error_out; 494 goto error_out;
461 } 495 }
462 496
463 offset = p[i * 2] / IRQS_PER_MSI_REG; 497 if (!p) {
464 count = p[i * 2 + 1] / IRQS_PER_MSI_REG; 498 p = all_avail;
499 len = sizeof(all_avail);
500 }
465 501
466 for (j = 0; j < count; j++, irq_index++) { 502 for (irq_index = 0, i = 0; i < len / (2 * sizeof(u32)); i++) {
467 err = fsl_msi_setup_hwirq(msi, dev, offset + j, irq_index); 503 if (p[i * 2] % IRQS_PER_MSI_REG ||
468 if (err) 504 p[i * 2 + 1] % IRQS_PER_MSI_REG) {
505 pr_warn("%s: %s: msi available range of %u at %u is not IRQ-aligned\n",
506 __func__, dev->dev.of_node->full_name,
507 p[i * 2 + 1], p[i * 2]);
508 err = -EINVAL;
469 goto error_out; 509 goto error_out;
510 }
511
512 offset = p[i * 2] / IRQS_PER_MSI_REG;
513 count = p[i * 2 + 1] / IRQS_PER_MSI_REG;
514
515 for (j = 0; j < count; j++, irq_index++) {
516 err = fsl_msi_setup_hwirq(msi, dev, offset + j,
517 irq_index);
518 if (err)
519 goto error_out;
520 }
470 } 521 }
471 } 522 }
472 523
@@ -509,6 +560,10 @@ static const struct of_device_id fsl_of_msi_ids[] = {
509 .data = &mpic_msi_feature, 560 .data = &mpic_msi_feature,
510 }, 561 },
511 { 562 {
563 .compatible = "fsl,mpic-msi-v4.3",
564 .data = &mpic_msi_feature,
565 },
566 {
512 .compatible = "fsl,ipic-msi", 567 .compatible = "fsl,ipic-msi",
513 .data = &ipic_msi_feature, 568 .data = &ipic_msi_feature,
514 }, 569 },
diff --git a/arch/powerpc/sysdev/fsl_msi.h b/arch/powerpc/sysdev/fsl_msi.h
index 8225f8653f78..df9aa9fe0933 100644
--- a/arch/powerpc/sysdev/fsl_msi.h
+++ b/arch/powerpc/sysdev/fsl_msi.h
@@ -16,9 +16,11 @@
16#include <linux/of.h> 16#include <linux/of.h>
17#include <asm/msi_bitmap.h> 17#include <asm/msi_bitmap.h>
18 18
19#define NR_MSI_REG 8 19#define NR_MSI_REG_MSIIR 8 /* MSIIR can index 8 MSI registers */
20#define NR_MSI_REG_MSIIR1 16 /* MSIIR1 can index 16 MSI registers */
21#define NR_MSI_REG_MAX NR_MSI_REG_MSIIR1
20#define IRQS_PER_MSI_REG 32 22#define IRQS_PER_MSI_REG 32
21#define NR_MSI_IRQS (NR_MSI_REG * IRQS_PER_MSI_REG) 23#define NR_MSI_IRQS_MAX (NR_MSI_REG_MAX * IRQS_PER_MSI_REG)
22 24
23#define FSL_PIC_IP_MASK 0x0000000F 25#define FSL_PIC_IP_MASK 0x0000000F
24#define FSL_PIC_IP_MPIC 0x00000001 26#define FSL_PIC_IP_MPIC 0x00000001
@@ -31,9 +33,11 @@ struct fsl_msi {
31 unsigned long cascade_irq; 33 unsigned long cascade_irq;
32 34
33 u32 msiir_offset; /* Offset of MSIIR, relative to start of CCSR */ 35 u32 msiir_offset; /* Offset of MSIIR, relative to start of CCSR */
36 u32 ibs_shift; /* Shift of interrupt bit select */
37 u32 srs_shift; /* Shift of the shared interrupt register select */
34 void __iomem *msi_regs; 38 void __iomem *msi_regs;
35 u32 feature; 39 u32 feature;
36 int msi_virqs[NR_MSI_REG]; 40 int msi_virqs[NR_MSI_REG_MAX];
37 41
38 struct msi_bitmap bitmap; 42 struct msi_bitmap bitmap;
39 43
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index 46ac1ddea683..ccfb50ddfe38 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -26,11 +26,15 @@
26#include <linux/memblock.h> 26#include <linux/memblock.h>
27#include <linux/log2.h> 27#include <linux/log2.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/uaccess.h>
29 30
30#include <asm/io.h> 31#include <asm/io.h>
31#include <asm/prom.h> 32#include <asm/prom.h>
32#include <asm/pci-bridge.h> 33#include <asm/pci-bridge.h>
34#include <asm/ppc-pci.h>
33#include <asm/machdep.h> 35#include <asm/machdep.h>
36#include <asm/disassemble.h>
37#include <asm/ppc-opcode.h>
34#include <sysdev/fsl_soc.h> 38#include <sysdev/fsl_soc.h>
35#include <sysdev/fsl_pci.h> 39#include <sysdev/fsl_pci.h>
36 40
@@ -64,7 +68,7 @@ static int fsl_pcie_check_link(struct pci_controller *hose)
64 if (hose->indirect_type & PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK) { 68 if (hose->indirect_type & PPC_INDIRECT_TYPE_FSL_CFG_REG_LINK) {
65 if (hose->ops->read == fsl_indirect_read_config) { 69 if (hose->ops->read == fsl_indirect_read_config) {
66 struct pci_bus bus; 70 struct pci_bus bus;
67 bus.number = 0; 71 bus.number = hose->first_busno;
68 bus.sysdata = hose; 72 bus.sysdata = hose;
69 bus.ops = hose->ops; 73 bus.ops = hose->ops;
70 indirect_read_config(&bus, 0, PCIE_LTSSM, 4, &val); 74 indirect_read_config(&bus, 0, PCIE_LTSSM, 4, &val);
@@ -297,10 +301,10 @@ static void setup_pci_atmu(struct pci_controller *hose)
297 if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) { 301 if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) {
298 /* Size window to exact size if power-of-two or one size up */ 302 /* Size window to exact size if power-of-two or one size up */
299 if ((1ull << mem_log) != mem) { 303 if ((1ull << mem_log) != mem) {
304 mem_log++;
300 if ((1ull << mem_log) > mem) 305 if ((1ull << mem_log) > mem)
301 pr_info("%s: Setting PCI inbound window " 306 pr_info("%s: Setting PCI inbound window "
302 "greater than memory size\n", name); 307 "greater than memory size\n", name);
303 mem_log++;
304 } 308 }
305 309
306 piwar |= ((mem_log - 1) & PIWAR_SZ_MASK); 310 piwar |= ((mem_log - 1) & PIWAR_SZ_MASK);
@@ -373,7 +377,9 @@ static void setup_pci_atmu(struct pci_controller *hose)
373 } 377 }
374 378
375 if (hose->dma_window_size < mem) { 379 if (hose->dma_window_size < mem) {
376#ifndef CONFIG_SWIOTLB 380#ifdef CONFIG_SWIOTLB
381 ppc_swiotlb_enable = 1;
382#else
377 pr_err("%s: ERROR: Memory size exceeds PCI ATMU ability to " 383 pr_err("%s: ERROR: Memory size exceeds PCI ATMU ability to "
378 "map - enable CONFIG_SWIOTLB to avoid dma errors.\n", 384 "map - enable CONFIG_SWIOTLB to avoid dma errors.\n",
379 name); 385 name);
@@ -868,6 +874,160 @@ u64 fsl_pci_immrbar_base(struct pci_controller *hose)
868 return 0; 874 return 0;
869} 875}
870 876
877#ifdef CONFIG_E500
878static int mcheck_handle_load(struct pt_regs *regs, u32 inst)
879{
880 unsigned int rd, ra, rb, d;
881
882 rd = get_rt(inst);
883 ra = get_ra(inst);
884 rb = get_rb(inst);
885 d = get_d(inst);
886
887 switch (get_op(inst)) {
888 case 31:
889 switch (get_xop(inst)) {
890 case OP_31_XOP_LWZX:
891 case OP_31_XOP_LWBRX:
892 regs->gpr[rd] = 0xffffffff;
893 break;
894
895 case OP_31_XOP_LWZUX:
896 regs->gpr[rd] = 0xffffffff;
897 regs->gpr[ra] += regs->gpr[rb];
898 break;
899
900 case OP_31_XOP_LBZX:
901 regs->gpr[rd] = 0xff;
902 break;
903
904 case OP_31_XOP_LBZUX:
905 regs->gpr[rd] = 0xff;
906 regs->gpr[ra] += regs->gpr[rb];
907 break;
908
909 case OP_31_XOP_LHZX:
910 case OP_31_XOP_LHBRX:
911 regs->gpr[rd] = 0xffff;
912 break;
913
914 case OP_31_XOP_LHZUX:
915 regs->gpr[rd] = 0xffff;
916 regs->gpr[ra] += regs->gpr[rb];
917 break;
918
919 case OP_31_XOP_LHAX:
920 regs->gpr[rd] = ~0UL;
921 break;
922
923 case OP_31_XOP_LHAUX:
924 regs->gpr[rd] = ~0UL;
925 regs->gpr[ra] += regs->gpr[rb];
926 break;
927
928 default:
929 return 0;
930 }
931 break;
932
933 case OP_LWZ:
934 regs->gpr[rd] = 0xffffffff;
935 break;
936
937 case OP_LWZU:
938 regs->gpr[rd] = 0xffffffff;
939 regs->gpr[ra] += (s16)d;
940 break;
941
942 case OP_LBZ:
943 regs->gpr[rd] = 0xff;
944 break;
945
946 case OP_LBZU:
947 regs->gpr[rd] = 0xff;
948 regs->gpr[ra] += (s16)d;
949 break;
950
951 case OP_LHZ:
952 regs->gpr[rd] = 0xffff;
953 break;
954
955 case OP_LHZU:
956 regs->gpr[rd] = 0xffff;
957 regs->gpr[ra] += (s16)d;
958 break;
959
960 case OP_LHA:
961 regs->gpr[rd] = ~0UL;
962 break;
963
964 case OP_LHAU:
965 regs->gpr[rd] = ~0UL;
966 regs->gpr[ra] += (s16)d;
967 break;
968
969 default:
970 return 0;
971 }
972
973 return 1;
974}
975
976static int is_in_pci_mem_space(phys_addr_t addr)
977{
978 struct pci_controller *hose;
979 struct resource *res;
980 int i;
981
982 list_for_each_entry(hose, &hose_list, list_node) {
983 if (!(hose->indirect_type & PPC_INDIRECT_TYPE_EXT_REG))
984 continue;
985
986 for (i = 0; i < 3; i++) {
987 res = &hose->mem_resources[i];
988 if ((res->flags & IORESOURCE_MEM) &&
989 addr >= res->start && addr <= res->end)
990 return 1;
991 }
992 }
993 return 0;
994}
995
996int fsl_pci_mcheck_exception(struct pt_regs *regs)
997{
998 u32 inst;
999 int ret;
1000 phys_addr_t addr = 0;
1001
1002 /* Let KVM/QEMU deal with the exception */
1003 if (regs->msr & MSR_GS)
1004 return 0;
1005
1006#ifdef CONFIG_PHYS_64BIT
1007 addr = mfspr(SPRN_MCARU);
1008 addr <<= 32;
1009#endif
1010 addr += mfspr(SPRN_MCAR);
1011
1012 if (is_in_pci_mem_space(addr)) {
1013 if (user_mode(regs)) {
1014 pagefault_disable();
1015 ret = get_user(regs->nip, &inst);
1016 pagefault_enable();
1017 } else {
1018 ret = probe_kernel_address(regs->nip, inst);
1019 }
1020
1021 if (mcheck_handle_load(regs, inst)) {
1022 regs->nip += 4;
1023 return 1;
1024 }
1025 }
1026
1027 return 0;
1028}
1029#endif
1030
871#if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx) 1031#if defined(CONFIG_FSL_SOC_BOOKE) || defined(CONFIG_PPC_86xx)
872static const struct of_device_id pci_ids[] = { 1032static const struct of_device_id pci_ids[] = {
873 { .compatible = "fsl,mpc8540-pci", }, 1033 { .compatible = "fsl,mpc8540-pci", },
@@ -928,28 +1088,10 @@ static int fsl_pci_probe(struct platform_device *pdev)
928{ 1088{
929 int ret; 1089 int ret;
930 struct device_node *node; 1090 struct device_node *node;
931#ifdef CONFIG_SWIOTLB
932 struct pci_controller *hose;
933#endif
934 1091
935 node = pdev->dev.of_node; 1092 node = pdev->dev.of_node;
936 ret = fsl_add_bridge(pdev, fsl_pci_primary == node); 1093 ret = fsl_add_bridge(pdev, fsl_pci_primary == node);
937 1094
938#ifdef CONFIG_SWIOTLB
939 if (ret == 0) {
940 hose = pci_find_hose_for_OF_device(pdev->dev.of_node);
941
942 /*
943 * if we couldn't map all of DRAM via the dma windows
944 * we need SWIOTLB to handle buffers located outside of
945 * dma capable memory region
946 */
947 if (memblock_end_of_DRAM() - 1 > hose->dma_window_base_cur +
948 hose->dma_window_size)
949 ppc_swiotlb_enable = 1;
950 }
951#endif
952
953 mpc85xx_pci_err_probe(pdev); 1095 mpc85xx_pci_err_probe(pdev);
954 1096
955 return 0; 1097 return 0;
diff --git a/arch/powerpc/sysdev/fsl_pci.h b/arch/powerpc/sysdev/fsl_pci.h
index 72b5625330e2..defc422a375f 100644
--- a/arch/powerpc/sysdev/fsl_pci.h
+++ b/arch/powerpc/sysdev/fsl_pci.h
@@ -126,5 +126,11 @@ static inline int mpc85xx_pci_err_probe(struct platform_device *op)
126} 126}
127#endif 127#endif
128 128
129#ifdef CONFIG_FSL_PCI
130extern int fsl_pci_mcheck_exception(struct pt_regs *);
131#else
132static inline int fsl_pci_mcheck_exception(struct pt_regs *regs) {return 0; }
133#endif
134
129#endif /* __POWERPC_FSL_PCI_H */ 135#endif /* __POWERPC_FSL_PCI_H */
130#endif /* __KERNEL__ */ 136#endif /* __KERNEL__ */
diff --git a/arch/powerpc/sysdev/xics/icp-native.c b/arch/powerpc/sysdev/xics/icp-native.c
index 7cd728b3b5e4..9dee47071af8 100644
--- a/arch/powerpc/sysdev/xics/icp-native.c
+++ b/arch/powerpc/sysdev/xics/icp-native.c
@@ -216,7 +216,7 @@ static int __init icp_native_init_one_node(struct device_node *np,
216 unsigned int *indx) 216 unsigned int *indx)
217{ 217{
218 unsigned int ilen; 218 unsigned int ilen;
219 const u32 *ireg; 219 const __be32 *ireg;
220 int i; 220 int i;
221 int reg_tuple_size; 221 int reg_tuple_size;
222 int num_servers = 0; 222 int num_servers = 0;
diff --git a/arch/powerpc/sysdev/xics/xics-common.c b/arch/powerpc/sysdev/xics/xics-common.c
index 9049d9f44485..fe0cca477164 100644
--- a/arch/powerpc/sysdev/xics/xics-common.c
+++ b/arch/powerpc/sysdev/xics/xics-common.c
@@ -49,7 +49,7 @@ void xics_update_irq_servers(void)
49 int i, j; 49 int i, j;
50 struct device_node *np; 50 struct device_node *np;
51 u32 ilen; 51 u32 ilen;
52 const u32 *ireg; 52 const __be32 *ireg;
53 u32 hcpuid; 53 u32 hcpuid;
54 54
55 /* Find the server numbers for the boot cpu. */ 55 /* Find the server numbers for the boot cpu. */
@@ -75,8 +75,8 @@ void xics_update_irq_servers(void)
75 * default distribution server 75 * default distribution server
76 */ 76 */
77 for (j = 0; j < i; j += 2) { 77 for (j = 0; j < i; j += 2) {
78 if (ireg[j] == hcpuid) { 78 if (be32_to_cpu(ireg[j]) == hcpuid) {
79 xics_default_distrib_server = ireg[j+1]; 79 xics_default_distrib_server = be32_to_cpu(ireg[j+1]);
80 break; 80 break;
81 } 81 }
82 } 82 }
@@ -383,7 +383,7 @@ void __init xics_register_ics(struct ics *ics)
383static void __init xics_get_server_size(void) 383static void __init xics_get_server_size(void)
384{ 384{
385 struct device_node *np; 385 struct device_node *np;
386 const u32 *isize; 386 const __be32 *isize;
387 387
388 /* We fetch the interrupt server size from the first ICS node 388 /* We fetch the interrupt server size from the first ICS node
389 * we find if any 389 * we find if any
@@ -394,7 +394,7 @@ static void __init xics_get_server_size(void)
394 isize = of_get_property(np, "ibm,interrupt-server#-size", NULL); 394 isize = of_get_property(np, "ibm,interrupt-server#-size", NULL);
395 if (!isize) 395 if (!isize)
396 return; 396 return;
397 xics_interrupt_server_size = *isize; 397 xics_interrupt_server_size = be32_to_cpu(*isize);
398 of_node_put(np); 398 of_node_put(np);
399} 399}
400 400
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 96bf5bd30fbc..af9d3469fb99 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -972,27 +972,27 @@ static void bootcmds(void)
972static int cpu_cmd(void) 972static int cpu_cmd(void)
973{ 973{
974#ifdef CONFIG_SMP 974#ifdef CONFIG_SMP
975 unsigned long cpu; 975 unsigned long cpu, first_cpu, last_cpu;
976 int timeout; 976 int timeout;
977 int count;
978 977
979 if (!scanhex(&cpu)) { 978 if (!scanhex(&cpu)) {
980 /* print cpus waiting or in xmon */ 979 /* print cpus waiting or in xmon */
981 printf("cpus stopped:"); 980 printf("cpus stopped:");
982 count = 0; 981 last_cpu = first_cpu = NR_CPUS;
983 for_each_possible_cpu(cpu) { 982 for_each_possible_cpu(cpu) {
984 if (cpumask_test_cpu(cpu, &cpus_in_xmon)) { 983 if (cpumask_test_cpu(cpu, &cpus_in_xmon)) {
985 if (count == 0) 984 if (cpu == last_cpu + 1) {
986 printf(" %x", cpu); 985 last_cpu = cpu;
987 ++count; 986 } else {
988 } else { 987 if (last_cpu != first_cpu)
989 if (count > 1) 988 printf("-%lx", last_cpu);
990 printf("-%x", cpu - 1); 989 last_cpu = first_cpu = cpu;
991 count = 0; 990 printf(" %lx", cpu);
991 }
992 } 992 }
993 } 993 }
994 if (count > 1) 994 if (last_cpu != first_cpu)
995 printf("-%x", NR_CPUS - 1); 995 printf("-%lx", last_cpu);
996 printf("\n"); 996 printf("\n");
997 return 0; 997 return 0;
998 } 998 }
@@ -1256,11 +1256,18 @@ const char *getvecname(unsigned long vec)
1256 case 0x700: ret = "(Program Check)"; break; 1256 case 0x700: ret = "(Program Check)"; break;
1257 case 0x800: ret = "(FPU Unavailable)"; break; 1257 case 0x800: ret = "(FPU Unavailable)"; break;
1258 case 0x900: ret = "(Decrementer)"; break; 1258 case 0x900: ret = "(Decrementer)"; break;
1259 case 0x980: ret = "(Hypervisor Decrementer)"; break;
1260 case 0xa00: ret = "(Doorbell)"; break;
1259 case 0xc00: ret = "(System Call)"; break; 1261 case 0xc00: ret = "(System Call)"; break;
1260 case 0xd00: ret = "(Single Step)"; break; 1262 case 0xd00: ret = "(Single Step)"; break;
1263 case 0xe40: ret = "(Emulation Assist)"; break;
1264 case 0xe60: ret = "(HMI)"; break;
1265 case 0xe80: ret = "(Hypervisor Doorbell)"; break;
1261 case 0xf00: ret = "(Performance Monitor)"; break; 1266 case 0xf00: ret = "(Performance Monitor)"; break;
1262 case 0xf20: ret = "(Altivec Unavailable)"; break; 1267 case 0xf20: ret = "(Altivec Unavailable)"; break;
1263 case 0x1300: ret = "(Instruction Breakpoint)"; break; 1268 case 0x1300: ret = "(Instruction Breakpoint)"; break;
1269 case 0x1500: ret = "(Denormalisation)"; break;
1270 case 0x1700: ret = "(Altivec Assist)"; break;
1264 default: ret = ""; 1271 default: ret = "";
1265 } 1272 }
1266 return ret; 1273 return ret;