aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MAINTAINERS7
-rw-r--r--arch/powerpc/Kconfig14
-rw-r--r--arch/powerpc/Kconfig.debug16
-rw-r--r--arch/powerpc/boot/Makefile7
-rw-r--r--arch/powerpc/boot/dts/mpc8349emds.dts16
-rw-r--r--arch/powerpc/boot/flatdevtree.h46
-rw-r--r--arch/powerpc/boot/main.c250
-rw-r--r--arch/powerpc/boot/of.c (renamed from arch/powerpc/boot/prom.c)144
-rw-r--r--arch/powerpc/boot/ops.h100
-rw-r--r--arch/powerpc/boot/prom.h41
-rw-r--r--arch/powerpc/boot/stdio.c4
-rw-r--r--arch/powerpc/boot/stdio.h8
-rw-r--r--arch/powerpc/boot/types.h23
-rw-r--r--arch/powerpc/configs/maple_defconfig2
-rw-r--r--arch/powerpc/kernel/Makefile4
-rw-r--r--arch/powerpc/kernel/asm-offsets.c17
-rw-r--r--arch/powerpc/kernel/btext.c24
-rw-r--r--arch/powerpc/kernel/cpu_setup_ppc970.S (renamed from arch/powerpc/kernel/cpu_setup_power4.S)103
-rw-r--r--arch/powerpc/kernel/cputable.c21
-rw-r--r--arch/powerpc/kernel/crash_dump.c2
-rw-r--r--arch/powerpc/kernel/dma_64.c65
-rw-r--r--arch/powerpc/kernel/entry_64.S8
-rw-r--r--arch/powerpc/kernel/head_64.S54
-rw-r--r--arch/powerpc/kernel/ibmebus.c6
-rw-r--r--arch/powerpc/kernel/io.c131
-rw-r--r--arch/powerpc/kernel/irq.c5
-rw-r--r--arch/powerpc/kernel/legacy_serial.c35
-rw-r--r--arch/powerpc/kernel/lparcfg.c30
-rw-r--r--arch/powerpc/kernel/machine_kexec_64.c10
-rw-r--r--arch/powerpc/kernel/misc.S159
-rw-r--r--arch/powerpc/kernel/of_device.c24
-rw-r--r--arch/powerpc/kernel/paca.c15
-rw-r--r--arch/powerpc/kernel/pci_32.c39
-rw-r--r--arch/powerpc/kernel/pci_64.c67
-rw-r--r--arch/powerpc/kernel/pci_dn.c13
-rw-r--r--arch/powerpc/kernel/ppc_ksyms.c19
-rw-r--r--arch/powerpc/kernel/prom.c44
-rw-r--r--arch/powerpc/kernel/prom_init.c10
-rw-r--r--arch/powerpc/kernel/prom_parse.c90
-rw-r--r--arch/powerpc/kernel/rtas-proc.c25
-rw-r--r--arch/powerpc/kernel/rtas.c47
-rw-r--r--arch/powerpc/kernel/rtas_pci.c28
-rw-r--r--arch/powerpc/kernel/setup-common.c32
-rw-r--r--arch/powerpc/kernel/setup_64.c23
-rw-r--r--arch/powerpc/kernel/sysfs.c9
-rw-r--r--arch/powerpc/kernel/time.c8
-rw-r--r--arch/powerpc/kernel/traps.c25
-rw-r--r--arch/powerpc/kernel/vio.c16
-rw-r--r--arch/powerpc/lib/Makefile1
-rw-r--r--arch/powerpc/lib/e2a.c116
-rw-r--r--arch/powerpc/lib/locks.c27
-rw-r--r--arch/powerpc/mm/numa.c31
-rw-r--r--arch/powerpc/mm/slb.c37
-rw-r--r--arch/powerpc/mm/tlb_64.c1
-rw-r--r--arch/powerpc/platforms/83xx/mpc834x_itx.c4
-rw-r--r--arch/powerpc/platforms/83xx/mpc834x_sys.c4
-rw-r--r--arch/powerpc/platforms/83xx/pci.c4
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_ads.c4
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_cds.c4
-rw-r--r--arch/powerpc/platforms/85xx/pci.c4
-rw-r--r--arch/powerpc/platforms/86xx/mpc86xx_hpcn.c4
-rw-r--r--arch/powerpc/platforms/86xx/pci.c4
-rw-r--r--arch/powerpc/platforms/Makefile1
-rw-r--r--arch/powerpc/platforms/cell/cbe_regs.c8
-rw-r--r--arch/powerpc/platforms/cell/interrupt.c25
-rw-r--r--arch/powerpc/platforms/cell/iommu.c22
-rw-r--r--arch/powerpc/platforms/cell/setup.c4
-rw-r--r--arch/powerpc/platforms/cell/smp.c4
-rw-r--r--arch/powerpc/platforms/cell/spider-pic.c10
-rw-r--r--arch/powerpc/platforms/cell/spu_base.c18
-rw-r--r--arch/powerpc/platforms/chrp/nvram.c5
-rw-r--r--arch/powerpc/platforms/chrp/pci.c53
-rw-r--r--arch/powerpc/platforms/chrp/setup.c48
-rw-r--r--arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c8
-rw-r--r--arch/powerpc/platforms/iseries/Kconfig8
-rw-r--r--arch/powerpc/platforms/iseries/dt.c45
-rw-r--r--arch/powerpc/platforms/iseries/hvlpconfig.c13
-rw-r--r--arch/powerpc/platforms/iseries/iommu.c19
-rw-r--r--arch/powerpc/platforms/iseries/it_exp_vpd_panel.h (renamed from include/asm-powerpc/iseries/it_exp_vpd_panel.h)6
-rw-r--r--arch/powerpc/platforms/iseries/it_lp_naca.h (renamed from include/asm-powerpc/iseries/it_lp_naca.h)6
-rw-r--r--arch/powerpc/platforms/iseries/lpardata.c6
-rw-r--r--arch/powerpc/platforms/iseries/lpevents.c2
-rw-r--r--arch/powerpc/platforms/iseries/main_store.h126
-rw-r--r--arch/powerpc/platforms/iseries/pci.c289
-rw-r--r--arch/powerpc/platforms/iseries/setup.c1
-rw-r--r--arch/powerpc/platforms/iseries/viopath.c28
-rw-r--r--arch/powerpc/platforms/iseries/vpdinfo.c22
-rw-r--r--arch/powerpc/platforms/maple/pci.c70
-rw-r--r--arch/powerpc/platforms/maple/setup.c27
-rw-r--r--arch/powerpc/platforms/pasemi/Makefile1
-rw-r--r--arch/powerpc/platforms/pasemi/pasemi.h8
-rw-r--r--arch/powerpc/platforms/pasemi/pci.c198
-rw-r--r--arch/powerpc/platforms/pasemi/setup.c188
-rw-r--r--arch/powerpc/platforms/pasemi/time.c29
-rw-r--r--arch/powerpc/platforms/powermac/backlight.c3
-rw-r--r--arch/powerpc/platforms/powermac/cpufreq_32.c23
-rw-r--r--arch/powerpc/platforms/powermac/cpufreq_64.c27
-rw-r--r--arch/powerpc/platforms/powermac/feature.c30
-rw-r--r--arch/powerpc/platforms/powermac/low_i2c.c24
-rw-r--r--arch/powerpc/platforms/powermac/pci.c37
-rw-r--r--arch/powerpc/platforms/powermac/pfunc_base.c2
-rw-r--r--arch/powerpc/platforms/powermac/pfunc_core.c5
-rw-r--r--arch/powerpc/platforms/powermac/setup.c18
-rw-r--r--arch/powerpc/platforms/powermac/smp.c7
-rw-r--r--arch/powerpc/platforms/powermac/udbg_scc.c10
-rw-r--r--arch/powerpc/platforms/pseries/Makefile1
-rw-r--r--arch/powerpc/platforms/pseries/eeh.c96
-rw-r--r--arch/powerpc/platforms/pseries/eeh_cache.c17
-rw-r--r--arch/powerpc/platforms/pseries/eeh_driver.c112
-rw-r--r--arch/powerpc/platforms/pseries/eeh_event.c4
-rw-r--r--arch/powerpc/platforms/pseries/firmware.c2
-rw-r--r--arch/powerpc/platforms/pseries/hvCall.S273
-rw-r--r--arch/powerpc/platforms/pseries/hvCall_inst.c129
-rw-r--r--arch/powerpc/platforms/pseries/hvconsole.c5
-rw-r--r--arch/powerpc/platforms/pseries/iommu.c13
-rw-r--r--arch/powerpc/platforms/pseries/lpar.c46
-rw-r--r--arch/powerpc/platforms/pseries/nvram.c5
-rw-r--r--arch/powerpc/platforms/pseries/pci.c2
-rw-r--r--arch/powerpc/platforms/pseries/plpar_wrappers.h107
-rw-r--r--arch/powerpc/platforms/pseries/ras.c4
-rw-r--r--arch/powerpc/platforms/pseries/rtasd.c4
-rw-r--r--arch/powerpc/platforms/pseries/setup.c42
-rw-r--r--arch/powerpc/platforms/pseries/smp.c12
-rw-r--r--arch/powerpc/platforms/pseries/xics.c44
-rw-r--r--arch/powerpc/sysdev/fsl_soc.c28
-rw-r--r--arch/powerpc/sysdev/fsl_soc.h2
-rw-r--r--arch/powerpc/sysdev/i8259.c2
-rw-r--r--arch/powerpc/sysdev/ipic.c42
-rw-r--r--arch/powerpc/sysdev/mmio_nvram.c4
-rw-r--r--arch/powerpc/sysdev/tsi108_pci.c4
-rw-r--r--arch/powerpc/xmon/xmon.c10
-rw-r--r--arch/ppc/Kconfig6
-rw-r--r--arch/ppc/kernel/misc.S88
-rw-r--r--arch/ppc/kernel/ppc_ksyms.c9
-rw-r--r--arch/ppc/kernel/setup.c17
-rw-r--r--arch/ppc/platforms/85xx/sbc8560.h1
-rw-r--r--arch/ppc/platforms/85xx/sbc85xx.h18
-rw-r--r--arch/ppc/syslib/m8260_pci_erratum9.c16
-rw-r--r--arch/ppc/xmon/start.c28
-rw-r--r--arch/ppc/xmon/xmon.c28
-rw-r--r--drivers/char/Kconfig22
-rw-r--r--drivers/char/Makefile2
-rw-r--r--drivers/char/agp/uninorth-agp.c4
-rw-r--r--drivers/char/briq_panel.c268
-rw-r--r--drivers/char/hvc_console.c18
-rw-r--r--drivers/char/hvc_console.h2
-rw-r--r--drivers/char/hvc_iseries.c594
-rw-r--r--drivers/char/hvc_rtas.c2
-rw-r--r--drivers/char/hvc_vio.c7
-rw-r--r--drivers/char/hvsi.c7
-rw-r--r--drivers/char/tpm/tpm_atmel.h4
-rw-r--r--drivers/char/viocons.c31
-rw-r--r--drivers/char/viotape.c6
-rw-r--r--drivers/i2c/busses/i2c-powermac.c3
-rw-r--r--drivers/ide/ppc/pmac.c8
-rw-r--r--drivers/macintosh/macio_asic.c10
-rw-r--r--drivers/macintosh/macio_sysfs.c8
-rw-r--r--drivers/macintosh/smu.c19
-rw-r--r--drivers/macintosh/therm_adt746x.c8
-rw-r--r--drivers/macintosh/therm_pm72.c14
-rw-r--r--drivers/macintosh/therm_windtunnel.c4
-rw-r--r--drivers/macintosh/via-cuda.c4
-rw-r--r--drivers/macintosh/via-pmu-led.c2
-rw-r--r--drivers/macintosh/via-pmu.c10
-rw-r--r--drivers/macintosh/windfarm_pm81.c4
-rw-r--r--drivers/macintosh/windfarm_pm91.c2
-rw-r--r--drivers/macintosh/windfarm_smu_controls.c13
-rw-r--r--drivers/macintosh/windfarm_smu_sat.c8
-rw-r--r--drivers/macintosh/windfarm_smu_sensors.c12
-rw-r--r--drivers/mtd/Kconfig8
-rw-r--r--drivers/mtd/Makefile1
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0002.c1
-rw-r--r--drivers/mtd/devices/pmc551.c1154
-rw-r--r--drivers/mtd/maps/Kconfig8
-rw-r--r--drivers/mtd/maps/Makefile1
-rw-r--r--drivers/mtd/maps/amd76xrom.c5
-rw-r--r--drivers/mtd/maps/arctic-mtd.c14
-rw-r--r--drivers/mtd/maps/beech-mtd.c14
-rw-r--r--drivers/mtd/maps/cstm_mips_ixx.c18
-rw-r--r--drivers/mtd/maps/ebony.c4
-rw-r--r--drivers/mtd/maps/fortunet.c3
-rw-r--r--drivers/mtd/maps/ichxrom.c3
-rw-r--r--drivers/mtd/maps/iq80310.c118
-rw-r--r--drivers/mtd/maps/ixp4xx.c2
-rw-r--r--drivers/mtd/maps/l440gx.c12
-rw-r--r--drivers/mtd/maps/lasat.c2
-rw-r--r--drivers/mtd/maps/nettel.c34
-rw-r--r--drivers/mtd/maps/ocotea.c4
-rw-r--r--drivers/mtd/maps/pcmciamtd.c4
-rw-r--r--drivers/mtd/maps/physmap.c33
-rw-r--r--drivers/mtd/maps/redwood.c11
-rw-r--r--drivers/mtd/maps/sbc8240.c11
-rw-r--r--drivers/mtd/maps/scx200_docflash.c9
-rw-r--r--drivers/mtd/maps/walnut.c4
-rw-r--r--drivers/mtd/mtdcore.c10
-rw-r--r--drivers/mtd/nand/au1550nd.c11
-rw-r--r--drivers/mtd/nand/edb7312.c3
-rw-r--r--drivers/mtd/nand/ndfc.c2
-rw-r--r--drivers/mtd/nand/ppchameleonevb.c7
-rw-r--r--drivers/mtd/ssfdc.c468
-rw-r--r--drivers/net/bmac.c13
-rw-r--r--drivers/net/ibmveth.c3
-rw-r--r--drivers/net/ibmveth.h27
-rw-r--r--drivers/net/mace.c2
-rw-r--r--drivers/net/spider_net.c12
-rw-r--r--drivers/net/sungem.c2
-rw-r--r--drivers/pci/hotplug/rpaphp_core.c32
-rw-r--r--drivers/scsi/ibmvscsi/rpa_vscsi.c11
-rw-r--r--drivers/scsi/mac53c94.c2
-rw-r--r--drivers/scsi/mesh.c5
-rw-r--r--drivers/scsi/sata_svw.c2
-rw-r--r--drivers/serial/pmac_zilog.c9
-rw-r--r--drivers/video/S3triofb.c12
-rw-r--r--drivers/video/aty/radeon_base.c8
-rw-r--r--drivers/video/aty/radeon_monitor.c12
-rw-r--r--drivers/video/aty/radeon_pm.c4
-rw-r--r--drivers/video/nvidia/nv_of.c12
-rw-r--r--drivers/video/offb.c22
-rw-r--r--drivers/video/riva/fbdev.c5
-rw-r--r--fs/jffs2/jffs2_fs_i.h4
-rw-r--r--include/asm-powerpc/cputable.h27
-rw-r--r--include/asm-powerpc/hvcall.h121
-rw-r--r--include/asm-powerpc/ibmebus.h2
-rw-r--r--include/asm-powerpc/ide.h12
-rw-r--r--include/asm-powerpc/io.h183
-rw-r--r--include/asm-powerpc/irq.h24
-rw-r--r--include/asm-powerpc/iseries/hv_call_xm.h17
-rw-r--r--include/asm-powerpc/iseries/hv_lp_config.h13
-rw-r--r--include/asm-powerpc/iseries/iseries_io.h60
-rw-r--r--include/asm-powerpc/iseries/it_lp_queue.h2
-rw-r--r--include/asm-powerpc/iseries/vio.h28
-rw-r--r--include/asm-powerpc/lppaca.h23
-rw-r--r--include/asm-powerpc/paca.h3
-rw-r--r--include/asm-powerpc/page.h6
-rw-r--r--include/asm-powerpc/ppc-pci.h11
-rw-r--r--include/asm-powerpc/processor.h1
-rw-r--r--include/asm-powerpc/prom.h40
-rw-r--r--include/asm-powerpc/ptrace.h4
-rw-r--r--include/asm-powerpc/reg.h1
-rw-r--r--include/asm-powerpc/rtas.h16
-rw-r--r--include/asm-powerpc/smu.h2
-rw-r--r--include/asm-powerpc/spu.h2
-rw-r--r--include/asm-powerpc/system.h5
-rw-r--r--include/asm-powerpc/vio.h4
-rw-r--r--include/asm-ppc/io.h26
-rw-r--r--include/asm-ppc/mpc8260_pci9.h4
-rw-r--r--include/asm-ppc/reg_booke.h16
-rw-r--r--include/mtd/mtd-abi.h1
-rwxr-xr-xscripts/checkstack.pl2
-rw-r--r--sound/aoa/core/snd-aoa-gpio-feature.c2
-rw-r--r--sound/oss/dmasound/dmasound_awacs.c11
-rw-r--r--sound/ppc/tumbler.c15
252 files changed, 5608 insertions, 3186 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 576a7f230840..ed2a83cfad7c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1783,6 +1783,13 @@ W: http://www.penguinppc.org/
1783L: linuxppc-embedded@ozlabs.org 1783L: linuxppc-embedded@ozlabs.org
1784S: Maintained 1784S: Maintained
1785 1785
1786LINUX FOR POWERPC PA SEMI PWRFICIENT
1787P: Olof Johansson
1788M: olof@lixom.net
1789W: http://www.pasemi.com/
1790L: linuxppc-dev@ozlabs.org
1791S: Supported
1792
1786LLC (802.2) 1793LLC (802.2)
1787P: Arnaldo Carvalho de Melo 1794P: Arnaldo Carvalho de Melo
1788M: acme@conectiva.com.br 1795M: acme@conectiva.com.br
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 694b0c63ee50..de1ef2fa1a20 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -417,6 +417,17 @@ config PPC_MAPLE
417 This option enables support for the Maple 970FX Evaluation Board. 417 This option enables support for the Maple 970FX Evaluation Board.
418 For more informations, refer to <http://www.970eval.com> 418 For more informations, refer to <http://www.970eval.com>
419 419
420config PPC_PASEMI
421 depends on PPC_MULTIPLATFORM && PPC64
422 bool "PA Semi SoC-based platforms"
423 default n
424 select MPIC
425 select PPC_UDBG_16550
426 select GENERIC_TBSYNC
427 help
428 This option enables support for PA Semi's PWRficient line
429 of SoC processors, including PA6T-1682M
430
420config PPC_CELL 431config PPC_CELL
421 bool 432 bool
422 default n 433 default n
@@ -436,7 +447,8 @@ config PPC_IBM_CELL_BLADE
436 select UDBG_RTAS_CONSOLE 447 select UDBG_RTAS_CONSOLE
437 448
438config UDBG_RTAS_CONSOLE 449config UDBG_RTAS_CONSOLE
439 bool 450 bool "RTAS based debug console"
451 depends on PPC_RTAS
440 default n 452 default n
441 453
442config XICS 454config XICS
diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
index e29ef77d3b00..5ad149b47e34 100644
--- a/arch/powerpc/Kconfig.debug
+++ b/arch/powerpc/Kconfig.debug
@@ -18,6 +18,20 @@ config DEBUG_STACK_USAGE
18 18
19 This option will slow down process creation somewhat. 19 This option will slow down process creation somewhat.
20 20
21config HCALL_STATS
22 bool "Hypervisor call instrumentation"
23 depends on PPC_PSERIES && DEBUG_FS
24 help
25 Adds code to keep track of the number of hypervisor calls made and
26 the amount of time spent in hypervisor callsr. Wall time spent in
27 each call is always calculated, and if available CPU cycles spent
28 are also calculated. A directory named hcall_inst is added at the
29 root of the debugfs filesystem. Within the hcall_inst directory
30 are files that contain CPU specific call statistics.
31
32 This option will add a small amount of overhead to all hypervisor
33 calls.
34
21config DEBUGGER 35config DEBUGGER
22 bool "Enable debugger hooks" 36 bool "Enable debugger hooks"
23 depends on DEBUG_KERNEL 37 depends on DEBUG_KERNEL
@@ -74,6 +88,8 @@ config XMON
74 very early during boot. 'xmon=on' will just enable the xmon 88 very early during boot. 'xmon=on' will just enable the xmon
75 debugger hooks. 'xmon=off' will disable the debugger hooks 89 debugger hooks. 'xmon=off' will disable the debugger hooks
76 if CONFIG_XMON_DEFAULT is set. 90 if CONFIG_XMON_DEFAULT is set.
91 xmon will print a backtrace on the very first invocation.
92 'xmon=nobt' will disable this autobacktrace.
77 93
78config XMON_DEFAULT 94config XMON_DEFAULT
79 bool "Enable xmon by default" 95 bool "Enable xmon by default"
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index d961bfeed05f..e73774136b55 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -36,11 +36,16 @@ zliblinuxheader := zlib.h zconf.h zutil.h
36$(addprefix $(obj)/,$(zlib) main.o): $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader)) 36$(addprefix $(obj)/,$(zlib) main.o): $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader))
37#$(addprefix $(obj)/,main.o): $(addprefix $(obj)/,zlib.h) 37#$(addprefix $(obj)/,main.o): $(addprefix $(obj)/,zlib.h)
38 38
39src-boot := crt0.S string.S prom.c stdio.c main.c div64.S 39src-boot-$(CONFIG_PPC_MULTIPLATFORM) := of.c
40src-boot := crt0.S string.S stdio.c main.c div64.S $(src-boot-y)
40src-boot += $(zlib) 41src-boot += $(zlib)
41src-boot := $(addprefix $(obj)/, $(src-boot)) 42src-boot := $(addprefix $(obj)/, $(src-boot))
42obj-boot := $(addsuffix .o, $(basename $(src-boot))) 43obj-boot := $(addsuffix .o, $(basename $(src-boot)))
43 44
45ifeq ($(call cc-option-yn, -fstack-protector),y)
46BOOTCFLAGS += -fno-stack-protector
47endif
48
44BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj) 49BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj)
45 50
46quiet_cmd_copy_zlib = COPY $@ 51quiet_cmd_copy_zlib = COPY $@
diff --git a/arch/powerpc/boot/dts/mpc8349emds.dts b/arch/powerpc/boot/dts/mpc8349emds.dts
index 12f5dbf3055f..efceb3432653 100644
--- a/arch/powerpc/boot/dts/mpc8349emds.dts
+++ b/arch/powerpc/boot/dts/mpc8349emds.dts
@@ -214,10 +214,10 @@
214 b800 0 0 4 700 15 8 214 b800 0 0 4 700 15 8
215 215
216 /* IDSEL 0x18 */ 216 /* IDSEL 0x18 */
217 b000 0 0 1 700 15 8 217 c000 0 0 1 700 15 8
218 b000 0 0 2 700 16 8 218 c000 0 0 2 700 16 8
219 b000 0 0 3 700 17 8 219 c000 0 0 3 700 17 8
220 b000 0 0 4 700 14 8>; 220 c000 0 0 4 700 14 8>;
221 interrupt-parent = <700>; 221 interrupt-parent = <700>;
222 interrupts = <42 8>; 222 interrupts = <42 8>;
223 bus-range = <0 0>; 223 bus-range = <0 0>;
@@ -274,10 +274,10 @@
274 b800 0 0 4 700 15 8 274 b800 0 0 4 700 15 8
275 275
276 /* IDSEL 0x18 */ 276 /* IDSEL 0x18 */
277 b000 0 0 1 700 15 8 277 c000 0 0 1 700 15 8
278 b000 0 0 2 700 16 8 278 c000 0 0 2 700 16 8
279 b000 0 0 3 700 17 8 279 c000 0 0 3 700 17 8
280 b000 0 0 4 700 14 8>; 280 c000 0 0 4 700 14 8>;
281 interrupt-parent = <700>; 281 interrupt-parent = <700>;
282 interrupts = <42 8>; 282 interrupts = <42 8>;
283 bus-range = <0 0>; 283 bus-range = <0 0>;
diff --git a/arch/powerpc/boot/flatdevtree.h b/arch/powerpc/boot/flatdevtree.h
new file mode 100644
index 000000000000..761c8dc84008
--- /dev/null
+++ b/arch/powerpc/boot/flatdevtree.h
@@ -0,0 +1,46 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 */
16
17#ifndef FLATDEVTREE_H
18#define FLATDEVTREE_H
19
20#include "types.h"
21
22/* Definitions used by the flattened device tree */
23#define OF_DT_HEADER 0xd00dfeed /* marker */
24#define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */
25#define OF_DT_END_NODE 0x2 /* End node */
26#define OF_DT_PROP 0x3 /* Property: name off, size, content */
27#define OF_DT_NOP 0x4 /* nop */
28#define OF_DT_END 0x9
29
30#define OF_DT_VERSION 0x10
31
32struct boot_param_header {
33 u32 magic; /* magic word OF_DT_HEADER */
34 u32 totalsize; /* total size of DT block */
35 u32 off_dt_struct; /* offset to structure */
36 u32 off_dt_strings; /* offset to strings */
37 u32 off_mem_rsvmap; /* offset to memory reserve map */
38 u32 version; /* format version */
39 u32 last_comp_version; /* last compatible version */
40 /* version 2 fields below */
41 u32 boot_cpuid_phys; /* Physical CPU id we're booting on */
42 /* version 3 fields below */
43 u32 dt_strings_size; /* size of the DT strings block */
44};
45
46#endif /* FLATDEVTREE_H */
diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index b66634c9ea34..d719bb9333d1 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -14,17 +14,12 @@
14#include "page.h" 14#include "page.h"
15#include "string.h" 15#include "string.h"
16#include "stdio.h" 16#include "stdio.h"
17#include "prom.h"
18#include "zlib.h" 17#include "zlib.h"
18#include "ops.h"
19#include "flatdevtree.h"
19 20
20extern void flush_cache(void *, unsigned long); 21extern void flush_cache(void *, unsigned long);
21 22
22
23/* Value picked to match that used by yaboot */
24#define PROG_START 0x01400000 /* only used on 64-bit systems */
25#define RAM_END (512<<20) /* Fixme: use OF */
26#define ONE_MB 0x100000
27
28extern char _start[]; 23extern char _start[];
29extern char __bss_start[]; 24extern char __bss_start[];
30extern char _end[]; 25extern char _end[];
@@ -33,14 +28,6 @@ extern char _vmlinux_end[];
33extern char _initrd_start[]; 28extern char _initrd_start[];
34extern char _initrd_end[]; 29extern char _initrd_end[];
35 30
36/* A buffer that may be edited by tools operating on a zImage binary so as to
37 * edit the command line passed to vmlinux (by setting /chosen/bootargs).
38 * The buffer is put in it's own section so that tools may locate it easier.
39 */
40static char builtin_cmdline[512]
41 __attribute__((section("__builtin_cmdline")));
42
43
44struct addr_range { 31struct addr_range {
45 unsigned long addr; 32 unsigned long addr;
46 unsigned long size; 33 unsigned long size;
@@ -51,21 +38,16 @@ static struct addr_range vmlinuz;
51static struct addr_range initrd; 38static struct addr_range initrd;
52 39
53static unsigned long elfoffset; 40static unsigned long elfoffset;
41static int is_64bit;
54 42
55static char scratch[46912]; /* scratch space for gunzip, from zlib_inflate_workspacesize() */ 43/* scratch space for gunzip; 46912 is from zlib_inflate_workspacesize() */
44static char scratch[46912];
56static char elfheader[256]; 45static char elfheader[256];
57 46
58 47typedef void (*kernel_entry_t)(unsigned long, unsigned long, void *);
59typedef void (*kernel_entry_t)( unsigned long,
60 unsigned long,
61 void *,
62 void *);
63
64 48
65#undef DEBUG 49#undef DEBUG
66 50
67static unsigned long claim_base;
68
69#define HEAD_CRC 2 51#define HEAD_CRC 2
70#define EXTRA_FIELD 4 52#define EXTRA_FIELD 4
71#define ORIG_NAME 8 53#define ORIG_NAME 8
@@ -123,24 +105,6 @@ static void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp)
123 zlib_inflateEnd(&s); 105 zlib_inflateEnd(&s);
124} 106}
125 107
126static unsigned long try_claim(unsigned long size)
127{
128 unsigned long addr = 0;
129
130 for(; claim_base < RAM_END; claim_base += ONE_MB) {
131#ifdef DEBUG
132 printf(" trying: 0x%08lx\n\r", claim_base);
133#endif
134 addr = (unsigned long)claim(claim_base, size, 0);
135 if ((void *)addr != (void *)-1)
136 break;
137 }
138 if (addr == 0)
139 return 0;
140 claim_base = PAGE_ALIGN(claim_base + size);
141 return addr;
142}
143
144static int is_elf64(void *hdr) 108static int is_elf64(void *hdr)
145{ 109{
146 Elf64_Ehdr *elf64 = hdr; 110 Elf64_Ehdr *elf64 = hdr;
@@ -169,16 +133,7 @@ static int is_elf64(void *hdr)
169 vmlinux.size = (unsigned long)elf64ph->p_filesz + elfoffset; 133 vmlinux.size = (unsigned long)elf64ph->p_filesz + elfoffset;
170 vmlinux.memsize = (unsigned long)elf64ph->p_memsz + elfoffset; 134 vmlinux.memsize = (unsigned long)elf64ph->p_memsz + elfoffset;
171 135
172#if defined(PROG_START) 136 is_64bit = 1;
173 /*
174 * Maintain a "magic" minimum address. This keeps some older
175 * firmware platforms running.
176 */
177
178 if (claim_base < PROG_START)
179 claim_base = PROG_START;
180#endif
181
182 return 1; 137 return 1;
183} 138}
184 139
@@ -212,47 +167,9 @@ static int is_elf32(void *hdr)
212 return 1; 167 return 1;
213} 168}
214 169
215void export_cmdline(void* chosen_handle) 170static void prep_kernel(unsigned long *a1, unsigned long *a2)
216{
217 int len;
218 char cmdline[2] = { 0, 0 };
219
220 if (builtin_cmdline[0] == 0)
221 return;
222
223 len = getprop(chosen_handle, "bootargs", cmdline, sizeof(cmdline));
224 if (len > 0 && cmdline[0] != 0)
225 return;
226
227 setprop(chosen_handle, "bootargs", builtin_cmdline,
228 strlen(builtin_cmdline) + 1);
229}
230
231
232void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
233{ 171{
234 int len; 172 int len;
235 kernel_entry_t kernel_entry;
236
237 memset(__bss_start, 0, _end - __bss_start);
238
239 prom = (int (*)(void *)) promptr;
240 chosen_handle = finddevice("/chosen");
241 if (chosen_handle == (void *) -1)
242 exit();
243 if (getprop(chosen_handle, "stdout", &stdout, sizeof(stdout)) != 4)
244 exit();
245
246 printf("\n\rzImage starting: loaded at 0x%p (sp: 0x%p)\n\r", _start, sp);
247
248 /*
249 * The first available claim_base must be above the end of the
250 * the loaded kernel wrapper file (_start to _end includes the
251 * initrd image if it is present) and rounded up to a nice
252 * 1 MB boundary for good measure.
253 */
254
255 claim_base = _ALIGN_UP((unsigned long)_end, ONE_MB);
256 173
257 vmlinuz.addr = (unsigned long)_vmlinux_start; 174 vmlinuz.addr = (unsigned long)_vmlinux_start;
258 vmlinuz.size = (unsigned long)(_vmlinux_end - _vmlinux_start); 175 vmlinuz.size = (unsigned long)(_vmlinux_end - _vmlinux_start);
@@ -263,43 +180,51 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
263 gunzip(elfheader, sizeof(elfheader), 180 gunzip(elfheader, sizeof(elfheader),
264 (unsigned char *)vmlinuz.addr, &len); 181 (unsigned char *)vmlinuz.addr, &len);
265 } else 182 } else
266 memcpy(elfheader, (const void *)vmlinuz.addr, sizeof(elfheader)); 183 memcpy(elfheader, (const void *)vmlinuz.addr,
184 sizeof(elfheader));
267 185
268 if (!is_elf64(elfheader) && !is_elf32(elfheader)) { 186 if (!is_elf64(elfheader) && !is_elf32(elfheader)) {
269 printf("Error: not a valid PPC32 or PPC64 ELF file!\n\r"); 187 printf("Error: not a valid PPC32 or PPC64 ELF file!\n\r");
270 exit(); 188 exit();
271 } 189 }
190 if (platform_ops.image_hdr)
191 platform_ops.image_hdr(elfheader);
272 192
273 /* We need to claim the memsize plus the file offset since gzip 193 /* We need to alloc the memsize plus the file offset since gzip
274 * will expand the header (file offset), then the kernel, then 194 * will expand the header (file offset), then the kernel, then
275 * possible rubbish we don't care about. But the kernel bss must 195 * possible rubbish we don't care about. But the kernel bss must
276 * be claimed (it will be zero'd by the kernel itself) 196 * be claimed (it will be zero'd by the kernel itself)
277 */ 197 */
278 printf("Allocating 0x%lx bytes for kernel ...\n\r", vmlinux.memsize); 198 printf("Allocating 0x%lx bytes for kernel ...\n\r", vmlinux.memsize);
279 vmlinux.addr = try_claim(vmlinux.memsize); 199 vmlinux.addr = (unsigned long)malloc(vmlinux.memsize);
280 if (vmlinux.addr == 0) { 200 if (vmlinux.addr == 0) {
281 printf("Can't allocate memory for kernel image !\n\r"); 201 printf("Can't allocate memory for kernel image !\n\r");
282 exit(); 202 exit();
283 } 203 }
284 204
285 /* 205 /*
286 * Now we try to claim memory for the initrd (and copy it there) 206 * Now we try to alloc memory for the initrd (and copy it there)
287 */ 207 */
288 initrd.size = (unsigned long)(_initrd_end - _initrd_start); 208 initrd.size = (unsigned long)(_initrd_end - _initrd_start);
289 initrd.memsize = initrd.size; 209 initrd.memsize = initrd.size;
290 if ( initrd.size > 0 ) { 210 if ( initrd.size > 0 ) {
291 printf("Allocating 0x%lx bytes for initrd ...\n\r", initrd.size); 211 printf("Allocating 0x%lx bytes for initrd ...\n\r",
292 initrd.addr = try_claim(initrd.size); 212 initrd.size);
213 initrd.addr = (unsigned long)malloc((u32)initrd.size);
293 if (initrd.addr == 0) { 214 if (initrd.addr == 0) {
294 printf("Can't allocate memory for initial ramdisk !\n\r"); 215 printf("Can't allocate memory for initial "
216 "ramdisk !\n\r");
295 exit(); 217 exit();
296 } 218 }
297 a1 = initrd.addr; 219 *a1 = initrd.addr;
298 a2 = initrd.size; 220 *a2 = initrd.size;
299 printf("initial ramdisk moving 0x%lx <- 0x%lx (0x%lx bytes)\n\r", 221 printf("initial ramdisk moving 0x%lx <- 0x%lx "
300 initrd.addr, (unsigned long)_initrd_start, initrd.size); 222 "(0x%lx bytes)\n\r", initrd.addr,
301 memmove((void *)initrd.addr, (void *)_initrd_start, initrd.size); 223 (unsigned long)_initrd_start, initrd.size);
302 printf("initrd head: 0x%lx\n\r", *((unsigned long *)initrd.addr)); 224 memmove((void *)initrd.addr, (void *)_initrd_start,
225 initrd.size);
226 printf("initrd head: 0x%lx\n\r",
227 *((unsigned long *)initrd.addr));
303 } 228 }
304 229
305 /* Eventually gunzip the kernel */ 230 /* Eventually gunzip the kernel */
@@ -311,11 +236,10 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
311 (unsigned char *)vmlinuz.addr, &len); 236 (unsigned char *)vmlinuz.addr, &len);
312 printf("done 0x%lx bytes\n\r", len); 237 printf("done 0x%lx bytes\n\r", len);
313 } else { 238 } else {
314 memmove((void *)vmlinux.addr,(void *)vmlinuz.addr,vmlinuz.size); 239 memmove((void *)vmlinux.addr,(void *)vmlinuz.addr,
240 vmlinuz.size);
315 } 241 }
316 242
317 export_cmdline(chosen_handle);
318
319 /* Skip over the ELF header */ 243 /* Skip over the ELF header */
320#ifdef DEBUG 244#ifdef DEBUG
321 printf("... skipping 0x%lx bytes of ELF header\n\r", 245 printf("... skipping 0x%lx bytes of ELF header\n\r",
@@ -324,23 +248,107 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
324 vmlinux.addr += elfoffset; 248 vmlinux.addr += elfoffset;
325 249
326 flush_cache((void *)vmlinux.addr, vmlinux.size); 250 flush_cache((void *)vmlinux.addr, vmlinux.size);
251}
327 252
328 kernel_entry = (kernel_entry_t)vmlinux.addr; 253void __attribute__ ((weak)) ft_init(void *dt_blob)
329#ifdef DEBUG 254{
330 printf( "kernel:\n\r" 255}
331 " entry addr = 0x%lx\n\r"
332 " a1 = 0x%lx,\n\r"
333 " a2 = 0x%lx,\n\r"
334 " prom = 0x%lx,\n\r"
335 " bi_recs = 0x%lx,\n\r",
336 (unsigned long)kernel_entry, a1, a2,
337 (unsigned long)prom, NULL);
338#endif
339 256
340 kernel_entry(a1, a2, prom, NULL); 257/* A buffer that may be edited by tools operating on a zImage binary so as to
258 * edit the command line passed to vmlinux (by setting /chosen/bootargs).
259 * The buffer is put in it's own section so that tools may locate it easier.
260 */
261static char builtin_cmdline[COMMAND_LINE_SIZE]
262 __attribute__((__section__("__builtin_cmdline")));
341 263
342 printf("Error: Linux kernel returned to zImage bootloader!\n\r"); 264static void get_cmdline(char *buf, int size)
265{
266 void *devp;
267 int len = strlen(builtin_cmdline);
343 268
344 exit(); 269 buf[0] = '\0';
270
271 if (len > 0) { /* builtin_cmdline overrides dt's /chosen/bootargs */
272 len = min(len, size-1);
273 strncpy(buf, builtin_cmdline, len);
274 buf[len] = '\0';
275 }
276 else if ((devp = finddevice("/chosen")))
277 getprop(devp, "bootargs", buf, size);
278}
279
280static void set_cmdline(char *buf)
281{
282 void *devp;
283
284 if ((devp = finddevice("/chosen")))
285 setprop(devp, "bootargs", buf, strlen(buf) + 1);
345} 286}
346 287
288/* Section where ft can be tacked on after zImage is built */
289union blobspace {
290 struct boot_param_header hdr;
291 char space[8*1024];
292} dt_blob __attribute__((__section__("__builtin_ft")));
293
294struct platform_ops platform_ops;
295struct dt_ops dt_ops;
296struct console_ops console_ops;
297
298void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
299{
300 int have_dt = 0;
301 kernel_entry_t kentry;
302 char cmdline[COMMAND_LINE_SIZE];
303
304 memset(__bss_start, 0, _end - __bss_start);
305 memset(&platform_ops, 0, sizeof(platform_ops));
306 memset(&dt_ops, 0, sizeof(dt_ops));
307 memset(&console_ops, 0, sizeof(console_ops));
308
309 /* Override the dt_ops and device tree if there was an flat dev
310 * tree attached to the zImage.
311 */
312 if (dt_blob.hdr.magic == OF_DT_HEADER) {
313 have_dt = 1;
314 ft_init(&dt_blob);
315 }
316
317 if (platform_init(promptr))
318 exit();
319 if (console_ops.open && (console_ops.open() < 0))
320 exit();
321 if (platform_ops.fixups)
322 platform_ops.fixups();
323
324 printf("\n\rzImage starting: loaded at 0x%p (sp: 0x%p)\n\r",
325 _start, sp);
326
327 prep_kernel(&a1, &a2);
328
329 /* If cmdline came from zimage wrapper or if we can edit the one
330 * in the dt, print it out and edit it, if possible.
331 */
332 if ((strlen(builtin_cmdline) > 0) || console_ops.edit_cmdline) {
333 get_cmdline(cmdline, COMMAND_LINE_SIZE);
334 printf("\n\rLinux/PowerPC load: %s", cmdline);
335 if (console_ops.edit_cmdline)
336 console_ops.edit_cmdline(cmdline, COMMAND_LINE_SIZE);
337 printf("\n\r");
338 set_cmdline(cmdline);
339 }
340
341 if (console_ops.close)
342 console_ops.close();
343
344 kentry = (kernel_entry_t) vmlinux.addr;
345 if (have_dt)
346 kentry(dt_ops.ft_addr(), 0, NULL);
347 else
348 /* XXX initrd addr/size should be passed in properties */
349 kentry(a1, a2, promptr);
350
351 /* console closed so printf below may not work */
352 printf("Error: Linux kernel returned to zImage boot wrapper!\n\r");
353 exit();
354}
diff --git a/arch/powerpc/boot/prom.c b/arch/powerpc/boot/of.c
index fa0057736f6b..fd99f789a37b 100644
--- a/arch/powerpc/boot/prom.c
+++ b/arch/powerpc/boot/of.c
@@ -8,15 +8,29 @@
8 */ 8 */
9#include <stdarg.h> 9#include <stdarg.h>
10#include <stddef.h> 10#include <stddef.h>
11#include "types.h"
12#include "elf.h"
11#include "string.h" 13#include "string.h"
12#include "stdio.h" 14#include "stdio.h"
13#include "prom.h" 15#include "page.h"
16#include "ops.h"
14 17
15int (*prom)(void *); 18typedef void *ihandle;
16phandle chosen_handle; 19typedef void *phandle;
17ihandle stdout;
18 20
19int call_prom(const char *service, int nargs, int nret, ...) 21extern char _end[];
22
23/* Value picked to match that used by yaboot */
24#define PROG_START 0x01400000 /* only used on 64-bit systems */
25#define RAM_END (512<<20) /* Fixme: use OF */
26#define ONE_MB 0x100000
27
28int (*prom) (void *);
29
30
31static unsigned long claim_base;
32
33static int call_prom(const char *service, int nargs, int nret, ...)
20{ 34{
21 int i; 35 int i;
22 struct prom_args { 36 struct prom_args {
@@ -45,7 +59,7 @@ int call_prom(const char *service, int nargs, int nret, ...)
45 return (nret > 0)? args.args[nargs]: 0; 59 return (nret > 0)? args.args[nargs]: 0;
46} 60}
47 61
48int call_prom_ret(const char *service, int nargs, int nret, 62static int call_prom_ret(const char *service, int nargs, int nret,
49 unsigned int *rets, ...) 63 unsigned int *rets, ...)
50{ 64{
51 int i; 65 int i;
@@ -79,11 +93,6 @@ int call_prom_ret(const char *service, int nargs, int nret,
79 return (nret > 0)? args.args[nargs]: 0; 93 return (nret > 0)? args.args[nargs]: 0;
80} 94}
81 95
82int write(void *handle, void *ptr, int nb)
83{
84 return call_prom("write", 3, 1, handle, ptr, nb);
85}
86
87/* 96/*
88 * Older OF's require that when claiming a specific range of addresses, 97 * Older OF's require that when claiming a specific range of addresses,
89 * we claim the physical space in the /memory node and the virtual 98 * we claim the physical space in the /memory node and the virtual
@@ -142,7 +151,7 @@ static int check_of_version(void)
142 return 1; 151 return 1;
143} 152}
144 153
145void *claim(unsigned long virt, unsigned long size, unsigned long align) 154static void *claim(unsigned long virt, unsigned long size, unsigned long align)
146{ 155{
147 int ret; 156 int ret;
148 unsigned int result; 157 unsigned int result;
@@ -151,7 +160,7 @@ void *claim(unsigned long virt, unsigned long size, unsigned long align)
151 need_map = check_of_version(); 160 need_map = check_of_version();
152 if (align || !need_map) 161 if (align || !need_map)
153 return (void *) call_prom("claim", 3, 1, virt, size, align); 162 return (void *) call_prom("claim", 3, 1, virt, size, align);
154 163
155 ret = call_prom_ret("call-method", 5, 2, &result, "claim", memory, 164 ret = call_prom_ret("call-method", 5, 2, &result, "claim", memory,
156 align, size, virt); 165 align, size, virt);
157 if (ret != 0 || result == -1) 166 if (ret != 0 || result == -1)
@@ -163,3 +172,112 @@ void *claim(unsigned long virt, unsigned long size, unsigned long align)
163 0x12, size, virt, virt); 172 0x12, size, virt, virt);
164 return (void *) virt; 173 return (void *) virt;
165} 174}
175
176static void *of_try_claim(u32 size)
177{
178 unsigned long addr = 0;
179 static u8 first_time = 1;
180
181 if (first_time) {
182 claim_base = _ALIGN_UP((unsigned long)_end, ONE_MB);
183 first_time = 0;
184 }
185
186 for(; claim_base < RAM_END; claim_base += ONE_MB) {
187#ifdef DEBUG
188 printf(" trying: 0x%08lx\n\r", claim_base);
189#endif
190 addr = (unsigned long)claim(claim_base, size, 0);
191 if ((void *)addr != (void *)-1)
192 break;
193 }
194 if (addr == 0)
195 return NULL;
196 claim_base = PAGE_ALIGN(claim_base + size);
197 return (void *)addr;
198}
199
200static void of_image_hdr(const void *hdr)
201{
202 const Elf64_Ehdr *elf64 = hdr;
203
204 if (elf64->e_ident[EI_CLASS] == ELFCLASS64) {
205 /*
206 * Maintain a "magic" minimum address. This keeps some older
207 * firmware platforms running.
208 */
209 if (claim_base < PROG_START)
210 claim_base = PROG_START;
211 }
212}
213
214static void of_exit(void)
215{
216 call_prom("exit", 0, 0);
217}
218
219/*
220 * OF device tree routines
221 */
222static void *of_finddevice(const char *name)
223{
224 return (phandle) call_prom("finddevice", 1, 1, name);
225}
226
227static int of_getprop(const void *phandle, const char *name, void *buf,
228 const int buflen)
229{
230 return call_prom("getprop", 4, 1, phandle, name, buf, buflen);
231}
232
233static int of_setprop(const void *phandle, const char *name, const void *buf,
234 const int buflen)
235{
236 return call_prom("setprop", 4, 1, phandle, name, buf, buflen);
237}
238
239/*
240 * OF console routines
241 */
242static void *of_stdout_handle;
243
244static int of_console_open(void)
245{
246 void *devp;
247
248 if (((devp = finddevice("/chosen")) != NULL)
249 && (getprop(devp, "stdout", &of_stdout_handle,
250 sizeof(of_stdout_handle))
251 == sizeof(of_stdout_handle)))
252 return 0;
253
254 return -1;
255}
256
257static void of_console_write(char *buf, int len)
258{
259 call_prom("write", 3, 1, of_stdout_handle, buf, len);
260}
261
262int platform_init(void *promptr)
263{
264 platform_ops.fixups = NULL;
265 platform_ops.image_hdr = of_image_hdr;
266 platform_ops.malloc = of_try_claim;
267 platform_ops.free = NULL;
268 platform_ops.exit = of_exit;
269
270 dt_ops.finddevice = of_finddevice;
271 dt_ops.getprop = of_getprop;
272 dt_ops.setprop = of_setprop;
273 dt_ops.translate_addr = NULL;
274
275 console_ops.open = of_console_open;
276 console_ops.write = of_console_write;
277 console_ops.edit_cmdline = NULL;
278 console_ops.close = NULL;
279 console_ops.data = NULL;
280
281 prom = (int (*)(void *))promptr;
282 return 0;
283}
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
new file mode 100644
index 000000000000..135eb4bb03b4
--- /dev/null
+++ b/arch/powerpc/boot/ops.h
@@ -0,0 +1,100 @@
1/*
2 * Global definition of all the bootwrapper operations.
3 *
4 * Author: Mark A. Greer <mgreer@mvista.com>
5 *
6 * 2006 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11#ifndef _PPC_BOOT_OPS_H_
12#define _PPC_BOOT_OPS_H_
13
14#include "types.h"
15
16#define COMMAND_LINE_SIZE 512
17#define MAX_PATH_LEN 256
18#define MAX_PROP_LEN 256 /* What should this be? */
19
20/* Platform specific operations */
21struct platform_ops {
22 void (*fixups)(void);
23 void (*image_hdr)(const void *);
24 void * (*malloc)(u32 size);
25 void (*free)(void *ptr, u32 size);
26 void (*exit)(void);
27};
28extern struct platform_ops platform_ops;
29
30/* Device Tree operations */
31struct dt_ops {
32 void * (*finddevice)(const char *name);
33 int (*getprop)(const void *node, const char *name, void *buf,
34 const int buflen);
35 int (*setprop)(const void *node, const char *name,
36 const void *buf, const int buflen);
37 u64 (*translate_addr)(const char *path, const u32 *in_addr,
38 const u32 addr_len);
39 unsigned long (*ft_addr)(void);
40};
41extern struct dt_ops dt_ops;
42
43/* Console operations */
44struct console_ops {
45 int (*open)(void);
46 void (*write)(char *buf, int len);
47 void (*edit_cmdline)(char *buf, int len);
48 void (*close)(void);
49 void *data;
50};
51extern struct console_ops console_ops;
52
53/* Serial console operations */
54struct serial_console_data {
55 int (*open)(void);
56 void (*putc)(unsigned char c);
57 unsigned char (*getc)(void);
58 u8 (*tstc)(void);
59 void (*close)(void);
60};
61
62extern int platform_init(void *promptr);
63extern void simple_alloc_init(void);
64extern void ft_init(void *dt_blob);
65extern int serial_console_init(void);
66
67static inline void *finddevice(const char *name)
68{
69 return (dt_ops.finddevice) ? dt_ops.finddevice(name) : NULL;
70}
71
72static inline int getprop(void *devp, const char *name, void *buf, int buflen)
73{
74 return (dt_ops.getprop) ? dt_ops.getprop(devp, name, buf, buflen) : -1;
75}
76
77static inline int setprop(void *devp, const char *name, void *buf, int buflen)
78{
79 return (dt_ops.setprop) ? dt_ops.setprop(devp, name, buf, buflen) : -1;
80}
81
82static inline void *malloc(u32 size)
83{
84 return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL;
85}
86
87static inline void free(void *ptr, u32 size)
88{
89 if (platform_ops.free)
90 platform_ops.free(ptr, size);
91}
92
93static inline void exit(void)
94{
95 if (platform_ops.exit)
96 platform_ops.exit();
97 for(;;);
98}
99
100#endif /* _PPC_BOOT_OPS_H_ */
diff --git a/arch/powerpc/boot/prom.h b/arch/powerpc/boot/prom.h
deleted file mode 100644
index a57b184c564f..000000000000
--- a/arch/powerpc/boot/prom.h
+++ /dev/null
@@ -1,41 +0,0 @@
1#ifndef _PPC_BOOT_PROM_H_
2#define _PPC_BOOT_PROM_H_
3
4typedef void *phandle;
5typedef void *ihandle;
6
7extern int (*prom) (void *);
8extern phandle chosen_handle;
9extern ihandle stdout;
10
11int call_prom(const char *service, int nargs, int nret, ...);
12int call_prom_ret(const char *service, int nargs, int nret,
13 unsigned int *rets, ...);
14
15extern int write(void *handle, void *ptr, int nb);
16extern void *claim(unsigned long virt, unsigned long size, unsigned long aln);
17
18static inline void exit(void)
19{
20 call_prom("exit", 0, 0);
21}
22
23static inline phandle finddevice(const char *name)
24{
25 return (phandle) call_prom("finddevice", 1, 1, name);
26}
27
28static inline int getprop(void *phandle, const char *name,
29 void *buf, int buflen)
30{
31 return call_prom("getprop", 4, 1, phandle, name, buf, buflen);
32}
33
34
35static inline int setprop(void *phandle, const char *name,
36 void *buf, int buflen)
37{
38 return call_prom("setprop", 4, 1, phandle, name, buf, buflen);
39}
40
41#endif /* _PPC_BOOT_PROM_H_ */
diff --git a/arch/powerpc/boot/stdio.c b/arch/powerpc/boot/stdio.c
index b5aa522f8b77..6d5f6382e1ce 100644
--- a/arch/powerpc/boot/stdio.c
+++ b/arch/powerpc/boot/stdio.c
@@ -10,7 +10,7 @@
10#include <stddef.h> 10#include <stddef.h>
11#include "string.h" 11#include "string.h"
12#include "stdio.h" 12#include "stdio.h"
13#include "prom.h" 13#include "ops.h"
14 14
15size_t strnlen(const char * s, size_t count) 15size_t strnlen(const char * s, size_t count)
16{ 16{
@@ -320,6 +320,6 @@ printf(const char *fmt, ...)
320 va_start(args, fmt); 320 va_start(args, fmt);
321 n = vsprintf(sprint_buf, fmt, args); 321 n = vsprintf(sprint_buf, fmt, args);
322 va_end(args); 322 va_end(args);
323 write(stdout, sprint_buf, n); 323 console_ops.write(sprint_buf, n);
324 return n; 324 return n;
325} 325}
diff --git a/arch/powerpc/boot/stdio.h b/arch/powerpc/boot/stdio.h
index eb9e16c87aef..73b8a91bfb34 100644
--- a/arch/powerpc/boot/stdio.h
+++ b/arch/powerpc/boot/stdio.h
@@ -1,8 +1,16 @@
1#ifndef _PPC_BOOT_STDIO_H_ 1#ifndef _PPC_BOOT_STDIO_H_
2#define _PPC_BOOT_STDIO_H_ 2#define _PPC_BOOT_STDIO_H_
3 3
4#include <stdarg.h>
5
6#define ENOMEM 12 /* Out of Memory */
7#define EINVAL 22 /* Invalid argument */
8#define ENOSPC 28 /* No space left on device */
9
4extern int printf(const char *fmt, ...); 10extern int printf(const char *fmt, ...);
5 11
12#define fprintf(fmt, args...) printf(args)
13
6extern int sprintf(char *buf, const char *fmt, ...); 14extern int sprintf(char *buf, const char *fmt, ...);
7 15
8extern int vsprintf(char *buf, const char *fmt, va_list args); 16extern int vsprintf(char *buf, const char *fmt, va_list args);
diff --git a/arch/powerpc/boot/types.h b/arch/powerpc/boot/types.h
new file mode 100644
index 000000000000..79d26e708677
--- /dev/null
+++ b/arch/powerpc/boot/types.h
@@ -0,0 +1,23 @@
1#ifndef _TYPES_H_
2#define _TYPES_H_
3
4#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
5
6typedef unsigned char u8;
7typedef unsigned short u16;
8typedef unsigned int u32;
9typedef unsigned long long u64;
10
11#define min(x,y) ({ \
12 typeof(x) _x = (x); \
13 typeof(y) _y = (y); \
14 (void) (&_x == &_y); \
15 _x < _y ? _x : _y; })
16
17#define max(x,y) ({ \
18 typeof(x) _x = (x); \
19 typeof(y) _y = (y); \
20 (void) (&_x == &_y); \
21 _x > _y ? _x : _y; })
22
23#endif /* _TYPES_H_ */
diff --git a/arch/powerpc/configs/maple_defconfig b/arch/powerpc/configs/maple_defconfig
index 2860be106f4f..62ba66091a13 100644
--- a/arch/powerpc/configs/maple_defconfig
+++ b/arch/powerpc/configs/maple_defconfig
@@ -496,7 +496,7 @@ CONFIG_E1000=y
496# CONFIG_SKY2 is not set 496# CONFIG_SKY2 is not set
497# CONFIG_SK98LIN is not set 497# CONFIG_SK98LIN is not set
498# CONFIG_VIA_VELOCITY is not set 498# CONFIG_VIA_VELOCITY is not set
499# CONFIG_TIGON3 is not set 499CONFIG_TIGON3=y
500# CONFIG_BNX2 is not set 500# CONFIG_BNX2 is not set
501# CONFIG_MV643XX_ETH is not set 501# CONFIG_MV643XX_ETH is not set
502 502
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 7d32ad0194a4..8b133afbdc20 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -16,7 +16,7 @@ obj-y := semaphore.o cputable.o ptrace.o syscalls.o \
16obj-y += vdso32/ 16obj-y += vdso32/
17obj-$(CONFIG_PPC64) += setup_64.o binfmt_elf32.o sys_ppc32.o \ 17obj-$(CONFIG_PPC64) += setup_64.o binfmt_elf32.o sys_ppc32.o \
18 signal_64.o ptrace32.o \ 18 signal_64.o ptrace32.o \
19 paca.o cpu_setup_power4.o \ 19 paca.o cpu_setup_ppc970.o \
20 firmware.o sysfs.o 20 firmware.o sysfs.o
21obj-$(CONFIG_PPC64) += vdso64/ 21obj-$(CONFIG_PPC64) += vdso64/
22obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o 22obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o
@@ -51,7 +51,7 @@ extra-$(CONFIG_8xx) := head_8xx.o
51extra-y += vmlinux.lds 51extra-y += vmlinux.lds
52 52
53obj-y += time.o prom.o traps.o setup-common.o \ 53obj-y += time.o prom.o traps.o setup-common.o \
54 udbg.o misc.o 54 udbg.o misc.o io.o
55obj-$(CONFIG_PPC32) += entry_32.o setup_32.o misc_32.o 55obj-$(CONFIG_PPC32) += entry_32.o setup_32.o misc_32.o
56obj-$(CONFIG_PPC64) += misc_64.o dma_64.o iommu.o 56obj-$(CONFIG_PPC64) += misc_64.o dma_64.o iommu.o
57obj-$(CONFIG_PPC_MULTIPLATFORM) += prom_init.o 57obj-$(CONFIG_PPC_MULTIPLATFORM) += prom_init.o
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 7ee84968087b..d06f378597bb 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -40,9 +40,10 @@
40#ifdef CONFIG_PPC64 40#ifdef CONFIG_PPC64
41#include <asm/paca.h> 41#include <asm/paca.h>
42#include <asm/lppaca.h> 42#include <asm/lppaca.h>
43#include <asm/iseries/hv_lp_event.h>
44#include <asm/cache.h> 43#include <asm/cache.h>
45#include <asm/compat.h> 44#include <asm/compat.h>
45#include <asm/mmu.h>
46#include <asm/hvcall.h>
46#endif 47#endif
47 48
48#define DEFINE(sym, val) \ 49#define DEFINE(sym, val) \
@@ -136,11 +137,18 @@ int main(void)
136 DEFINE(PACA_STARTPURR, offsetof(struct paca_struct, startpurr)); 137 DEFINE(PACA_STARTPURR, offsetof(struct paca_struct, startpurr));
137 DEFINE(PACA_USER_TIME, offsetof(struct paca_struct, user_time)); 138 DEFINE(PACA_USER_TIME, offsetof(struct paca_struct, user_time));
138 DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time)); 139 DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time));
140 DEFINE(PACA_SLBSHADOWPTR, offsetof(struct paca_struct, slb_shadow_ptr));
141 DEFINE(PACA_DATA_OFFSET, offsetof(struct paca_struct, data_offset));
139 142
143 DEFINE(SLBSHADOW_STACKVSID,
144 offsetof(struct slb_shadow, save_area[SLB_NUM_BOLTED - 1].vsid));
145 DEFINE(SLBSHADOW_STACKESID,
146 offsetof(struct slb_shadow, save_area[SLB_NUM_BOLTED - 1].esid));
140 DEFINE(LPPACASRR0, offsetof(struct lppaca, saved_srr0)); 147 DEFINE(LPPACASRR0, offsetof(struct lppaca, saved_srr0));
141 DEFINE(LPPACASRR1, offsetof(struct lppaca, saved_srr1)); 148 DEFINE(LPPACASRR1, offsetof(struct lppaca, saved_srr1));
142 DEFINE(LPPACAANYINT, offsetof(struct lppaca, int_dword.any_int)); 149 DEFINE(LPPACAANYINT, offsetof(struct lppaca, int_dword.any_int));
143 DEFINE(LPPACADECRINT, offsetof(struct lppaca, int_dword.fields.decr_int)); 150 DEFINE(LPPACADECRINT, offsetof(struct lppaca, int_dword.fields.decr_int));
151 DEFINE(SLBSHADOW_SAVEAREA, offsetof(struct slb_shadow, save_area));
144#endif /* CONFIG_PPC64 */ 152#endif /* CONFIG_PPC64 */
145 153
146 /* RTAS */ 154 /* RTAS */
@@ -159,6 +167,12 @@ int main(void)
159 /* Create extra stack space for SRR0 and SRR1 when calling prom/rtas. */ 167 /* Create extra stack space for SRR0 and SRR1 when calling prom/rtas. */
160 DEFINE(PROM_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs) + 16); 168 DEFINE(PROM_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs) + 16);
161 DEFINE(RTAS_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs) + 16); 169 DEFINE(RTAS_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs) + 16);
170
171 /* hcall statistics */
172 DEFINE(HCALL_STAT_SIZE, sizeof(struct hcall_stats));
173 DEFINE(HCALL_STAT_CALLS, offsetof(struct hcall_stats, num_calls));
174 DEFINE(HCALL_STAT_TB, offsetof(struct hcall_stats, tb_total));
175 DEFINE(HCALL_STAT_PURR, offsetof(struct hcall_stats, purr_total));
162#endif /* CONFIG_PPC64 */ 176#endif /* CONFIG_PPC64 */
163 DEFINE(GPR0, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[0])); 177 DEFINE(GPR0, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[0]));
164 DEFINE(GPR1, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[1])); 178 DEFINE(GPR1, STACK_FRAME_OVERHEAD+offsetof(struct pt_regs, gpr[1]));
@@ -240,6 +254,7 @@ int main(void)
240 DEFINE(CPU_SPEC_PVR_VALUE, offsetof(struct cpu_spec, pvr_value)); 254 DEFINE(CPU_SPEC_PVR_VALUE, offsetof(struct cpu_spec, pvr_value));
241 DEFINE(CPU_SPEC_FEATURES, offsetof(struct cpu_spec, cpu_features)); 255 DEFINE(CPU_SPEC_FEATURES, offsetof(struct cpu_spec, cpu_features));
242 DEFINE(CPU_SPEC_SETUP, offsetof(struct cpu_spec, cpu_setup)); 256 DEFINE(CPU_SPEC_SETUP, offsetof(struct cpu_spec, cpu_setup));
257 DEFINE(CPU_SPEC_RESTORE, offsetof(struct cpu_spec, cpu_restore));
243 258
244#ifndef CONFIG_PPC64 259#ifndef CONFIG_PPC64
245 DEFINE(pbe_address, offsetof(struct pbe, address)); 260 DEFINE(pbe_address, offsetof(struct pbe, address));
diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c
index f4e5e14ee2b6..995fcef156fd 100644
--- a/arch/powerpc/kernel/btext.c
+++ b/arch/powerpc/kernel/btext.c
@@ -158,35 +158,35 @@ int btext_initialize(struct device_node *np)
158{ 158{
159 unsigned int width, height, depth, pitch; 159 unsigned int width, height, depth, pitch;
160 unsigned long address = 0; 160 unsigned long address = 0;
161 u32 *prop; 161 const u32 *prop;
162 162
163 prop = (u32 *)get_property(np, "linux,bootx-width", NULL); 163 prop = get_property(np, "linux,bootx-width", NULL);
164 if (prop == NULL) 164 if (prop == NULL)
165 prop = (u32 *)get_property(np, "width", NULL); 165 prop = get_property(np, "width", NULL);
166 if (prop == NULL) 166 if (prop == NULL)
167 return -EINVAL; 167 return -EINVAL;
168 width = *prop; 168 width = *prop;
169 prop = (u32 *)get_property(np, "linux,bootx-height", NULL); 169 prop = get_property(np, "linux,bootx-height", NULL);
170 if (prop == NULL) 170 if (prop == NULL)
171 prop = (u32 *)get_property(np, "height", NULL); 171 prop = get_property(np, "height", NULL);
172 if (prop == NULL) 172 if (prop == NULL)
173 return -EINVAL; 173 return -EINVAL;
174 height = *prop; 174 height = *prop;
175 prop = (u32 *)get_property(np, "linux,bootx-depth", NULL); 175 prop = get_property(np, "linux,bootx-depth", NULL);
176 if (prop == NULL) 176 if (prop == NULL)
177 prop = (u32 *)get_property(np, "depth", NULL); 177 prop = get_property(np, "depth", NULL);
178 if (prop == NULL) 178 if (prop == NULL)
179 return -EINVAL; 179 return -EINVAL;
180 depth = *prop; 180 depth = *prop;
181 pitch = width * ((depth + 7) / 8); 181 pitch = width * ((depth + 7) / 8);
182 prop = (u32 *)get_property(np, "linux,bootx-linebytes", NULL); 182 prop = get_property(np, "linux,bootx-linebytes", NULL);
183 if (prop == NULL) 183 if (prop == NULL)
184 prop = (u32 *)get_property(np, "linebytes", NULL); 184 prop = get_property(np, "linebytes", NULL);
185 if (prop) 185 if (prop)
186 pitch = *prop; 186 pitch = *prop;
187 if (pitch == 1) 187 if (pitch == 1)
188 pitch = 0x1000; 188 pitch = 0x1000;
189 prop = (u32 *)get_property(np, "address", NULL); 189 prop = get_property(np, "address", NULL);
190 if (prop) 190 if (prop)
191 address = *prop; 191 address = *prop;
192 192
@@ -214,11 +214,11 @@ int btext_initialize(struct device_node *np)
214 214
215int __init btext_find_display(int allow_nonstdout) 215int __init btext_find_display(int allow_nonstdout)
216{ 216{
217 char *name; 217 const char *name;
218 struct device_node *np = NULL; 218 struct device_node *np = NULL;
219 int rc = -ENODEV; 219 int rc = -ENODEV;
220 220
221 name = (char *)get_property(of_chosen, "linux,stdout-path", NULL); 221 name = get_property(of_chosen, "linux,stdout-path", NULL);
222 if (name != NULL) { 222 if (name != NULL) {
223 np = of_find_node_by_path(name); 223 np = of_find_node_by_path(name);
224 if (np != NULL) { 224 if (np != NULL) {
diff --git a/arch/powerpc/kernel/cpu_setup_power4.S b/arch/powerpc/kernel/cpu_setup_ppc970.S
index 76e97aa71c45..652594891d58 100644
--- a/arch/powerpc/kernel/cpu_setup_power4.S
+++ b/arch/powerpc/kernel/cpu_setup_ppc970.S
@@ -16,27 +16,12 @@
16#include <asm/asm-offsets.h> 16#include <asm/asm-offsets.h>
17#include <asm/cache.h> 17#include <asm/cache.h>
18 18
19_GLOBAL(__970_cpu_preinit) 19_GLOBAL(__cpu_preinit_ppc970)
20 /* 20 /* Do nothing if not running in HV mode */
21 * Do nothing if not running in HV mode
22 */
23 mfmsr r0 21 mfmsr r0
24 rldicl. r0,r0,4,63 22 rldicl. r0,r0,4,63
25 beqlr 23 beqlr
26 24
27 /*
28 * Deal only with PPC970 and PPC970FX.
29 */
30 mfspr r0,SPRN_PVR
31 srwi r0,r0,16
32 cmpwi r0,0x39
33 beq 1f
34 cmpwi r0,0x3c
35 beq 1f
36 cmpwi r0,0x44
37 bnelr
381:
39
40 /* Make sure HID4:rm_ci is off before MMU is turned off, that large 25 /* Make sure HID4:rm_ci is off before MMU is turned off, that large
41 * pages are enabled with HID4:61 and clear HID5:DCBZ_size and 26 * pages are enabled with HID4:61 and clear HID5:DCBZ_size and
42 * HID5:DCBZ32_ill 27 * HID5:DCBZ32_ill
@@ -72,23 +57,6 @@ _GLOBAL(__970_cpu_preinit)
72 isync 57 isync
73 blr 58 blr
74 59
75_GLOBAL(__setup_cpu_ppc970)
76 mfspr r0,SPRN_HID0
77 li r11,5 /* clear DOZE and SLEEP */
78 rldimi r0,r11,52,8 /* set NAP and DPM */
79 li r11,0
80 rldimi r0,r11,32,31 /* clear EN_ATTN */
81 mtspr SPRN_HID0,r0
82 mfspr r0,SPRN_HID0
83 mfspr r0,SPRN_HID0
84 mfspr r0,SPRN_HID0
85 mfspr r0,SPRN_HID0
86 mfspr r0,SPRN_HID0
87 mfspr r0,SPRN_HID0
88 sync
89 isync
90 blr
91
92/* Definitions for the table use to save CPU states */ 60/* Definitions for the table use to save CPU states */
93#define CS_HID0 0 61#define CS_HID0 0
94#define CS_HID1 8 62#define CS_HID1 8
@@ -103,33 +71,30 @@ cpu_state_storage:
103 .balign L1_CACHE_BYTES,0 71 .balign L1_CACHE_BYTES,0
104 .text 72 .text
105 73
106/* Called in normal context to backup CPU 0 state. This
107 * does not include cache settings. This function is also
108 * called for machine sleep. This does not include the MMU
109 * setup, BATs, etc... but rather the "special" registers
110 * like HID0, HID1, HID4, etc...
111 */
112_GLOBAL(__save_cpu_setup)
113 /* Some CR fields are volatile, we back it up all */
114 mfcr r7
115
116 /* Get storage ptr */
117 LOAD_REG_IMMEDIATE(r5,cpu_state_storage)
118 74
119 /* We only deal with 970 for now */ 75_GLOBAL(__setup_cpu_ppc970)
120 mfspr r0,SPRN_PVR 76 /* Do nothing if not running in HV mode */
121 srwi r0,r0,16
122 cmpwi r0,0x39
123 beq 1f
124 cmpwi r0,0x3c
125 beq 1f
126 cmpwi r0,0x44
127 bne 2f
128
1291: /* skip if not running in HV mode */
130 mfmsr r0 77 mfmsr r0
131 rldicl. r0,r0,4,63 78 rldicl. r0,r0,4,63
132 beq 2f 79 beqlr
80
81 mfspr r0,SPRN_HID0
82 li r11,5 /* clear DOZE and SLEEP */
83 rldimi r0,r11,52,8 /* set NAP and DPM */
84 li r11,0
85 rldimi r0,r11,32,31 /* clear EN_ATTN */
86 mtspr SPRN_HID0,r0
87 mfspr r0,SPRN_HID0
88 mfspr r0,SPRN_HID0
89 mfspr r0,SPRN_HID0
90 mfspr r0,SPRN_HID0
91 mfspr r0,SPRN_HID0
92 mfspr r0,SPRN_HID0
93 sync
94 isync
95
96 /* Save away cpu state */
97 LOAD_REG_IMMEDIATE(r5,cpu_state_storage)
133 98
134 /* Save HID0,1,4 and 5 */ 99 /* Save HID0,1,4 and 5 */
135 mfspr r3,SPRN_HID0 100 mfspr r3,SPRN_HID0
@@ -141,35 +106,19 @@ _GLOBAL(__save_cpu_setup)
141 mfspr r3,SPRN_HID5 106 mfspr r3,SPRN_HID5
142 std r3,CS_HID5(r5) 107 std r3,CS_HID5(r5)
143 108
1442:
145 mtcr r7
146 blr 109 blr
147 110
148/* Called with no MMU context (typically MSR:IR/DR off) to 111/* Called with no MMU context (typically MSR:IR/DR off) to
149 * restore CPU state as backed up by the previous 112 * restore CPU state as backed up by the previous
150 * function. This does not include cache setting 113 * function. This does not include cache setting
151 */ 114 */
152_GLOBAL(__restore_cpu_setup) 115_GLOBAL(__restore_cpu_ppc970)
153 /* Get storage ptr (FIXME when using anton reloc as we 116 /* Do nothing if not running in HV mode */
154 * are running with translation disabled here
155 */
156 LOAD_REG_IMMEDIATE(r5,cpu_state_storage)
157
158 /* We only deal with 970 for now */
159 mfspr r0,SPRN_PVR
160 srwi r0,r0,16
161 cmpwi r0,0x39
162 beq 1f
163 cmpwi r0,0x3c
164 beq 1f
165 cmpwi r0,0x44
166 bnelr
167
1681: /* skip if not running in HV mode */
169 mfmsr r0 117 mfmsr r0
170 rldicl. r0,r0,4,63 118 rldicl. r0,r0,4,63
171 beqlr 119 beqlr
172 120
121 LOAD_REG_IMMEDIATE(r5,cpu_state_storage)
173 /* Before accessing memory, we make sure rm_ci is clear */ 122 /* Before accessing memory, we make sure rm_ci is clear */
174 li r0,0 123 li r0,0
175 mfspr r3,SPRN_HID4 124 mfspr r3,SPRN_HID4
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 272e43622fd6..190a57e20765 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -39,7 +39,10 @@ extern void __setup_cpu_7400(unsigned long offset, struct cpu_spec* spec);
39extern void __setup_cpu_7410(unsigned long offset, struct cpu_spec* spec); 39extern void __setup_cpu_7410(unsigned long offset, struct cpu_spec* spec);
40extern void __setup_cpu_745x(unsigned long offset, struct cpu_spec* spec); 40extern void __setup_cpu_745x(unsigned long offset, struct cpu_spec* spec);
41#endif /* CONFIG_PPC32 */ 41#endif /* CONFIG_PPC32 */
42#ifdef CONFIG_PPC64
42extern void __setup_cpu_ppc970(unsigned long offset, struct cpu_spec* spec); 43extern void __setup_cpu_ppc970(unsigned long offset, struct cpu_spec* spec);
44extern void __restore_cpu_ppc970(void);
45#endif /* CONFIG_PPC64 */
43 46
44/* This table only contains "desktop" CPUs, it need to be filled with embedded 47/* This table only contains "desktop" CPUs, it need to be filled with embedded
45 * ones as well... 48 * ones as well...
@@ -55,6 +58,9 @@ extern void __setup_cpu_ppc970(unsigned long offset, struct cpu_spec* spec);
55#define COMMON_USER_POWER6 (COMMON_USER_PPC64 | PPC_FEATURE_ARCH_2_05 |\ 58#define COMMON_USER_POWER6 (COMMON_USER_PPC64 | PPC_FEATURE_ARCH_2_05 |\
56 PPC_FEATURE_SMT | PPC_FEATURE_ICACHE_SNOOP | \ 59 PPC_FEATURE_SMT | PPC_FEATURE_ICACHE_SNOOP | \
57 PPC_FEATURE_TRUE_LE) 60 PPC_FEATURE_TRUE_LE)
61#define COMMON_USER_PA6T (COMMON_USER_PPC64 | PPC_FEATURE_PA6T |\
62 PPC_FEATURE_TRUE_LE | \
63 PPC_FEATURE_HAS_ALTIVEC_COMP)
58#define COMMON_USER_BOOKE (PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU | \ 64#define COMMON_USER_BOOKE (PPC_FEATURE_32 | PPC_FEATURE_HAS_MMU | \
59 PPC_FEATURE_BOOKE) 65 PPC_FEATURE_BOOKE)
60 66
@@ -184,6 +190,7 @@ struct cpu_spec cpu_specs[] = {
184 .dcache_bsize = 128, 190 .dcache_bsize = 128,
185 .num_pmcs = 8, 191 .num_pmcs = 8,
186 .cpu_setup = __setup_cpu_ppc970, 192 .cpu_setup = __setup_cpu_ppc970,
193 .cpu_restore = __restore_cpu_ppc970,
187 .oprofile_cpu_type = "ppc64/970", 194 .oprofile_cpu_type = "ppc64/970",
188 .oprofile_type = PPC_OPROFILE_POWER4, 195 .oprofile_type = PPC_OPROFILE_POWER4,
189 .platform = "ppc970", 196 .platform = "ppc970",
@@ -199,6 +206,7 @@ struct cpu_spec cpu_specs[] = {
199 .dcache_bsize = 128, 206 .dcache_bsize = 128,
200 .num_pmcs = 8, 207 .num_pmcs = 8,
201 .cpu_setup = __setup_cpu_ppc970, 208 .cpu_setup = __setup_cpu_ppc970,
209 .cpu_restore = __restore_cpu_ppc970,
202 .oprofile_cpu_type = "ppc64/970", 210 .oprofile_cpu_type = "ppc64/970",
203 .oprofile_type = PPC_OPROFILE_POWER4, 211 .oprofile_type = PPC_OPROFILE_POWER4,
204 .platform = "ppc970", 212 .platform = "ppc970",
@@ -214,6 +222,7 @@ struct cpu_spec cpu_specs[] = {
214 .dcache_bsize = 128, 222 .dcache_bsize = 128,
215 .num_pmcs = 8, 223 .num_pmcs = 8,
216 .cpu_setup = __setup_cpu_ppc970, 224 .cpu_setup = __setup_cpu_ppc970,
225 .cpu_restore = __restore_cpu_ppc970,
217 .oprofile_cpu_type = "ppc64/970", 226 .oprofile_cpu_type = "ppc64/970",
218 .oprofile_type = PPC_OPROFILE_POWER4, 227 .oprofile_type = PPC_OPROFILE_POWER4,
219 .platform = "ppc970", 228 .platform = "ppc970",
@@ -280,6 +289,17 @@ struct cpu_spec cpu_specs[] = {
280 .dcache_bsize = 128, 289 .dcache_bsize = 128,
281 .platform = "ppc-cell-be", 290 .platform = "ppc-cell-be",
282 }, 291 },
292 { /* PA Semi PA6T */
293 .pvr_mask = 0x7fff0000,
294 .pvr_value = 0x00900000,
295 .cpu_name = "PA6T",
296 .cpu_features = CPU_FTRS_PA6T,
297 .cpu_user_features = COMMON_USER_PA6T,
298 .icache_bsize = 64,
299 .dcache_bsize = 64,
300 .num_pmcs = 6,
301 .platform = "pa6t",
302 },
283 { /* default match */ 303 { /* default match */
284 .pvr_mask = 0x00000000, 304 .pvr_mask = 0x00000000,
285 .pvr_value = 0x00000000, 305 .pvr_value = 0x00000000,
@@ -929,6 +949,7 @@ struct cpu_spec cpu_specs[] = {
929 PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC, 949 PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC,
930 .icache_bsize = 32, 950 .icache_bsize = 32,
931 .dcache_bsize = 32, 951 .dcache_bsize = 32,
952 .platform = "ppc405",
932 }, 953 },
933 { /* 405EP */ 954 { /* 405EP */
934 .pvr_mask = 0xffff0000, 955 .pvr_mask = 0xffff0000,
diff --git a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c
index 371973be8d71..2f6f5a7bc69e 100644
--- a/arch/powerpc/kernel/crash_dump.c
+++ b/arch/powerpc/kernel/crash_dump.c
@@ -80,7 +80,7 @@ static int __init parse_savemaxmem(char *p)
80} 80}
81__setup("savemaxmem=", parse_savemaxmem); 81__setup("savemaxmem=", parse_savemaxmem);
82 82
83/* 83/**
84 * copy_oldmem_page - copy one page from "oldmem" 84 * copy_oldmem_page - copy one page from "oldmem"
85 * @pfn: page frame number to be copied 85 * @pfn: page frame number to be copied
86 * @buf: target memory address for the copy; this can be in kernel address 86 * @buf: target memory address for the copy; this can be in kernel address
diff --git a/arch/powerpc/kernel/dma_64.c b/arch/powerpc/kernel/dma_64.c
index 36aaa7663f02..6c168f6ea142 100644
--- a/arch/powerpc/kernel/dma_64.c
+++ b/arch/powerpc/kernel/dma_64.c
@@ -35,10 +35,9 @@ int dma_supported(struct device *dev, u64 mask)
35{ 35{
36 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 36 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
37 37
38 if (dma_ops) 38 BUG_ON(!dma_ops);
39 return dma_ops->dma_supported(dev, mask); 39
40 BUG(); 40 return dma_ops->dma_supported(dev, mask);
41 return 0;
42} 41}
43EXPORT_SYMBOL(dma_supported); 42EXPORT_SYMBOL(dma_supported);
44 43
@@ -66,10 +65,9 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
66{ 65{
67 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 66 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
68 67
69 if (dma_ops) 68 BUG_ON(!dma_ops);
70 return dma_ops->alloc_coherent(dev, size, dma_handle, flag); 69
71 BUG(); 70 return dma_ops->alloc_coherent(dev, size, dma_handle, flag);
72 return NULL;
73} 71}
74EXPORT_SYMBOL(dma_alloc_coherent); 72EXPORT_SYMBOL(dma_alloc_coherent);
75 73
@@ -78,10 +76,9 @@ void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
78{ 76{
79 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 77 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
80 78
81 if (dma_ops) 79 BUG_ON(!dma_ops);
82 dma_ops->free_coherent(dev, size, cpu_addr, dma_handle); 80
83 else 81 dma_ops->free_coherent(dev, size, cpu_addr, dma_handle);
84 BUG();
85} 82}
86EXPORT_SYMBOL(dma_free_coherent); 83EXPORT_SYMBOL(dma_free_coherent);
87 84
@@ -90,10 +87,9 @@ dma_addr_t dma_map_single(struct device *dev, void *cpu_addr, size_t size,
90{ 87{
91 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 88 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
92 89
93 if (dma_ops) 90 BUG_ON(!dma_ops);
94 return dma_ops->map_single(dev, cpu_addr, size, direction); 91
95 BUG(); 92 return dma_ops->map_single(dev, cpu_addr, size, direction);
96 return (dma_addr_t)0;
97} 93}
98EXPORT_SYMBOL(dma_map_single); 94EXPORT_SYMBOL(dma_map_single);
99 95
@@ -102,10 +98,9 @@ void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size,
102{ 98{
103 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 99 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
104 100
105 if (dma_ops) 101 BUG_ON(!dma_ops);
106 dma_ops->unmap_single(dev, dma_addr, size, direction); 102
107 else 103 dma_ops->unmap_single(dev, dma_addr, size, direction);
108 BUG();
109} 104}
110EXPORT_SYMBOL(dma_unmap_single); 105EXPORT_SYMBOL(dma_unmap_single);
111 106
@@ -115,11 +110,10 @@ dma_addr_t dma_map_page(struct device *dev, struct page *page,
115{ 110{
116 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 111 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
117 112
118 if (dma_ops) 113 BUG_ON(!dma_ops);
119 return dma_ops->map_single(dev, 114
120 (page_address(page) + offset), size, direction); 115 return dma_ops->map_single(dev, page_address(page) + offset, size,
121 BUG(); 116 direction);
122 return (dma_addr_t)0;
123} 117}
124EXPORT_SYMBOL(dma_map_page); 118EXPORT_SYMBOL(dma_map_page);
125 119
@@ -128,10 +122,9 @@ void dma_unmap_page(struct device *dev, dma_addr_t dma_address, size_t size,
128{ 122{
129 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 123 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
130 124
131 if (dma_ops) 125 BUG_ON(!dma_ops);
132 dma_ops->unmap_single(dev, dma_address, size, direction); 126
133 else 127 dma_ops->unmap_single(dev, dma_address, size, direction);
134 BUG();
135} 128}
136EXPORT_SYMBOL(dma_unmap_page); 129EXPORT_SYMBOL(dma_unmap_page);
137 130
@@ -140,10 +133,9 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
140{ 133{
141 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 134 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
142 135
143 if (dma_ops) 136 BUG_ON(!dma_ops);
144 return dma_ops->map_sg(dev, sg, nents, direction); 137
145 BUG(); 138 return dma_ops->map_sg(dev, sg, nents, direction);
146 return 0;
147} 139}
148EXPORT_SYMBOL(dma_map_sg); 140EXPORT_SYMBOL(dma_map_sg);
149 141
@@ -152,9 +144,8 @@ void dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nhwentries,
152{ 144{
153 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 145 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
154 146
155 if (dma_ops) 147 BUG_ON(!dma_ops);
156 dma_ops->unmap_sg(dev, sg, nhwentries, direction); 148
157 else 149 dma_ops->unmap_sg(dev, sg, nhwentries, direction);
158 BUG();
159} 150}
160EXPORT_SYMBOL(dma_unmap_sg); 151EXPORT_SYMBOL(dma_unmap_sg);
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 54d9f5cdaab4..2cd872b5283b 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -375,6 +375,14 @@ BEGIN_FTR_SECTION
375 ld r7,KSP_VSID(r4) /* Get new stack's VSID */ 375 ld r7,KSP_VSID(r4) /* Get new stack's VSID */
376 oris r0,r6,(SLB_ESID_V)@h 376 oris r0,r6,(SLB_ESID_V)@h
377 ori r0,r0,(SLB_NUM_BOLTED-1)@l 377 ori r0,r0,(SLB_NUM_BOLTED-1)@l
378
379 /* Update the last bolted SLB */
380 ld r9,PACA_SLBSHADOWPTR(r13)
381 li r12,0
382 std r12,SLBSHADOW_STACKESID(r9) /* Clear ESID */
383 std r7,SLBSHADOW_STACKVSID(r9) /* Save VSID */
384 std r0,SLBSHADOW_STACKESID(r9) /* Save ESID */
385
378 slbie r6 386 slbie r6
379 slbie r6 /* Workaround POWER5 < DD2.1 issue */ 387 slbie r6 /* Workaround POWER5 < DD2.1 issue */
380 slbmte r7,r0 388 slbmte r7,r0
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 6ff3cf506088..3065b472b95d 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -132,7 +132,7 @@ _GLOBAL(__secondary_hold)
132 bne 100b 132 bne 100b
133 133
134#if defined(CONFIG_SMP) || defined(CONFIG_KEXEC) 134#if defined(CONFIG_SMP) || defined(CONFIG_KEXEC)
135 LOAD_REG_IMMEDIATE(r4, .pSeries_secondary_smp_init) 135 LOAD_REG_IMMEDIATE(r4, .generic_secondary_smp_init)
136 mtctr r4 136 mtctr r4
137 mr r3,r24 137 mr r3,r24
138 bctr 138 bctr
@@ -1484,19 +1484,17 @@ fwnmi_data_area:
1484 . = 0x8000 1484 . = 0x8000
1485 1485
1486/* 1486/*
1487 * On pSeries, secondary processors spin in the following code. 1487 * On pSeries and most other platforms, secondary processors spin
1488 * in the following code.
1488 * At entry, r3 = this processor's number (physical cpu id) 1489 * At entry, r3 = this processor's number (physical cpu id)
1489 */ 1490 */
1490_GLOBAL(pSeries_secondary_smp_init) 1491_GLOBAL(generic_secondary_smp_init)
1491 mr r24,r3 1492 mr r24,r3
1492 1493
1493 /* turn on 64-bit mode */ 1494 /* turn on 64-bit mode */
1494 bl .enable_64b_mode 1495 bl .enable_64b_mode
1495 isync 1496 isync
1496 1497
1497 /* Copy some CPU settings from CPU 0 */
1498 bl .__restore_cpu_setup
1499
1500 /* Set up a paca value for this processor. Since we have the 1498 /* Set up a paca value for this processor. Since we have the
1501 * physical cpu id in r24, we need to search the pacas to find 1499 * physical cpu id in r24, we need to search the pacas to find
1502 * which logical id maps to our physical one. 1500 * which logical id maps to our physical one.
@@ -1522,15 +1520,28 @@ _GLOBAL(pSeries_secondary_smp_init)
1522 /* start. */ 1520 /* start. */
1523 sync 1521 sync
1524 1522
1525 /* Create a temp kernel stack for use before relocation is on. */ 1523#ifndef CONFIG_SMP
1524 b 3b /* Never go on non-SMP */
1525#else
1526 cmpwi 0,r23,0
1527 beq 3b /* Loop until told to go */
1528
1529 /* See if we need to call a cpu state restore handler */
1530 LOAD_REG_IMMEDIATE(r23, cur_cpu_spec)
1531 ld r23,0(r23)
1532 ld r23,CPU_SPEC_RESTORE(r23)
1533 cmpdi 0,r23,0
1534 beq 4f
1535 ld r23,0(r23)
1536 mtctr r23
1537 bctrl
1538
15394: /* Create a temp kernel stack for use before relocation is on. */
1526 ld r1,PACAEMERGSP(r13) 1540 ld r1,PACAEMERGSP(r13)
1527 subi r1,r1,STACK_FRAME_OVERHEAD 1541 subi r1,r1,STACK_FRAME_OVERHEAD
1528 1542
1529 cmpwi 0,r23,0 1543 b .__secondary_start
1530#ifdef CONFIG_SMP
1531 bne .__secondary_start
1532#endif 1544#endif
1533 b 3b /* Loop until told to go */
1534 1545
1535#ifdef CONFIG_PPC_ISERIES 1546#ifdef CONFIG_PPC_ISERIES
1536_STATIC(__start_initialization_iSeries) 1547_STATIC(__start_initialization_iSeries)
@@ -1611,7 +1622,16 @@ _GLOBAL(__start_initialization_multiplatform)
1611 bl .enable_64b_mode 1622 bl .enable_64b_mode
1612 1623
1613 /* Setup some critical 970 SPRs before switching MMU off */ 1624 /* Setup some critical 970 SPRs before switching MMU off */
1614 bl .__970_cpu_preinit 1625 mfspr r0,SPRN_PVR
1626 srwi r0,r0,16
1627 cmpwi r0,0x39 /* 970 */
1628 beq 1f
1629 cmpwi r0,0x3c /* 970FX */
1630 beq 1f
1631 cmpwi r0,0x44 /* 970MP */
1632 bne 2f
16331: bl .__cpu_preinit_ppc970
16342:
1615 1635
1616 /* Switch off MMU if not already */ 1636 /* Switch off MMU if not already */
1617 LOAD_REG_IMMEDIATE(r4, .__after_prom_start - KERNELBASE) 1637 LOAD_REG_IMMEDIATE(r4, .__after_prom_start - KERNELBASE)
@@ -1728,7 +1748,7 @@ _STATIC(__after_prom_start)
1728_GLOBAL(copy_and_flush) 1748_GLOBAL(copy_and_flush)
1729 addi r5,r5,-8 1749 addi r5,r5,-8
1730 addi r6,r6,-8 1750 addi r6,r6,-8
17314: li r0,16 /* Use the least common */ 17514: li r0,8 /* Use the smallest common */
1732 /* denominator cache line */ 1752 /* denominator cache line */
1733 /* size. This results in */ 1753 /* size. This results in */
1734 /* extra cache line flushes */ 1754 /* extra cache line flushes */
@@ -1782,7 +1802,7 @@ _GLOBAL(pmac_secondary_start)
1782 isync 1802 isync
1783 1803
1784 /* Copy some CPU settings from CPU 0 */ 1804 /* Copy some CPU settings from CPU 0 */
1785 bl .__restore_cpu_setup 1805 bl .__restore_cpu_ppc970
1786 1806
1787 /* pSeries do that early though I don't think we really need it */ 1807 /* pSeries do that early though I don't think we really need it */
1788 mfmsr r3 1808 mfmsr r3
@@ -1932,12 +1952,6 @@ _STATIC(start_here_multiplatform)
1932 mr r5,r26 1952 mr r5,r26
1933 bl .identify_cpu 1953 bl .identify_cpu
1934 1954
1935 /* Save some low level config HIDs of CPU0 to be copied to
1936 * other CPUs later on, or used for suspend/resume
1937 */
1938 bl .__save_cpu_setup
1939 sync
1940
1941 /* Do very early kernel initializations, including initial hash table, 1955 /* Do very early kernel initializations, including initial hash table,
1942 * stab and slb setup before we turn on relocation. */ 1956 * stab and slb setup before we turn on relocation. */
1943 1957
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index 68e5ab0443d2..124dbcba94a8 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -167,7 +167,7 @@ static DEVICE_ATTR(name, S_IRUSR | S_IRGRP | S_IROTH, ibmebusdev_show_name,
167 NULL); 167 NULL);
168 168
169static struct ibmebus_dev* __devinit ibmebus_register_device_common( 169static struct ibmebus_dev* __devinit ibmebus_register_device_common(
170 struct ibmebus_dev *dev, char *name) 170 struct ibmebus_dev *dev, const char *name)
171{ 171{
172 int err = 0; 172 int err = 0;
173 173
@@ -194,10 +194,10 @@ static struct ibmebus_dev* __devinit ibmebus_register_device_node(
194 struct device_node *dn) 194 struct device_node *dn)
195{ 195{
196 struct ibmebus_dev *dev; 196 struct ibmebus_dev *dev;
197 char *loc_code; 197 const char *loc_code;
198 int length; 198 int length;
199 199
200 loc_code = (char *)get_property(dn, "ibm,loc-code", NULL); 200 loc_code = get_property(dn, "ibm,loc-code", NULL);
201 if (!loc_code) { 201 if (!loc_code) {
202 printk(KERN_WARNING "%s: node %s missing 'ibm,loc-code'\n", 202 printk(KERN_WARNING "%s: node %s missing 'ibm,loc-code'\n",
203 __FUNCTION__, dn->name ? dn->name : "<unknown>"); 203 __FUNCTION__, dn->name ? dn->name : "<unknown>");
diff --git a/arch/powerpc/kernel/io.c b/arch/powerpc/kernel/io.c
new file mode 100644
index 000000000000..e98180686b35
--- /dev/null
+++ b/arch/powerpc/kernel/io.c
@@ -0,0 +1,131 @@
1/*
2 * I/O string operations
3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
4 * Copyright (C) 2006 IBM Corporation
5 *
6 * Largely rewritten by Cort Dougan (cort@cs.nmt.edu)
7 * and Paul Mackerras.
8 *
9 * Adapted for iSeries by Mike Corrigan (mikejc@us.ibm.com)
10 * PPC64 updates by Dave Engebretsen (engebret@us.ibm.com)
11 *
12 * Rewritten in C by Stephen Rothwell.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 */
19#include <linux/kernel.h>
20#include <linux/types.h>
21#include <linux/compiler.h>
22#include <linux/module.h>
23
24#include <asm/io.h>
25#include <asm/firmware.h>
26#include <asm/bug.h>
27
28void _insb(volatile u8 __iomem *port, void *buf, long count)
29{
30 u8 *tbuf = buf;
31 u8 tmp;
32
33 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
34
35 if (unlikely(count <= 0))
36 return;
37 asm volatile("sync");
38 do {
39 tmp = *port;
40 asm volatile("eieio");
41 *tbuf++ = tmp;
42 } while (--count != 0);
43 asm volatile("twi 0,%0,0; isync" : : "r" (tmp));
44}
45EXPORT_SYMBOL(_insb);
46
47void _outsb(volatile u8 __iomem *port, const void *buf, long count)
48{
49 const u8 *tbuf = buf;
50
51 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
52
53 if (unlikely(count <= 0))
54 return;
55 asm volatile("sync");
56 do {
57 *port = *tbuf++;
58 } while (--count != 0);
59 asm volatile("sync");
60}
61EXPORT_SYMBOL(_outsb);
62
63void _insw_ns(volatile u16 __iomem *port, void *buf, long count)
64{
65 u16 *tbuf = buf;
66 u16 tmp;
67
68 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
69
70 if (unlikely(count <= 0))
71 return;
72 asm volatile("sync");
73 do {
74 tmp = *port;
75 asm volatile("eieio");
76 *tbuf++ = tmp;
77 } while (--count != 0);
78 asm volatile("twi 0,%0,0; isync" : : "r" (tmp));
79}
80EXPORT_SYMBOL(_insw_ns);
81
82void _outsw_ns(volatile u16 __iomem *port, const void *buf, long count)
83{
84 const u16 *tbuf = buf;
85
86 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
87
88 if (unlikely(count <= 0))
89 return;
90 asm volatile("sync");
91 do {
92 *port = *tbuf++;
93 } while (--count != 0);
94 asm volatile("sync");
95}
96EXPORT_SYMBOL(_outsw_ns);
97
98void _insl_ns(volatile u32 __iomem *port, void *buf, long count)
99{
100 u32 *tbuf = buf;
101 u32 tmp;
102
103 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
104
105 if (unlikely(count <= 0))
106 return;
107 asm volatile("sync");
108 do {
109 tmp = *port;
110 asm volatile("eieio");
111 *tbuf++ = tmp;
112 } while (--count != 0);
113 asm volatile("twi 0,%0,0; isync" : : "r" (tmp));
114}
115EXPORT_SYMBOL(_insl_ns);
116
117void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count)
118{
119 const u32 *tbuf = buf;
120
121 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
122
123 if (unlikely(count <= 0))
124 return;
125 asm volatile("sync");
126 do {
127 *port = *tbuf++;
128 } while (--count != 0);
129 asm volatile("sync");
130}
131EXPORT_SYMBOL(_outsl_ns);
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 12c5971d6565..b4432332341f 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -52,6 +52,7 @@
52#include <linux/radix-tree.h> 52#include <linux/radix-tree.h>
53#include <linux/mutex.h> 53#include <linux/mutex.h>
54#include <linux/bootmem.h> 54#include <linux/bootmem.h>
55#include <linux/pci.h>
55 56
56#include <asm/uaccess.h> 57#include <asm/uaccess.h>
57#include <asm/system.h> 58#include <asm/system.h>
@@ -875,12 +876,14 @@ int pci_enable_msi(struct pci_dev * pdev)
875 else 876 else
876 return -1; 877 return -1;
877} 878}
879EXPORT_SYMBOL(pci_enable_msi);
878 880
879void pci_disable_msi(struct pci_dev * pdev) 881void pci_disable_msi(struct pci_dev * pdev)
880{ 882{
881 if (ppc_md.disable_msi) 883 if (ppc_md.disable_msi)
882 ppc_md.disable_msi(pdev); 884 ppc_md.disable_msi(pdev);
883} 885}
886EXPORT_SYMBOL(pci_disable_msi);
884 887
885void pci_scan_msi_device(struct pci_dev *dev) {} 888void pci_scan_msi_device(struct pci_dev *dev) {}
886int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec) {return -1;} 889int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec) {return -1;}
@@ -888,6 +891,8 @@ void pci_disable_msix(struct pci_dev *dev) {}
888void msi_remove_pci_irq_vectors(struct pci_dev *dev) {} 891void msi_remove_pci_irq_vectors(struct pci_dev *dev) {}
889void disable_msi_mode(struct pci_dev *dev, int pos, int type) {} 892void disable_msi_mode(struct pci_dev *dev, int pos, int type) {}
890void pci_no_msi(void) {} 893void pci_no_msi(void) {}
894EXPORT_SYMBOL(pci_enable_msix);
895EXPORT_SYMBOL(pci_disable_msix);
891 896
892#endif 897#endif
893 898
diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index 40a39291861f..5e6ddfa474c0 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -39,16 +39,17 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
39 phys_addr_t taddr, unsigned long irq, 39 phys_addr_t taddr, unsigned long irq,
40 upf_t flags, int irq_check_parent) 40 upf_t flags, int irq_check_parent)
41{ 41{
42 u32 *clk, *spd, clock = BASE_BAUD * 16; 42 const u32 *clk, *spd;
43 u32 clock = BASE_BAUD * 16;
43 int index; 44 int index;
44 45
45 /* get clock freq. if present */ 46 /* get clock freq. if present */
46 clk = (u32 *)get_property(np, "clock-frequency", NULL); 47 clk = get_property(np, "clock-frequency", NULL);
47 if (clk && *clk) 48 if (clk && *clk)
48 clock = *clk; 49 clock = *clk;
49 50
50 /* get default speed if present */ 51 /* get default speed if present */
51 spd = (u32 *)get_property(np, "current-speed", NULL); 52 spd = get_property(np, "current-speed", NULL);
52 53
53 /* If we have a location index, then try to use it */ 54 /* If we have a location index, then try to use it */
54 if (want_index >= 0 && want_index < MAX_LEGACY_SERIAL_PORTS) 55 if (want_index >= 0 && want_index < MAX_LEGACY_SERIAL_PORTS)
@@ -113,7 +114,7 @@ static int __init add_legacy_soc_port(struct device_node *np,
113 struct device_node *soc_dev) 114 struct device_node *soc_dev)
114{ 115{
115 u64 addr; 116 u64 addr;
116 u32 *addrp; 117 const u32 *addrp;
117 upf_t flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_SHARE_IRQ; 118 upf_t flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_SHARE_IRQ;
118 struct device_node *tsi = of_get_parent(np); 119 struct device_node *tsi = of_get_parent(np);
119 120
@@ -144,15 +145,15 @@ static int __init add_legacy_soc_port(struct device_node *np,
144static int __init add_legacy_isa_port(struct device_node *np, 145static int __init add_legacy_isa_port(struct device_node *np,
145 struct device_node *isa_brg) 146 struct device_node *isa_brg)
146{ 147{
147 u32 *reg; 148 const u32 *reg;
148 char *typep; 149 const char *typep;
149 int index = -1; 150 int index = -1;
150 u64 taddr; 151 u64 taddr;
151 152
152 DBG(" -> add_legacy_isa_port(%s)\n", np->full_name); 153 DBG(" -> add_legacy_isa_port(%s)\n", np->full_name);
153 154
154 /* Get the ISA port number */ 155 /* Get the ISA port number */
155 reg = (u32 *)get_property(np, "reg", NULL); 156 reg = get_property(np, "reg", NULL);
156 if (reg == NULL) 157 if (reg == NULL)
157 return -1; 158 return -1;
158 159
@@ -163,7 +164,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
163 /* Now look for an "ibm,aix-loc" property that gives us ordering 164 /* Now look for an "ibm,aix-loc" property that gives us ordering
164 * if any... 165 * if any...
165 */ 166 */
166 typep = (char *)get_property(np, "ibm,aix-loc", NULL); 167 typep = get_property(np, "ibm,aix-loc", NULL);
167 168
168 /* If we have a location index, then use it */ 169 /* If we have a location index, then use it */
169 if (typep && *typep == 'S') 170 if (typep && *typep == 'S')
@@ -188,7 +189,7 @@ static int __init add_legacy_pci_port(struct device_node *np,
188 struct device_node *pci_dev) 189 struct device_node *pci_dev)
189{ 190{
190 u64 addr, base; 191 u64 addr, base;
191 u32 *addrp; 192 const u32 *addrp;
192 unsigned int flags; 193 unsigned int flags;
193 int iotype, index = -1, lindex = 0; 194 int iotype, index = -1, lindex = 0;
194 195
@@ -227,7 +228,7 @@ static int __init add_legacy_pci_port(struct device_node *np,
227 * we get to their "reg" property 228 * we get to their "reg" property
228 */ 229 */
229 if (np != pci_dev) { 230 if (np != pci_dev) {
230 u32 *reg = (u32 *)get_property(np, "reg", NULL); 231 const u32 *reg = get_property(np, "reg", NULL);
231 if (reg && (*reg < 4)) 232 if (reg && (*reg < 4))
232 index = lindex = *reg; 233 index = lindex = *reg;
233 } 234 }
@@ -285,13 +286,13 @@ static void __init setup_legacy_serial_console(int console)
285void __init find_legacy_serial_ports(void) 286void __init find_legacy_serial_ports(void)
286{ 287{
287 struct device_node *np, *stdout = NULL; 288 struct device_node *np, *stdout = NULL;
288 char *path; 289 const char *path;
289 int index; 290 int index;
290 291
291 DBG(" -> find_legacy_serial_port()\n"); 292 DBG(" -> find_legacy_serial_port()\n");
292 293
293 /* Now find out if one of these is out firmware console */ 294 /* Now find out if one of these is out firmware console */
294 path = (char *)get_property(of_chosen, "linux,stdout-path", NULL); 295 path = get_property(of_chosen, "linux,stdout-path", NULL);
295 if (path != NULL) { 296 if (path != NULL) {
296 stdout = of_find_node_by_path(path); 297 stdout = of_find_node_by_path(path);
297 if (stdout) 298 if (stdout)
@@ -491,8 +492,8 @@ static int __init check_legacy_serial_console(void)
491{ 492{
492 struct device_node *prom_stdout = NULL; 493 struct device_node *prom_stdout = NULL;
493 int speed = 0, offset = 0; 494 int speed = 0, offset = 0;
494 char *name; 495 const char *name;
495 u32 *spd; 496 const u32 *spd;
496 497
497 DBG(" -> check_legacy_serial_console()\n"); 498 DBG(" -> check_legacy_serial_console()\n");
498 499
@@ -513,7 +514,7 @@ static int __init check_legacy_serial_console(void)
513 } 514 }
514 /* We are getting a weird phandle from OF ... */ 515 /* We are getting a weird phandle from OF ... */
515 /* ... So use the full path instead */ 516 /* ... So use the full path instead */
516 name = (char *)get_property(of_chosen, "linux,stdout-path", NULL); 517 name = get_property(of_chosen, "linux,stdout-path", NULL);
517 if (name == NULL) { 518 if (name == NULL) {
518 DBG(" no linux,stdout-path !\n"); 519 DBG(" no linux,stdout-path !\n");
519 return -ENODEV; 520 return -ENODEV;
@@ -525,12 +526,12 @@ static int __init check_legacy_serial_console(void)
525 } 526 }
526 DBG("stdout is %s\n", prom_stdout->full_name); 527 DBG("stdout is %s\n", prom_stdout->full_name);
527 528
528 name = (char *)get_property(prom_stdout, "name", NULL); 529 name = get_property(prom_stdout, "name", NULL);
529 if (!name) { 530 if (!name) {
530 DBG(" stdout package has no name !\n"); 531 DBG(" stdout package has no name !\n");
531 goto not_found; 532 goto not_found;
532 } 533 }
533 spd = (u32 *)get_property(prom_stdout, "current-speed", NULL); 534 spd = get_property(prom_stdout, "current-speed", NULL);
534 if (spd) 535 if (spd)
535 speed = *spd; 536 speed = *spd;
536 537
diff --git a/arch/powerpc/kernel/lparcfg.c b/arch/powerpc/kernel/lparcfg.c
index 23f34daa044a..41c05dcd68f4 100644
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -32,7 +32,6 @@
32#include <asm/rtas.h> 32#include <asm/rtas.h>
33#include <asm/system.h> 33#include <asm/system.h>
34#include <asm/time.h> 34#include <asm/time.h>
35#include <asm/iseries/it_exp_vpd_panel.h>
36#include <asm/prom.h> 35#include <asm/prom.h>
37#include <asm/vdso_datapage.h> 36#include <asm/vdso_datapage.h>
38 37
@@ -183,8 +182,14 @@ static unsigned int h_get_ppp(unsigned long *entitled,
183 unsigned long *resource) 182 unsigned long *resource)
184{ 183{
185 unsigned long rc; 184 unsigned long rc;
186 rc = plpar_hcall_4out(H_GET_PPP, 0, 0, 0, 0, entitled, unallocated, 185 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
187 aggregation, resource); 186
187 rc = plpar_hcall(H_GET_PPP, retbuf);
188
189 *entitled = retbuf[0];
190 *unallocated = retbuf[1];
191 *aggregation = retbuf[2];
192 *resource = retbuf[3];
188 193
189 log_plpar_hcall_return(rc, "H_GET_PPP"); 194 log_plpar_hcall_return(rc, "H_GET_PPP");
190 195
@@ -194,8 +199,12 @@ static unsigned int h_get_ppp(unsigned long *entitled,
194static void h_pic(unsigned long *pool_idle_time, unsigned long *num_procs) 199static void h_pic(unsigned long *pool_idle_time, unsigned long *num_procs)
195{ 200{
196 unsigned long rc; 201 unsigned long rc;
197 unsigned long dummy; 202 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
198 rc = plpar_hcall(H_PIC, 0, 0, 0, 0, pool_idle_time, num_procs, &dummy); 203
204 rc = plpar_hcall(H_PIC, retbuf);
205
206 *pool_idle_time = retbuf[0];
207 *num_procs = retbuf[1];
199 208
200 if (rc != H_AUTHORITY) 209 if (rc != H_AUTHORITY)
201 log_plpar_hcall_return(rc, "H_PIC"); 210 log_plpar_hcall_return(rc, "H_PIC");
@@ -310,12 +319,11 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v)
310 int partition_potential_processors; 319 int partition_potential_processors;
311 int partition_active_processors; 320 int partition_active_processors;
312 struct device_node *rtas_node; 321 struct device_node *rtas_node;
313 int *lrdrp = NULL; 322 const int *lrdrp = NULL;
314 323
315 rtas_node = find_path_device("/rtas"); 324 rtas_node = find_path_device("/rtas");
316 if (rtas_node) 325 if (rtas_node)
317 lrdrp = (int *)get_property(rtas_node, "ibm,lrdr-capacity", 326 lrdrp = get_property(rtas_node, "ibm,lrdr-capacity", NULL);
318 NULL);
319 327
320 if (lrdrp == NULL) { 328 if (lrdrp == NULL) {
321 partition_potential_processors = vdso_data->processorCount; 329 partition_potential_processors = vdso_data->processorCount;
@@ -520,7 +528,8 @@ static int lparcfg_data(struct seq_file *m, void *v)
520 const char *model = ""; 528 const char *model = "";
521 const char *system_id = ""; 529 const char *system_id = "";
522 const char *tmp; 530 const char *tmp;
523 unsigned int *lp_index_ptr, lp_index = 0; 531 const unsigned int *lp_index_ptr;
532 unsigned int lp_index = 0;
524 533
525 seq_printf(m, "%s %s \n", MODULE_NAME, MODULE_VERS); 534 seq_printf(m, "%s %s \n", MODULE_NAME, MODULE_VERS);
526 535
@@ -540,8 +549,7 @@ static int lparcfg_data(struct seq_file *m, void *v)
540 if (firmware_has_feature(FW_FEATURE_ISERIES)) 549 if (firmware_has_feature(FW_FEATURE_ISERIES))
541 system_id += 4; 550 system_id += 4;
542 } 551 }
543 lp_index_ptr = (unsigned int *) 552 lp_index_ptr = get_property(rootdn, "ibm,partition-no", NULL);
544 get_property(rootdn, "ibm,partition-no", NULL);
545 if (lp_index_ptr) 553 if (lp_index_ptr)
546 lp_index = *lp_index_ptr; 554 lp_index = *lp_index_ptr;
547 } 555 }
diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
index be58985c7681..a24b09c27718 100644
--- a/arch/powerpc/kernel/machine_kexec_64.c
+++ b/arch/powerpc/kernel/machine_kexec_64.c
@@ -31,8 +31,8 @@ int default_machine_kexec_prepare(struct kimage *image)
31 unsigned long begin, end; /* limits of segment */ 31 unsigned long begin, end; /* limits of segment */
32 unsigned long low, high; /* limits of blocked memory range */ 32 unsigned long low, high; /* limits of blocked memory range */
33 struct device_node *node; 33 struct device_node *node;
34 unsigned long *basep; 34 const unsigned long *basep;
35 unsigned int *sizep; 35 const unsigned int *sizep;
36 36
37 if (!ppc_md.hpte_clear_all) 37 if (!ppc_md.hpte_clear_all)
38 return -ENOENT; 38 return -ENOENT;
@@ -72,10 +72,8 @@ int default_machine_kexec_prepare(struct kimage *image)
72 /* We also should not overwrite the tce tables */ 72 /* We also should not overwrite the tce tables */
73 for (node = of_find_node_by_type(NULL, "pci"); node != NULL; 73 for (node = of_find_node_by_type(NULL, "pci"); node != NULL;
74 node = of_find_node_by_type(node, "pci")) { 74 node = of_find_node_by_type(node, "pci")) {
75 basep = (unsigned long *)get_property(node, "linux,tce-base", 75 basep = get_property(node, "linux,tce-base", NULL);
76 NULL); 76 sizep = get_property(node, "linux,tce-size", NULL);
77 sizep = (unsigned int *)get_property(node, "linux,tce-size",
78 NULL);
79 if (basep == NULL || sizep == NULL) 77 if (basep == NULL || sizep == NULL)
80 continue; 78 continue;
81 79
diff --git a/arch/powerpc/kernel/misc.S b/arch/powerpc/kernel/misc.S
index f770805f1215..330c9dc7db86 100644
--- a/arch/powerpc/kernel/misc.S
+++ b/arch/powerpc/kernel/misc.S
@@ -43,162 +43,3 @@ _GLOBAL(add_reloc_offset)
43 add r3,r3,r5 43 add r3,r3,r5
44 mtlr r0 44 mtlr r0
45 blr 45 blr
46
47/*
48 * I/O string operations
49 *
50 * insb(port, buf, len)
51 * outsb(port, buf, len)
52 * insw(port, buf, len)
53 * outsw(port, buf, len)
54 * insl(port, buf, len)
55 * outsl(port, buf, len)
56 * insw_ns(port, buf, len)
57 * outsw_ns(port, buf, len)
58 * insl_ns(port, buf, len)
59 * outsl_ns(port, buf, len)
60 *
61 * The *_ns versions don't do byte-swapping.
62 */
63_GLOBAL(_insb)
64 sync
65 cmpwi 0,r5,0
66 mtctr r5
67 subi r4,r4,1
68 blelr-
6900: lbz r5,0(r3)
70 eieio
71 stbu r5,1(r4)
72 bdnz 00b
73 twi 0,r5,0
74 isync
75 blr
76
77_GLOBAL(_outsb)
78 cmpwi 0,r5,0
79 mtctr r5
80 subi r4,r4,1
81 blelr-
82 sync
8300: lbzu r5,1(r4)
84 stb r5,0(r3)
85 bdnz 00b
86 sync
87 blr
88
89_GLOBAL(_insw)
90 sync
91 cmpwi 0,r5,0
92 mtctr r5
93 subi r4,r4,2
94 blelr-
9500: lhbrx r5,0,r3
96 eieio
97 sthu r5,2(r4)
98 bdnz 00b
99 twi 0,r5,0
100 isync
101 blr
102
103_GLOBAL(_outsw)
104 cmpwi 0,r5,0
105 mtctr r5
106 subi r4,r4,2
107 blelr-
108 sync
10900: lhzu r5,2(r4)
110 sthbrx r5,0,r3
111 bdnz 00b
112 sync
113 blr
114
115_GLOBAL(_insl)
116 sync
117 cmpwi 0,r5,0
118 mtctr r5
119 subi r4,r4,4
120 blelr-
12100: lwbrx r5,0,r3
122 eieio
123 stwu r5,4(r4)
124 bdnz 00b
125 twi 0,r5,0
126 isync
127 blr
128
129_GLOBAL(_outsl)
130 cmpwi 0,r5,0
131 mtctr r5
132 subi r4,r4,4
133 blelr-
134 sync
13500: lwzu r5,4(r4)
136 stwbrx r5,0,r3
137 bdnz 00b
138 sync
139 blr
140
141#ifdef CONFIG_PPC32
142_GLOBAL(__ide_mm_insw)
143#endif
144_GLOBAL(_insw_ns)
145 sync
146 cmpwi 0,r5,0
147 mtctr r5
148 subi r4,r4,2
149 blelr-
15000: lhz r5,0(r3)
151 eieio
152 sthu r5,2(r4)
153 bdnz 00b
154 twi 0,r5,0
155 isync
156 blr
157
158#ifdef CONFIG_PPC32
159_GLOBAL(__ide_mm_outsw)
160#endif
161_GLOBAL(_outsw_ns)
162 cmpwi 0,r5,0
163 mtctr r5
164 subi r4,r4,2
165 blelr-
166 sync
16700: lhzu r5,2(r4)
168 sth r5,0(r3)
169 bdnz 00b
170 sync
171 blr
172
173#ifdef CONFIG_PPC32
174_GLOBAL(__ide_mm_insl)
175#endif
176_GLOBAL(_insl_ns)
177 sync
178 cmpwi 0,r5,0
179 mtctr r5
180 subi r4,r4,4
181 blelr-
18200: lwz r5,0(r3)
183 eieio
184 stwu r5,4(r4)
185 bdnz 00b
186 twi 0,r5,0
187 isync
188 blr
189
190#ifdef CONFIG_PPC32
191_GLOBAL(__ide_mm_outsl)
192#endif
193_GLOBAL(_outsl_ns)
194 cmpwi 0,r5,0
195 mtctr r5
196 subi r4,r4,4
197 blelr-
198 sync
19900: lwzu r5,4(r4)
200 stw r5,0(r3)
201 bdnz 00b
202 sync
203 blr
204
diff --git a/arch/powerpc/kernel/of_device.c b/arch/powerpc/kernel/of_device.c
index 3262b73a3a68..397c83eda20e 100644
--- a/arch/powerpc/kernel/of_device.c
+++ b/arch/powerpc/kernel/of_device.c
@@ -189,27 +189,9 @@ void of_release_dev(struct device *dev)
189int of_device_register(struct of_device *ofdev) 189int of_device_register(struct of_device *ofdev)
190{ 190{
191 int rc; 191 int rc;
192 struct of_device **odprop;
193 192
194 BUG_ON(ofdev->node == NULL); 193 BUG_ON(ofdev->node == NULL);
195 194
196 odprop = (struct of_device **)get_property(ofdev->node, "linux,device", NULL);
197 if (!odprop) {
198 struct property *new_prop;
199
200 new_prop = kmalloc(sizeof(struct property) + sizeof(struct of_device *),
201 GFP_KERNEL);
202 if (new_prop == NULL)
203 return -ENOMEM;
204 new_prop->name = "linux,device";
205 new_prop->length = sizeof(sizeof(struct of_device *));
206 new_prop->value = (unsigned char *)&new_prop[1];
207 odprop = (struct of_device **)new_prop->value;
208 *odprop = NULL;
209 prom_add_property(ofdev->node, new_prop);
210 }
211 *odprop = ofdev;
212
213 rc = device_register(&ofdev->dev); 195 rc = device_register(&ofdev->dev);
214 if (rc) 196 if (rc)
215 return rc; 197 return rc;
@@ -221,14 +203,8 @@ int of_device_register(struct of_device *ofdev)
221 203
222void of_device_unregister(struct of_device *ofdev) 204void of_device_unregister(struct of_device *ofdev)
223{ 205{
224 struct of_device **odprop;
225
226 device_remove_file(&ofdev->dev, &dev_attr_devspec); 206 device_remove_file(&ofdev->dev, &dev_attr_devspec);
227 207
228 odprop = (struct of_device **)get_property(ofdev->node, "linux,device", NULL);
229 if (odprop)
230 *odprop = NULL;
231
232 device_unregister(&ofdev->dev); 208 device_unregister(&ofdev->dev);
233} 209}
234 210
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c
index c68741fed14b..55f1a25085cd 100644
--- a/arch/powerpc/kernel/paca.c
+++ b/arch/powerpc/kernel/paca.c
@@ -17,6 +17,7 @@
17#include <asm/lppaca.h> 17#include <asm/lppaca.h>
18#include <asm/iseries/it_lp_reg_save.h> 18#include <asm/iseries/it_lp_reg_save.h>
19#include <asm/paca.h> 19#include <asm/paca.h>
20#include <asm/mmu.h>
20 21
21 22
22/* This symbol is provided by the linker - let it fill in the paca 23/* This symbol is provided by the linker - let it fill in the paca
@@ -45,6 +46,17 @@ struct lppaca lppaca[] = {
45 }, 46 },
46}; 47};
47 48
49/*
50 * 3 persistent SLBs are registered here. The buffer will be zero
51 * initially, hence will all be invaild until we actually write them.
52 */
53struct slb_shadow slb_shadow[] __cacheline_aligned = {
54 [0 ... (NR_CPUS-1)] = {
55 .persistent = SLB_NUM_BOLTED,
56 .buffer_length = sizeof(struct slb_shadow),
57 },
58};
59
48/* The Paca is an array with one entry per processor. Each contains an 60/* The Paca is an array with one entry per processor. Each contains an
49 * lppaca, which contains the information shared between the 61 * lppaca, which contains the information shared between the
50 * hypervisor and Linux. 62 * hypervisor and Linux.
@@ -59,7 +71,8 @@ struct lppaca lppaca[] = {
59 .lock_token = 0x8000, \ 71 .lock_token = 0x8000, \
60 .paca_index = (number), /* Paca Index */ \ 72 .paca_index = (number), /* Paca Index */ \
61 .kernel_toc = (unsigned long)(&__toc_start) + 0x8000UL, \ 73 .kernel_toc = (unsigned long)(&__toc_start) + 0x8000UL, \
62 .hw_cpu_id = 0xffff, 74 .hw_cpu_id = 0xffff, \
75 .slb_shadow_ptr = &slb_shadow[number],
63 76
64#ifdef CONFIG_PPC_ISERIES 77#ifdef CONFIG_PPC_ISERIES
65#define PACA_INIT_ISERIES(number) \ 78#define PACA_INIT_ISERIES(number) \
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index 09b1e1bbb29b..9b49f8691d29 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -633,12 +633,12 @@ pcibios_alloc_controller(void)
633static void 633static void
634make_one_node_map(struct device_node* node, u8 pci_bus) 634make_one_node_map(struct device_node* node, u8 pci_bus)
635{ 635{
636 int *bus_range; 636 const int *bus_range;
637 int len; 637 int len;
638 638
639 if (pci_bus >= pci_bus_count) 639 if (pci_bus >= pci_bus_count)
640 return; 640 return;
641 bus_range = (int *) get_property(node, "bus-range", &len); 641 bus_range = get_property(node, "bus-range", &len);
642 if (bus_range == NULL || len < 2 * sizeof(int)) { 642 if (bus_range == NULL || len < 2 * sizeof(int)) {
643 printk(KERN_WARNING "Can't get bus-range for %s, " 643 printk(KERN_WARNING "Can't get bus-range for %s, "
644 "assuming it starts at 0\n", node->full_name); 644 "assuming it starts at 0\n", node->full_name);
@@ -648,13 +648,13 @@ make_one_node_map(struct device_node* node, u8 pci_bus)
648 648
649 for (node=node->child; node != 0;node = node->sibling) { 649 for (node=node->child; node != 0;node = node->sibling) {
650 struct pci_dev* dev; 650 struct pci_dev* dev;
651 unsigned int *class_code, *reg; 651 const unsigned int *class_code, *reg;
652 652
653 class_code = (unsigned int *) get_property(node, "class-code", NULL); 653 class_code = get_property(node, "class-code", NULL);
654 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI && 654 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
655 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) 655 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS))
656 continue; 656 continue;
657 reg = (unsigned int *)get_property(node, "reg", NULL); 657 reg = get_property(node, "reg", NULL);
658 if (!reg) 658 if (!reg)
659 continue; 659 continue;
660 dev = pci_find_slot(pci_bus, ((reg[0] >> 8) & 0xff)); 660 dev = pci_find_slot(pci_bus, ((reg[0] >> 8) & 0xff));
@@ -669,7 +669,7 @@ pcibios_make_OF_bus_map(void)
669{ 669{
670 int i; 670 int i;
671 struct pci_controller* hose; 671 struct pci_controller* hose;
672 u8* of_prop_map; 672 struct property *map_prop;
673 673
674 pci_to_OF_bus_map = (u8*)kmalloc(pci_bus_count, GFP_KERNEL); 674 pci_to_OF_bus_map = (u8*)kmalloc(pci_bus_count, GFP_KERNEL);
675 if (!pci_to_OF_bus_map) { 675 if (!pci_to_OF_bus_map) {
@@ -691,9 +691,12 @@ pcibios_make_OF_bus_map(void)
691 continue; 691 continue;
692 make_one_node_map(node, hose->first_busno); 692 make_one_node_map(node, hose->first_busno);
693 } 693 }
694 of_prop_map = get_property(find_path_device("/"), "pci-OF-bus-map", NULL); 694 map_prop = of_find_property(find_path_device("/"),
695 if (of_prop_map) 695 "pci-OF-bus-map", NULL);
696 memcpy(of_prop_map, pci_to_OF_bus_map, pci_bus_count); 696 if (map_prop) {
697 BUG_ON(pci_bus_count > map_prop->length);
698 memcpy(map_prop->value, pci_to_OF_bus_map, pci_bus_count);
699 }
697#ifdef DEBUG 700#ifdef DEBUG
698 printk("PCI->OF bus map:\n"); 701 printk("PCI->OF bus map:\n");
699 for (i=0; i<pci_bus_count; i++) { 702 for (i=0; i<pci_bus_count; i++) {
@@ -712,7 +715,7 @@ scan_OF_pci_childs(struct device_node* node, pci_OF_scan_iterator filter, void*
712 struct device_node* sub_node; 715 struct device_node* sub_node;
713 716
714 for (; node != 0;node = node->sibling) { 717 for (; node != 0;node = node->sibling) {
715 unsigned int *class_code; 718 const unsigned int *class_code;
716 719
717 if (filter(node, data)) 720 if (filter(node, data))
718 return node; 721 return node;
@@ -722,7 +725,7 @@ scan_OF_pci_childs(struct device_node* node, pci_OF_scan_iterator filter, void*
722 * a fake root for all functions of a multi-function device, 725 * a fake root for all functions of a multi-function device,
723 * we go down them as well. 726 * we go down them as well.
724 */ 727 */
725 class_code = (unsigned int *) get_property(node, "class-code", NULL); 728 class_code = get_property(node, "class-code", NULL);
726 if ((!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI && 729 if ((!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
727 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) && 730 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) &&
728 strcmp(node->name, "multifunc-device")) 731 strcmp(node->name, "multifunc-device"))
@@ -737,10 +740,10 @@ scan_OF_pci_childs(struct device_node* node, pci_OF_scan_iterator filter, void*
737static int 740static int
738scan_OF_pci_childs_iterator(struct device_node* node, void* data) 741scan_OF_pci_childs_iterator(struct device_node* node, void* data)
739{ 742{
740 unsigned int *reg; 743 const unsigned int *reg;
741 u8* fdata = (u8*)data; 744 u8* fdata = (u8*)data;
742 745
743 reg = (unsigned int *) get_property(node, "reg", NULL); 746 reg = get_property(node, "reg", NULL);
744 if (reg && ((reg[0] >> 8) & 0xff) == fdata[1] 747 if (reg && ((reg[0] >> 8) & 0xff) == fdata[1]
745 && ((reg[0] >> 16) & 0xff) == fdata[0]) 748 && ((reg[0] >> 16) & 0xff) == fdata[0])
746 return 1; 749 return 1;
@@ -841,7 +844,7 @@ find_OF_pci_device_filter(struct device_node* node, void* data)
841int 844int
842pci_device_from_OF_node(struct device_node* node, u8* bus, u8* devfn) 845pci_device_from_OF_node(struct device_node* node, u8* bus, u8* devfn)
843{ 846{
844 unsigned int *reg; 847 const unsigned int *reg;
845 struct pci_controller* hose; 848 struct pci_controller* hose;
846 struct pci_dev* dev = NULL; 849 struct pci_dev* dev = NULL;
847 850
@@ -854,7 +857,7 @@ pci_device_from_OF_node(struct device_node* node, u8* bus, u8* devfn)
854 if (!scan_OF_pci_childs(((struct device_node*)hose->arch_data)->child, 857 if (!scan_OF_pci_childs(((struct device_node*)hose->arch_data)->child,
855 find_OF_pci_device_filter, (void *)node)) 858 find_OF_pci_device_filter, (void *)node))
856 return -ENODEV; 859 return -ENODEV;
857 reg = (unsigned int *) get_property(node, "reg", NULL); 860 reg = get_property(node, "reg", NULL);
858 if (!reg) 861 if (!reg)
859 return -ENODEV; 862 return -ENODEV;
860 *bus = (reg[0] >> 16) & 0xff; 863 *bus = (reg[0] >> 16) & 0xff;
@@ -885,8 +888,8 @@ pci_process_bridge_OF_ranges(struct pci_controller *hose,
885 struct device_node *dev, int primary) 888 struct device_node *dev, int primary)
886{ 889{
887 static unsigned int static_lc_ranges[256] __initdata; 890 static unsigned int static_lc_ranges[256] __initdata;
888 unsigned int *dt_ranges, *lc_ranges, *ranges, *prev; 891 const unsigned int *dt_ranges;
889 unsigned int size; 892 unsigned int *lc_ranges, *ranges, *prev, size;
890 int rlen = 0, orig_rlen; 893 int rlen = 0, orig_rlen;
891 int memno = 0; 894 int memno = 0;
892 struct resource *res; 895 struct resource *res;
@@ -897,7 +900,7 @@ pci_process_bridge_OF_ranges(struct pci_controller *hose,
897 * that can have more than 3 ranges, fortunately using contiguous 900 * that can have more than 3 ranges, fortunately using contiguous
898 * addresses -- BenH 901 * addresses -- BenH
899 */ 902 */
900 dt_ranges = (unsigned int *) get_property(dev, "ranges", &rlen); 903 dt_ranges = get_property(dev, "ranges", &rlen);
901 if (!dt_ranges) 904 if (!dt_ranges)
902 return; 905 return;
903 /* Sanity check, though hopefully that never happens */ 906 /* Sanity check, though hopefully that never happens */
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 138134c8c17d..c1b1e14775e4 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -185,34 +185,6 @@ static void __devinit pci_setup_pci_controller(struct pci_controller *hose)
185 spin_unlock(&hose_spinlock); 185 spin_unlock(&hose_spinlock);
186} 186}
187 187
188static void add_linux_pci_domain(struct device_node *dev,
189 struct pci_controller *phb)
190{
191 struct property *of_prop;
192 unsigned int size;
193
194 of_prop = (struct property *)
195 get_property(dev, "linux,pci-domain", &size);
196 if (of_prop != NULL)
197 return;
198 WARN_ON(of_prop && size < sizeof(int));
199 if (of_prop && size < sizeof(int))
200 of_prop = NULL;
201 size = sizeof(struct property) + sizeof(int);
202 if (of_prop == NULL) {
203 if (mem_init_done)
204 of_prop = kmalloc(size, GFP_KERNEL);
205 else
206 of_prop = alloc_bootmem(size);
207 }
208 memset(of_prop, 0, sizeof(struct property));
209 of_prop->name = "linux,pci-domain";
210 of_prop->length = sizeof(int);
211 of_prop->value = (unsigned char *)&of_prop[1];
212 *((int *)of_prop->value) = phb->global_number;
213 prom_add_property(dev, of_prop);
214}
215
216struct pci_controller * pcibios_alloc_controller(struct device_node *dev) 188struct pci_controller * pcibios_alloc_controller(struct device_node *dev)
217{ 189{
218 struct pci_controller *phb; 190 struct pci_controller *phb;
@@ -226,22 +198,13 @@ struct pci_controller * pcibios_alloc_controller(struct device_node *dev)
226 pci_setup_pci_controller(phb); 198 pci_setup_pci_controller(phb);
227 phb->arch_data = dev; 199 phb->arch_data = dev;
228 phb->is_dynamic = mem_init_done; 200 phb->is_dynamic = mem_init_done;
229 if (dev) { 201 if (dev)
230 PHB_SET_NODE(phb, of_node_to_nid(dev)); 202 PHB_SET_NODE(phb, of_node_to_nid(dev));
231 add_linux_pci_domain(dev, phb);
232 }
233 return phb; 203 return phb;
234} 204}
235 205
236void pcibios_free_controller(struct pci_controller *phb) 206void pcibios_free_controller(struct pci_controller *phb)
237{ 207{
238 if (phb->arch_data) {
239 struct device_node *np = phb->arch_data;
240 int *domain = (int *)get_property(np,
241 "linux,pci-domain", NULL);
242 if (domain)
243 *domain = -1;
244 }
245 if (phb->is_dynamic) 208 if (phb->is_dynamic)
246 kfree(phb); 209 kfree(phb);
247} 210}
@@ -283,10 +246,10 @@ static void __init pcibios_claim_of_setup(void)
283#ifdef CONFIG_PPC_MULTIPLATFORM 246#ifdef CONFIG_PPC_MULTIPLATFORM
284static u32 get_int_prop(struct device_node *np, const char *name, u32 def) 247static u32 get_int_prop(struct device_node *np, const char *name, u32 def)
285{ 248{
286 u32 *prop; 249 const u32 *prop;
287 int len; 250 int len;
288 251
289 prop = (u32 *) get_property(np, name, &len); 252 prop = get_property(np, name, &len);
290 if (prop && len >= 4) 253 if (prop && len >= 4)
291 return *prop; 254 return *prop;
292 return def; 255 return def;
@@ -315,10 +278,11 @@ static void pci_parse_of_addrs(struct device_node *node, struct pci_dev *dev)
315 u64 base, size; 278 u64 base, size;
316 unsigned int flags; 279 unsigned int flags;
317 struct resource *res; 280 struct resource *res;
318 u32 *addrs, i; 281 const u32 *addrs;
282 u32 i;
319 int proplen; 283 int proplen;
320 284
321 addrs = (u32 *) get_property(node, "assigned-addresses", &proplen); 285 addrs = get_property(node, "assigned-addresses", &proplen);
322 if (!addrs) 286 if (!addrs)
323 return; 287 return;
324 DBG(" parse addresses (%d bytes) @ %p\n", proplen, addrs); 288 DBG(" parse addresses (%d bytes) @ %p\n", proplen, addrs);
@@ -418,7 +382,7 @@ void __devinit of_scan_bus(struct device_node *node,
418 struct pci_bus *bus) 382 struct pci_bus *bus)
419{ 383{
420 struct device_node *child = NULL; 384 struct device_node *child = NULL;
421 u32 *reg; 385 const u32 *reg;
422 int reglen, devfn; 386 int reglen, devfn;
423 struct pci_dev *dev; 387 struct pci_dev *dev;
424 388
@@ -426,7 +390,7 @@ void __devinit of_scan_bus(struct device_node *node,
426 390
427 while ((child = of_get_next_child(node, child)) != NULL) { 391 while ((child = of_get_next_child(node, child)) != NULL) {
428 DBG(" * %s\n", child->full_name); 392 DBG(" * %s\n", child->full_name);
429 reg = (u32 *) get_property(child, "reg", &reglen); 393 reg = get_property(child, "reg", &reglen);
430 if (reg == NULL || reglen < 20) 394 if (reg == NULL || reglen < 20)
431 continue; 395 continue;
432 devfn = (reg[0] >> 8) & 0xff; 396 devfn = (reg[0] >> 8) & 0xff;
@@ -450,7 +414,7 @@ void __devinit of_scan_pci_bridge(struct device_node *node,
450 struct pci_dev *dev) 414 struct pci_dev *dev)
451{ 415{
452 struct pci_bus *bus; 416 struct pci_bus *bus;
453 u32 *busrange, *ranges; 417 const u32 *busrange, *ranges;
454 int len, i, mode; 418 int len, i, mode;
455 struct resource *res; 419 struct resource *res;
456 unsigned int flags; 420 unsigned int flags;
@@ -459,13 +423,13 @@ void __devinit of_scan_pci_bridge(struct device_node *node,
459 DBG("of_scan_pci_bridge(%s)\n", node->full_name); 423 DBG("of_scan_pci_bridge(%s)\n", node->full_name);
460 424
461 /* parse bus-range property */ 425 /* parse bus-range property */
462 busrange = (u32 *) get_property(node, "bus-range", &len); 426 busrange = get_property(node, "bus-range", &len);
463 if (busrange == NULL || len != 8) { 427 if (busrange == NULL || len != 8) {
464 printk(KERN_DEBUG "Can't get bus-range for PCI-PCI bridge %s\n", 428 printk(KERN_DEBUG "Can't get bus-range for PCI-PCI bridge %s\n",
465 node->full_name); 429 node->full_name);
466 return; 430 return;
467 } 431 }
468 ranges = (u32 *) get_property(node, "ranges", &len); 432 ranges = get_property(node, "ranges", &len);
469 if (ranges == NULL) { 433 if (ranges == NULL) {
470 printk(KERN_DEBUG "Can't get ranges for PCI-PCI bridge %s\n", 434 printk(KERN_DEBUG "Can't get ranges for PCI-PCI bridge %s\n",
471 node->full_name); 435 node->full_name);
@@ -929,13 +893,13 @@ static void __devinit pci_process_ISA_OF_ranges(struct device_node *isa_node,
929 unsigned int size; 893 unsigned int size;
930 }; 894 };
931 895
932 struct isa_range *range; 896 const struct isa_range *range;
933 unsigned long pci_addr; 897 unsigned long pci_addr;
934 unsigned int isa_addr; 898 unsigned int isa_addr;
935 unsigned int size; 899 unsigned int size;
936 int rlen = 0; 900 int rlen = 0;
937 901
938 range = (struct isa_range *) get_property(isa_node, "ranges", &rlen); 902 range = get_property(isa_node, "ranges", &rlen);
939 if (range == NULL || (rlen < sizeof(struct isa_range))) { 903 if (range == NULL || (rlen < sizeof(struct isa_range))) {
940 printk(KERN_ERR "no ISA ranges or unexpected isa range size," 904 printk(KERN_ERR "no ISA ranges or unexpected isa range size,"
941 "mapping 64k\n"); 905 "mapping 64k\n");
@@ -976,7 +940,8 @@ static void __devinit pci_process_ISA_OF_ranges(struct device_node *isa_node,
976void __devinit pci_process_bridge_OF_ranges(struct pci_controller *hose, 940void __devinit pci_process_bridge_OF_ranges(struct pci_controller *hose,
977 struct device_node *dev, int prim) 941 struct device_node *dev, int prim)
978{ 942{
979 unsigned int *ranges, pci_space; 943 const unsigned int *ranges;
944 unsigned int pci_space;
980 unsigned long size; 945 unsigned long size;
981 int rlen = 0; 946 int rlen = 0;
982 int memno = 0; 947 int memno = 0;
@@ -994,7 +959,7 @@ void __devinit pci_process_bridge_OF_ranges(struct pci_controller *hose,
994 * (size depending on dev->n_addr_cells) 959 * (size depending on dev->n_addr_cells)
995 * cells 4+5 or 5+6: the size of the range 960 * cells 4+5 or 5+6: the size of the range
996 */ 961 */
997 ranges = (unsigned int *) get_property(dev, "ranges", &rlen); 962 ranges = get_property(dev, "ranges", &rlen);
998 if (ranges == NULL) 963 if (ranges == NULL)
999 return; 964 return;
1000 hose->io_base_phys = 0; 965 hose->io_base_phys = 0;
diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c
index 1c18953514c3..68df018dae0e 100644
--- a/arch/powerpc/kernel/pci_dn.c
+++ b/arch/powerpc/kernel/pci_dn.c
@@ -40,8 +40,8 @@
40static void * __devinit update_dn_pci_info(struct device_node *dn, void *data) 40static void * __devinit update_dn_pci_info(struct device_node *dn, void *data)
41{ 41{
42 struct pci_controller *phb = data; 42 struct pci_controller *phb = data;
43 int *type = (int *)get_property(dn, "ibm,pci-config-space-type", NULL); 43 const int *type = get_property(dn, "ibm,pci-config-space-type", NULL);
44 u32 *regs; 44 const u32 *regs;
45 struct pci_dn *pdn; 45 struct pci_dn *pdn;
46 46
47 if (mem_init_done) 47 if (mem_init_done)
@@ -54,14 +54,14 @@ static void * __devinit update_dn_pci_info(struct device_node *dn, void *data)
54 dn->data = pdn; 54 dn->data = pdn;
55 pdn->node = dn; 55 pdn->node = dn;
56 pdn->phb = phb; 56 pdn->phb = phb;
57 regs = (u32 *)get_property(dn, "reg", NULL); 57 regs = get_property(dn, "reg", NULL);
58 if (regs) { 58 if (regs) {
59 /* First register entry is addr (00BBSS00) */ 59 /* First register entry is addr (00BBSS00) */
60 pdn->busno = (regs[0] >> 16) & 0xff; 60 pdn->busno = (regs[0] >> 16) & 0xff;
61 pdn->devfn = (regs[0] >> 8) & 0xff; 61 pdn->devfn = (regs[0] >> 8) & 0xff;
62 } 62 }
63 if (firmware_has_feature(FW_FEATURE_ISERIES)) { 63 if (firmware_has_feature(FW_FEATURE_ISERIES)) {
64 u32 *busp = (u32 *)get_property(dn, "linux,subbus", NULL); 64 const u32 *busp = get_property(dn, "linux,subbus", NULL);
65 if (busp) 65 if (busp)
66 pdn->bussubno = *busp; 66 pdn->bussubno = *busp;
67 } 67 }
@@ -96,10 +96,11 @@ void *traverse_pci_devices(struct device_node *start, traverse_func pre,
96 96
97 /* We started with a phb, iterate all childs */ 97 /* We started with a phb, iterate all childs */
98 for (dn = start->child; dn; dn = nextdn) { 98 for (dn = start->child; dn; dn = nextdn) {
99 u32 *classp, class; 99 const u32 *classp;
100 u32 class;
100 101
101 nextdn = NULL; 102 nextdn = NULL;
102 classp = (u32 *)get_property(dn, "class-code", NULL); 103 classp = get_property(dn, "class-code", NULL);
103 class = classp ? *classp : 0; 104 class = classp ? *classp : 0;
104 105
105 if (pre && ((ret = pre(dn, data)) != NULL)) 106 if (pre && ((ret = pre(dn, data)) != NULL))
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 39d3bfcabcd2..807193a3c784 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -91,25 +91,10 @@ EXPORT_SYMBOL(__copy_tofrom_user);
91EXPORT_SYMBOL(__clear_user); 91EXPORT_SYMBOL(__clear_user);
92EXPORT_SYMBOL(__strncpy_from_user); 92EXPORT_SYMBOL(__strncpy_from_user);
93EXPORT_SYMBOL(__strnlen_user); 93EXPORT_SYMBOL(__strnlen_user);
94 94#ifdef CONFIG_PPC64
95#ifndef __powerpc64__ 95EXPORT_SYMBOL(copy_4K_page);
96EXPORT_SYMBOL(__ide_mm_insl);
97EXPORT_SYMBOL(__ide_mm_outsw);
98EXPORT_SYMBOL(__ide_mm_insw);
99EXPORT_SYMBOL(__ide_mm_outsl);
100#endif 96#endif
101 97
102EXPORT_SYMBOL(_insb);
103EXPORT_SYMBOL(_outsb);
104EXPORT_SYMBOL(_insw);
105EXPORT_SYMBOL(_outsw);
106EXPORT_SYMBOL(_insl);
107EXPORT_SYMBOL(_outsl);
108EXPORT_SYMBOL(_insw_ns);
109EXPORT_SYMBOL(_outsw_ns);
110EXPORT_SYMBOL(_insl_ns);
111EXPORT_SYMBOL(_outsl_ns);
112
113#if defined(CONFIG_PPC32) && (defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE)) 98#if defined(CONFIG_PPC32) && (defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE))
114EXPORT_SYMBOL(ppc_ide_md); 99EXPORT_SYMBOL(ppc_ide_md);
115#endif 100#endif
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index a1787ffb6319..eb913f80bfb1 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -757,24 +757,9 @@ static int __init early_init_dt_scan_root(unsigned long node,
757static unsigned long __init dt_mem_next_cell(int s, cell_t **cellp) 757static unsigned long __init dt_mem_next_cell(int s, cell_t **cellp)
758{ 758{
759 cell_t *p = *cellp; 759 cell_t *p = *cellp;
760 unsigned long r;
761 760
762 /* Ignore more than 2 cells */ 761 *cellp = p + s;
763 while (s > sizeof(unsigned long) / 4) { 762 return of_read_ulong(p, s);
764 p++;
765 s--;
766 }
767 r = *p++;
768#ifdef CONFIG_PPC64
769 if (s > 1) {
770 r <<= 32;
771 r |= *(p++);
772 s--;
773 }
774#endif
775
776 *cellp = p;
777 return r;
778} 763}
779 764
780 765
@@ -942,11 +927,11 @@ void __init early_init_devtree(void *params)
942int 927int
943prom_n_addr_cells(struct device_node* np) 928prom_n_addr_cells(struct device_node* np)
944{ 929{
945 int* ip; 930 const int *ip;
946 do { 931 do {
947 if (np->parent) 932 if (np->parent)
948 np = np->parent; 933 np = np->parent;
949 ip = (int *) get_property(np, "#address-cells", NULL); 934 ip = get_property(np, "#address-cells", NULL);
950 if (ip != NULL) 935 if (ip != NULL)
951 return *ip; 936 return *ip;
952 } while (np->parent); 937 } while (np->parent);
@@ -958,11 +943,11 @@ EXPORT_SYMBOL(prom_n_addr_cells);
958int 943int
959prom_n_size_cells(struct device_node* np) 944prom_n_size_cells(struct device_node* np)
960{ 945{
961 int* ip; 946 const int* ip;
962 do { 947 do {
963 if (np->parent) 948 if (np->parent)
964 np = np->parent; 949 np = np->parent;
965 ip = (int *) get_property(np, "#size-cells", NULL); 950 ip = get_property(np, "#size-cells", NULL);
966 if (ip != NULL) 951 if (ip != NULL)
967 return *ip; 952 return *ip;
968 } while (np->parent); 953 } while (np->parent);
@@ -1034,7 +1019,7 @@ int device_is_compatible(struct device_node *device, const char *compat)
1034 const char* cp; 1019 const char* cp;
1035 int cplen, l; 1020 int cplen, l;
1036 1021
1037 cp = (char *) get_property(device, "compatible", &cplen); 1022 cp = get_property(device, "compatible", &cplen);
1038 if (cp == NULL) 1023 if (cp == NULL)
1039 return 0; 1024 return 0;
1040 while (cplen > 0) { 1025 while (cplen > 0) {
@@ -1449,7 +1434,7 @@ static int of_finish_dynamic_node(struct device_node *node)
1449{ 1434{
1450 struct device_node *parent = of_get_parent(node); 1435 struct device_node *parent = of_get_parent(node);
1451 int err = 0; 1436 int err = 0;
1452 phandle *ibm_phandle; 1437 const phandle *ibm_phandle;
1453 1438
1454 node->name = get_property(node, "name", NULL); 1439 node->name = get_property(node, "name", NULL);
1455 node->type = get_property(node, "device_type", NULL); 1440 node->type = get_property(node, "device_type", NULL);
@@ -1466,8 +1451,7 @@ static int of_finish_dynamic_node(struct device_node *node)
1466 return -ENODEV; 1451 return -ENODEV;
1467 1452
1468 /* fix up new node's linux_phandle field */ 1453 /* fix up new node's linux_phandle field */
1469 if ((ibm_phandle = (unsigned int *)get_property(node, 1454 if ((ibm_phandle = get_property(node, "ibm,phandle", NULL)))
1470 "ibm,phandle", NULL)))
1471 node->linux_phandle = *ibm_phandle; 1455 node->linux_phandle = *ibm_phandle;
1472 1456
1473out: 1457out:
@@ -1528,7 +1512,7 @@ struct property *of_find_property(struct device_node *np, const char *name,
1528 * Find a property with a given name for a given node 1512 * Find a property with a given name for a given node
1529 * and return the value. 1513 * and return the value.
1530 */ 1514 */
1531void *get_property(struct device_node *np, const char *name, int *lenp) 1515const void *get_property(struct device_node *np, const char *name, int *lenp)
1532{ 1516{
1533 struct property *pp = of_find_property(np,name,lenp); 1517 struct property *pp = of_find_property(np,name,lenp);
1534 return pp ? pp->value : NULL; 1518 return pp ? pp->value : NULL;
@@ -1658,16 +1642,16 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
1658 hardid = get_hard_smp_processor_id(cpu); 1642 hardid = get_hard_smp_processor_id(cpu);
1659 1643
1660 for_each_node_by_type(np, "cpu") { 1644 for_each_node_by_type(np, "cpu") {
1661 u32 *intserv; 1645 const u32 *intserv;
1662 unsigned int plen, t; 1646 unsigned int plen, t;
1663 1647
1664 /* Check for ibm,ppc-interrupt-server#s. If it doesn't exist 1648 /* Check for ibm,ppc-interrupt-server#s. If it doesn't exist
1665 * fallback to "reg" property and assume no threads 1649 * fallback to "reg" property and assume no threads
1666 */ 1650 */
1667 intserv = (u32 *)get_property(np, "ibm,ppc-interrupt-server#s", 1651 intserv = get_property(np, "ibm,ppc-interrupt-server#s",
1668 &plen); 1652 &plen);
1669 if (intserv == NULL) { 1653 if (intserv == NULL) {
1670 u32 *reg = (u32 *)get_property(np, "reg", NULL); 1654 const u32 *reg = get_property(np, "reg", NULL);
1671 if (reg == NULL) 1655 if (reg == NULL)
1672 continue; 1656 continue;
1673 if (*reg == hardid) { 1657 if (*reg == hardid) {
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 4394e545f9f7..b91761639d96 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -2033,16 +2033,22 @@ static void __init fixup_device_tree_maple(void)
2033#endif 2033#endif
2034 2034
2035#ifdef CONFIG_PPC_CHRP 2035#ifdef CONFIG_PPC_CHRP
2036/* Pegasos lacks the "ranges" property in the isa node */ 2036/* Pegasos and BriQ lacks the "ranges" property in the isa node */
2037static void __init fixup_device_tree_chrp(void) 2037static void __init fixup_device_tree_chrp(void)
2038{ 2038{
2039 phandle isa; 2039 phandle isa;
2040 u32 isa_ranges[6]; 2040 u32 isa_ranges[6];
2041 u32 rloc = 0x01006000; /* IO space; PCI device = 12 */
2041 char *name; 2042 char *name;
2042 int rc; 2043 int rc;
2043 2044
2044 name = "/pci@80000000/isa@c"; 2045 name = "/pci@80000000/isa@c";
2045 isa = call_prom("finddevice", 1, 1, ADDR(name)); 2046 isa = call_prom("finddevice", 1, 1, ADDR(name));
2047 if (!PHANDLE_VALID(isa)) {
2048 name = "/pci@ff500000/isa@6";
2049 isa = call_prom("finddevice", 1, 1, ADDR(name));
2050 rloc = 0x01003000; /* IO space; PCI device = 6 */
2051 }
2046 if (!PHANDLE_VALID(isa)) 2052 if (!PHANDLE_VALID(isa))
2047 return; 2053 return;
2048 2054
@@ -2054,7 +2060,7 @@ static void __init fixup_device_tree_chrp(void)
2054 2060
2055 isa_ranges[0] = 0x1; 2061 isa_ranges[0] = 0x1;
2056 isa_ranges[1] = 0x0; 2062 isa_ranges[1] = 0x0;
2057 isa_ranges[2] = 0x01006000; 2063 isa_ranges[2] = rloc;
2058 isa_ranges[3] = 0x0; 2064 isa_ranges[3] = 0x0;
2059 isa_ranges[4] = 0x0; 2065 isa_ranges[4] = 0x0;
2060 isa_ranges[5] = 0x00010000; 2066 isa_ranges[5] = 0x00010000;
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c
index a10825a5dfe6..603dff3ad62a 100644
--- a/arch/powerpc/kernel/prom_parse.c
+++ b/arch/powerpc/kernel/prom_parse.c
@@ -27,7 +27,7 @@
27 27
28/* Debug utility */ 28/* Debug utility */
29#ifdef DEBUG 29#ifdef DEBUG
30static void of_dump_addr(const char *s, u32 *addr, int na) 30static void of_dump_addr(const char *s, const u32 *addr, int na)
31{ 31{
32 printk("%s", s); 32 printk("%s", s);
33 while(na--) 33 while(na--)
@@ -35,7 +35,7 @@ static void of_dump_addr(const char *s, u32 *addr, int na)
35 printk("\n"); 35 printk("\n");
36} 36}
37#else 37#else
38static void of_dump_addr(const char *s, u32 *addr, int na) { } 38static void of_dump_addr(const char *s, const u32 *addr, int na) { }
39#endif 39#endif
40 40
41 41
@@ -46,9 +46,10 @@ struct of_bus {
46 int (*match)(struct device_node *parent); 46 int (*match)(struct device_node *parent);
47 void (*count_cells)(struct device_node *child, 47 void (*count_cells)(struct device_node *child,
48 int *addrc, int *sizec); 48 int *addrc, int *sizec);
49 u64 (*map)(u32 *addr, u32 *range, int na, int ns, int pna); 49 u64 (*map)(u32 *addr, const u32 *range,
50 int na, int ns, int pna);
50 int (*translate)(u32 *addr, u64 offset, int na); 51 int (*translate)(u32 *addr, u64 offset, int na);
51 unsigned int (*get_flags)(u32 *addr); 52 unsigned int (*get_flags)(const u32 *addr);
52}; 53};
53 54
54 55
@@ -65,7 +66,8 @@ static void of_bus_default_count_cells(struct device_node *dev,
65 *sizec = prom_n_size_cells(dev); 66 *sizec = prom_n_size_cells(dev);
66} 67}
67 68
68static u64 of_bus_default_map(u32 *addr, u32 *range, int na, int ns, int pna) 69static u64 of_bus_default_map(u32 *addr, const u32 *range,
70 int na, int ns, int pna)
69{ 71{
70 u64 cp, s, da; 72 u64 cp, s, da;
71 73
@@ -93,7 +95,7 @@ static int of_bus_default_translate(u32 *addr, u64 offset, int na)
93 return 0; 95 return 0;
94} 96}
95 97
96static unsigned int of_bus_default_get_flags(u32 *addr) 98static unsigned int of_bus_default_get_flags(const u32 *addr)
97{ 99{
98 return IORESOURCE_MEM; 100 return IORESOURCE_MEM;
99} 101}
@@ -118,7 +120,7 @@ static void of_bus_pci_count_cells(struct device_node *np,
118 *sizec = 2; 120 *sizec = 2;
119} 121}
120 122
121static u64 of_bus_pci_map(u32 *addr, u32 *range, int na, int ns, int pna) 123static u64 of_bus_pci_map(u32 *addr, const u32 *range, int na, int ns, int pna)
122{ 124{
123 u64 cp, s, da; 125 u64 cp, s, da;
124 126
@@ -143,7 +145,7 @@ static int of_bus_pci_translate(u32 *addr, u64 offset, int na)
143 return of_bus_default_translate(addr + 1, offset, na - 1); 145 return of_bus_default_translate(addr + 1, offset, na - 1);
144} 146}
145 147
146static unsigned int of_bus_pci_get_flags(u32 *addr) 148static unsigned int of_bus_pci_get_flags(const u32 *addr)
147{ 149{
148 unsigned int flags = 0; 150 unsigned int flags = 0;
149 u32 w = addr[0]; 151 u32 w = addr[0];
@@ -178,7 +180,7 @@ static void of_bus_isa_count_cells(struct device_node *child,
178 *sizec = 1; 180 *sizec = 1;
179} 181}
180 182
181static u64 of_bus_isa_map(u32 *addr, u32 *range, int na, int ns, int pna) 183static u64 of_bus_isa_map(u32 *addr, const u32 *range, int na, int ns, int pna)
182{ 184{
183 u64 cp, s, da; 185 u64 cp, s, da;
184 186
@@ -203,7 +205,7 @@ static int of_bus_isa_translate(u32 *addr, u64 offset, int na)
203 return of_bus_default_translate(addr + 1, offset, na - 1); 205 return of_bus_default_translate(addr + 1, offset, na - 1);
204} 206}
205 207
206static unsigned int of_bus_isa_get_flags(u32 *addr) 208static unsigned int of_bus_isa_get_flags(const u32 *addr)
207{ 209{
208 unsigned int flags = 0; 210 unsigned int flags = 0;
209 u32 w = addr[0]; 211 u32 w = addr[0];
@@ -268,7 +270,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
268 struct of_bus *pbus, u32 *addr, 270 struct of_bus *pbus, u32 *addr,
269 int na, int ns, int pna) 271 int na, int ns, int pna)
270{ 272{
271 u32 *ranges; 273 const u32 *ranges;
272 unsigned int rlen; 274 unsigned int rlen;
273 int rone; 275 int rone;
274 u64 offset = OF_BAD_ADDR; 276 u64 offset = OF_BAD_ADDR;
@@ -285,7 +287,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
285 * to translate addresses that aren't supposed to be translated in 287 * to translate addresses that aren't supposed to be translated in
286 * the first place. --BenH. 288 * the first place. --BenH.
287 */ 289 */
288 ranges = (u32 *)get_property(parent, "ranges", &rlen); 290 ranges = get_property(parent, "ranges", &rlen);
289 if (ranges == NULL || rlen == 0) { 291 if (ranges == NULL || rlen == 0) {
290 offset = of_read_number(addr, na); 292 offset = of_read_number(addr, na);
291 memset(addr, 0, pna * 4); 293 memset(addr, 0, pna * 4);
@@ -328,7 +330,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
328 * that can be mapped to a cpu physical address). This is not really specified 330 * that can be mapped to a cpu physical address). This is not really specified
329 * that way, but this is traditionally the way IBM at least do things 331 * that way, but this is traditionally the way IBM at least do things
330 */ 332 */
331u64 of_translate_address(struct device_node *dev, u32 *in_addr) 333u64 of_translate_address(struct device_node *dev, const u32 *in_addr)
332{ 334{
333 struct device_node *parent = NULL; 335 struct device_node *parent = NULL;
334 struct of_bus *bus, *pbus; 336 struct of_bus *bus, *pbus;
@@ -405,10 +407,10 @@ u64 of_translate_address(struct device_node *dev, u32 *in_addr)
405} 407}
406EXPORT_SYMBOL(of_translate_address); 408EXPORT_SYMBOL(of_translate_address);
407 409
408u32 *of_get_address(struct device_node *dev, int index, u64 *size, 410const u32 *of_get_address(struct device_node *dev, int index, u64 *size,
409 unsigned int *flags) 411 unsigned int *flags)
410{ 412{
411 u32 *prop; 413 const u32 *prop;
412 unsigned int psize; 414 unsigned int psize;
413 struct device_node *parent; 415 struct device_node *parent;
414 struct of_bus *bus; 416 struct of_bus *bus;
@@ -425,7 +427,7 @@ u32 *of_get_address(struct device_node *dev, int index, u64 *size,
425 return NULL; 427 return NULL;
426 428
427 /* Get "reg" or "assigned-addresses" property */ 429 /* Get "reg" or "assigned-addresses" property */
428 prop = (u32 *)get_property(dev, bus->addresses, &psize); 430 prop = get_property(dev, bus->addresses, &psize);
429 if (prop == NULL) 431 if (prop == NULL)
430 return NULL; 432 return NULL;
431 psize /= 4; 433 psize /= 4;
@@ -443,10 +445,10 @@ u32 *of_get_address(struct device_node *dev, int index, u64 *size,
443} 445}
444EXPORT_SYMBOL(of_get_address); 446EXPORT_SYMBOL(of_get_address);
445 447
446u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size, 448const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
447 unsigned int *flags) 449 unsigned int *flags)
448{ 450{
449 u32 *prop; 451 const u32 *prop;
450 unsigned int psize; 452 unsigned int psize;
451 struct device_node *parent; 453 struct device_node *parent;
452 struct of_bus *bus; 454 struct of_bus *bus;
@@ -467,7 +469,7 @@ u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
467 return NULL; 469 return NULL;
468 470
469 /* Get "reg" or "assigned-addresses" property */ 471 /* Get "reg" or "assigned-addresses" property */
470 prop = (u32 *)get_property(dev, bus->addresses, &psize); 472 prop = get_property(dev, bus->addresses, &psize);
471 if (prop == NULL) 473 if (prop == NULL)
472 return NULL; 474 return NULL;
473 psize /= 4; 475 psize /= 4;
@@ -485,7 +487,7 @@ u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
485} 487}
486EXPORT_SYMBOL(of_get_pci_address); 488EXPORT_SYMBOL(of_get_pci_address);
487 489
488static int __of_address_to_resource(struct device_node *dev, u32 *addrp, 490static int __of_address_to_resource(struct device_node *dev, const u32 *addrp,
489 u64 size, unsigned int flags, 491 u64 size, unsigned int flags,
490 struct resource *r) 492 struct resource *r)
491{ 493{
@@ -516,7 +518,7 @@ static int __of_address_to_resource(struct device_node *dev, u32 *addrp,
516int of_address_to_resource(struct device_node *dev, int index, 518int of_address_to_resource(struct device_node *dev, int index,
517 struct resource *r) 519 struct resource *r)
518{ 520{
519 u32 *addrp; 521 const u32 *addrp;
520 u64 size; 522 u64 size;
521 unsigned int flags; 523 unsigned int flags;
522 524
@@ -530,7 +532,7 @@ EXPORT_SYMBOL_GPL(of_address_to_resource);
530int of_pci_address_to_resource(struct device_node *dev, int bar, 532int of_pci_address_to_resource(struct device_node *dev, int bar,
531 struct resource *r) 533 struct resource *r)
532{ 534{
533 u32 *addrp; 535 const u32 *addrp;
534 u64 size; 536 u64 size;
535 unsigned int flags; 537 unsigned int flags;
536 538
@@ -541,13 +543,14 @@ int of_pci_address_to_resource(struct device_node *dev, int bar,
541} 543}
542EXPORT_SYMBOL_GPL(of_pci_address_to_resource); 544EXPORT_SYMBOL_GPL(of_pci_address_to_resource);
543 545
544void of_parse_dma_window(struct device_node *dn, unsigned char *dma_window_prop, 546void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
545 unsigned long *busno, unsigned long *phys, unsigned long *size) 547 unsigned long *busno, unsigned long *phys, unsigned long *size)
546{ 548{
547 u32 *dma_window, cells; 549 const u32 *dma_window;
548 unsigned char *prop; 550 u32 cells;
551 const unsigned char *prop;
549 552
550 dma_window = (u32 *)dma_window_prop; 553 dma_window = dma_window_prop;
551 554
552 /* busno is always one cell */ 555 /* busno is always one cell */
553 *busno = *(dma_window++); 556 *busno = *(dma_window++);
@@ -576,13 +579,13 @@ static struct device_node *of_irq_dflt_pic;
576static struct device_node *of_irq_find_parent(struct device_node *child) 579static struct device_node *of_irq_find_parent(struct device_node *child)
577{ 580{
578 struct device_node *p; 581 struct device_node *p;
579 phandle *parp; 582 const phandle *parp;
580 583
581 if (!of_node_get(child)) 584 if (!of_node_get(child))
582 return NULL; 585 return NULL;
583 586
584 do { 587 do {
585 parp = (phandle *)get_property(child, "interrupt-parent", NULL); 588 parp = get_property(child, "interrupt-parent", NULL);
586 if (parp == NULL) 589 if (parp == NULL)
587 p = of_get_parent(child); 590 p = of_get_parent(child);
588 else { 591 else {
@@ -639,11 +642,11 @@ void of_irq_map_init(unsigned int flags)
639 642
640} 643}
641 644
642int of_irq_map_raw(struct device_node *parent, u32 *intspec, u32 ointsize, 645int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize,
643 u32 *addr, struct of_irq *out_irq) 646 const u32 *addr, struct of_irq *out_irq)
644{ 647{
645 struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL; 648 struct device_node *ipar, *tnode, *old = NULL, *newpar = NULL;
646 u32 *tmp, *imap, *imask; 649 const u32 *tmp, *imap, *imask;
647 u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0; 650 u32 intsize = 1, addrsize, newintsize = 0, newaddrsize = 0;
648 int imaplen, match, i; 651 int imaplen, match, i;
649 652
@@ -657,7 +660,7 @@ int of_irq_map_raw(struct device_node *parent, u32 *intspec, u32 ointsize,
657 * is none, we are nice and just walk up the tree 660 * is none, we are nice and just walk up the tree
658 */ 661 */
659 do { 662 do {
660 tmp = (u32 *)get_property(ipar, "#interrupt-cells", NULL); 663 tmp = get_property(ipar, "#interrupt-cells", NULL);
661 if (tmp != NULL) { 664 if (tmp != NULL) {
662 intsize = *tmp; 665 intsize = *tmp;
663 break; 666 break;
@@ -681,7 +684,7 @@ int of_irq_map_raw(struct device_node *parent, u32 *intspec, u32 ointsize,
681 */ 684 */
682 old = of_node_get(ipar); 685 old = of_node_get(ipar);
683 do { 686 do {
684 tmp = (u32 *)get_property(old, "#address-cells", NULL); 687 tmp = get_property(old, "#address-cells", NULL);
685 tnode = of_get_parent(old); 688 tnode = of_get_parent(old);
686 of_node_put(old); 689 of_node_put(old);
687 old = tnode; 690 old = tnode;
@@ -708,7 +711,7 @@ int of_irq_map_raw(struct device_node *parent, u32 *intspec, u32 ointsize,
708 } 711 }
709 712
710 /* Now look for an interrupt-map */ 713 /* Now look for an interrupt-map */
711 imap = (u32 *)get_property(ipar, "interrupt-map", &imaplen); 714 imap = get_property(ipar, "interrupt-map", &imaplen);
712 /* No interrupt map, check for an interrupt parent */ 715 /* No interrupt map, check for an interrupt parent */
713 if (imap == NULL) { 716 if (imap == NULL) {
714 DBG(" -> no map, getting parent\n"); 717 DBG(" -> no map, getting parent\n");
@@ -718,7 +721,7 @@ int of_irq_map_raw(struct device_node *parent, u32 *intspec, u32 ointsize,
718 imaplen /= sizeof(u32); 721 imaplen /= sizeof(u32);
719 722
720 /* Look for a mask */ 723 /* Look for a mask */
721 imask = (u32 *)get_property(ipar, "interrupt-map-mask", NULL); 724 imask = get_property(ipar, "interrupt-map-mask", NULL);
722 725
723 /* If we were passed no "reg" property and we attempt to parse 726 /* If we were passed no "reg" property and we attempt to parse
724 * an interrupt-map, then #address-cells must be 0. 727 * an interrupt-map, then #address-cells must be 0.
@@ -765,14 +768,14 @@ int of_irq_map_raw(struct device_node *parent, u32 *intspec, u32 ointsize,
765 /* Get #interrupt-cells and #address-cells of new 768 /* Get #interrupt-cells and #address-cells of new
766 * parent 769 * parent
767 */ 770 */
768 tmp = (u32 *)get_property(newpar, "#interrupt-cells", 771 tmp = get_property(newpar, "#interrupt-cells",
769 NULL); 772 NULL);
770 if (tmp == NULL) { 773 if (tmp == NULL) {
771 DBG(" -> parent lacks #interrupt-cells !\n"); 774 DBG(" -> parent lacks #interrupt-cells !\n");
772 goto fail; 775 goto fail;
773 } 776 }
774 newintsize = *tmp; 777 newintsize = *tmp;
775 tmp = (u32 *)get_property(newpar, "#address-cells", 778 tmp = get_property(newpar, "#address-cells",
776 NULL); 779 NULL);
777 newaddrsize = (tmp == NULL) ? 0 : *tmp; 780 newaddrsize = (tmp == NULL) ? 0 : *tmp;
778 781
@@ -818,14 +821,14 @@ EXPORT_SYMBOL_GPL(of_irq_map_raw);
818static int of_irq_map_oldworld(struct device_node *device, int index, 821static int of_irq_map_oldworld(struct device_node *device, int index,
819 struct of_irq *out_irq) 822 struct of_irq *out_irq)
820{ 823{
821 u32 *ints; 824 const u32 *ints;
822 int intlen; 825 int intlen;
823 826
824 /* 827 /*
825 * Old machines just have a list of interrupt numbers 828 * Old machines just have a list of interrupt numbers
826 * and no interrupt-controller nodes. 829 * and no interrupt-controller nodes.
827 */ 830 */
828 ints = (u32 *) get_property(device, "AAPL,interrupts", &intlen); 831 ints = get_property(device, "AAPL,interrupts", &intlen);
829 if (ints == NULL) 832 if (ints == NULL)
830 return -EINVAL; 833 return -EINVAL;
831 intlen /= sizeof(u32); 834 intlen /= sizeof(u32);
@@ -850,7 +853,8 @@ static int of_irq_map_oldworld(struct device_node *device, int index,
850int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq) 853int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq)
851{ 854{
852 struct device_node *p; 855 struct device_node *p;
853 u32 *intspec, *tmp, intsize, intlen, *addr; 856 const u32 *intspec, *tmp, *addr;
857 u32 intsize, intlen;
854 int res; 858 int res;
855 859
856 DBG("of_irq_map_one: dev=%s, index=%d\n", device->full_name, index); 860 DBG("of_irq_map_one: dev=%s, index=%d\n", device->full_name, index);
@@ -860,13 +864,13 @@ int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq
860 return of_irq_map_oldworld(device, index, out_irq); 864 return of_irq_map_oldworld(device, index, out_irq);
861 865
862 /* Get the interrupts property */ 866 /* Get the interrupts property */
863 intspec = (u32 *)get_property(device, "interrupts", &intlen); 867 intspec = get_property(device, "interrupts", &intlen);
864 if (intspec == NULL) 868 if (intspec == NULL)
865 return -EINVAL; 869 return -EINVAL;
866 intlen /= sizeof(u32); 870 intlen /= sizeof(u32);
867 871
868 /* Get the reg property (if any) */ 872 /* Get the reg property (if any) */
869 addr = (u32 *)get_property(device, "reg", NULL); 873 addr = get_property(device, "reg", NULL);
870 874
871 /* Look for the interrupt parent. */ 875 /* Look for the interrupt parent. */
872 p = of_irq_find_parent(device); 876 p = of_irq_find_parent(device);
@@ -874,7 +878,7 @@ int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq
874 return -EINVAL; 878 return -EINVAL;
875 879
876 /* Get size of interrupt specifier */ 880 /* Get size of interrupt specifier */
877 tmp = (u32 *)get_property(p, "#interrupt-cells", NULL); 881 tmp = get_property(p, "#interrupt-cells", NULL);
878 if (tmp == NULL) { 882 if (tmp == NULL) {
879 of_node_put(p); 883 of_node_put(p);
880 return -EINVAL; 884 return -EINVAL;
diff --git a/arch/powerpc/kernel/rtas-proc.c b/arch/powerpc/kernel/rtas-proc.c
index 9c9ad1fa9cce..2fe82abf1c52 100644
--- a/arch/powerpc/kernel/rtas-proc.c
+++ b/arch/powerpc/kernel/rtas-proc.c
@@ -246,12 +246,12 @@ struct file_operations ppc_rtas_rmo_buf_ops = {
246 246
247static int ppc_rtas_find_all_sensors(void); 247static int ppc_rtas_find_all_sensors(void);
248static void ppc_rtas_process_sensor(struct seq_file *m, 248static void ppc_rtas_process_sensor(struct seq_file *m,
249 struct individual_sensor *s, int state, int error, char *loc); 249 struct individual_sensor *s, int state, int error, const char *loc);
250static char *ppc_rtas_process_error(int error); 250static char *ppc_rtas_process_error(int error);
251static void get_location_code(struct seq_file *m, 251static void get_location_code(struct seq_file *m,
252 struct individual_sensor *s, char *loc); 252 struct individual_sensor *s, const char *loc);
253static void check_location_string(struct seq_file *m, char *c); 253static void check_location_string(struct seq_file *m, const char *c);
254static void check_location(struct seq_file *m, char *c); 254static void check_location(struct seq_file *m, const char *c);
255 255
256static int __init proc_rtas_init(void) 256static int __init proc_rtas_init(void)
257{ 257{
@@ -446,11 +446,11 @@ static int ppc_rtas_sensors_show(struct seq_file *m, void *v)
446 for (i=0; i<sensors.quant; i++) { 446 for (i=0; i<sensors.quant; i++) {
447 struct individual_sensor *p = &sensors.sensor[i]; 447 struct individual_sensor *p = &sensors.sensor[i];
448 char rstr[64]; 448 char rstr[64];
449 char *loc; 449 const char *loc;
450 int llen, offs; 450 int llen, offs;
451 451
452 sprintf (rstr, SENSOR_PREFIX"%04d", p->token); 452 sprintf (rstr, SENSOR_PREFIX"%04d", p->token);
453 loc = (char *) get_property(rtas_node, rstr, &llen); 453 loc = get_property(rtas_node, rstr, &llen);
454 454
455 /* A sensor may have multiple instances */ 455 /* A sensor may have multiple instances */
456 for (j = 0, offs = 0; j <= p->quant; j++) { 456 for (j = 0, offs = 0; j <= p->quant; j++) {
@@ -474,10 +474,10 @@ static int ppc_rtas_sensors_show(struct seq_file *m, void *v)
474 474
475static int ppc_rtas_find_all_sensors(void) 475static int ppc_rtas_find_all_sensors(void)
476{ 476{
477 unsigned int *utmp; 477 const unsigned int *utmp;
478 int len, i; 478 int len, i;
479 479
480 utmp = (unsigned int *) get_property(rtas_node, "rtas-sensors", &len); 480 utmp = get_property(rtas_node, "rtas-sensors", &len);
481 if (utmp == NULL) { 481 if (utmp == NULL) {
482 printk (KERN_ERR "error: could not get rtas-sensors\n"); 482 printk (KERN_ERR "error: could not get rtas-sensors\n");
483 return 1; 483 return 1;
@@ -530,7 +530,7 @@ static char *ppc_rtas_process_error(int error)
530 */ 530 */
531 531
532static void ppc_rtas_process_sensor(struct seq_file *m, 532static void ppc_rtas_process_sensor(struct seq_file *m,
533 struct individual_sensor *s, int state, int error, char *loc) 533 struct individual_sensor *s, int state, int error, const char *loc)
534{ 534{
535 /* Defined return vales */ 535 /* Defined return vales */
536 const char * key_switch[] = { "Off\t", "Normal\t", "Secure\t", 536 const char * key_switch[] = { "Off\t", "Normal\t", "Secure\t",
@@ -682,7 +682,7 @@ static void ppc_rtas_process_sensor(struct seq_file *m,
682 682
683/* ****************************************************************** */ 683/* ****************************************************************** */
684 684
685static void check_location(struct seq_file *m, char *c) 685static void check_location(struct seq_file *m, const char *c)
686{ 686{
687 switch (c[0]) { 687 switch (c[0]) {
688 case LOC_PLANAR: 688 case LOC_PLANAR:
@@ -719,7 +719,7 @@ static void check_location(struct seq_file *m, char *c)
719 * ${LETTER}${NUMBER}[[-/]${LETTER}${NUMBER} [ ... ] ] 719 * ${LETTER}${NUMBER}[[-/]${LETTER}${NUMBER} [ ... ] ]
720 * the '.' may be an abbrevation 720 * the '.' may be an abbrevation
721 */ 721 */
722static void check_location_string(struct seq_file *m, char *c) 722static void check_location_string(struct seq_file *m, const char *c)
723{ 723{
724 while (*c) { 724 while (*c) {
725 if (isalpha(*c) || *c == '.') 725 if (isalpha(*c) || *c == '.')
@@ -733,7 +733,8 @@ static void check_location_string(struct seq_file *m, char *c)
733 733
734/* ****************************************************************** */ 734/* ****************************************************************** */
735 735
736static void get_location_code(struct seq_file *m, struct individual_sensor *s, char *loc) 736static void get_location_code(struct seq_file *m, struct individual_sensor *s,
737 const char *loc)
737{ 738{
738 if (!loc || !*loc) { 739 if (!loc || !*loc) {
739 seq_printf(m, "---");/* does not have a location */ 740 seq_printf(m, "---");/* does not have a location */
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 77f1e06d208d..6ef80d4e38d3 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -177,10 +177,12 @@ void __init udbg_init_rtas_console(void)
177void rtas_progress(char *s, unsigned short hex) 177void rtas_progress(char *s, unsigned short hex)
178{ 178{
179 struct device_node *root; 179 struct device_node *root;
180 int width, *p; 180 int width;
181 const int *p;
181 char *os; 182 char *os;
182 static int display_character, set_indicator; 183 static int display_character, set_indicator;
183 static int display_width, display_lines, *row_width, form_feed; 184 static int display_width, display_lines, form_feed;
185 const static int *row_width;
184 static DEFINE_SPINLOCK(progress_lock); 186 static DEFINE_SPINLOCK(progress_lock);
185 static int current_line; 187 static int current_line;
186 static int pending_newline = 0; /* did last write end with unprinted newline? */ 188 static int pending_newline = 0; /* did last write end with unprinted newline? */
@@ -191,16 +193,16 @@ void rtas_progress(char *s, unsigned short hex)
191 if (display_width == 0) { 193 if (display_width == 0) {
192 display_width = 0x10; 194 display_width = 0x10;
193 if ((root = find_path_device("/rtas"))) { 195 if ((root = find_path_device("/rtas"))) {
194 if ((p = (unsigned int *)get_property(root, 196 if ((p = get_property(root,
195 "ibm,display-line-length", NULL))) 197 "ibm,display-line-length", NULL)))
196 display_width = *p; 198 display_width = *p;
197 if ((p = (unsigned int *)get_property(root, 199 if ((p = get_property(root,
198 "ibm,form-feed", NULL))) 200 "ibm,form-feed", NULL)))
199 form_feed = *p; 201 form_feed = *p;
200 if ((p = (unsigned int *)get_property(root, 202 if ((p = get_property(root,
201 "ibm,display-number-of-lines", NULL))) 203 "ibm,display-number-of-lines", NULL)))
202 display_lines = *p; 204 display_lines = *p;
203 row_width = (unsigned int *)get_property(root, 205 row_width = get_property(root,
204 "ibm,display-truncation-length", NULL); 206 "ibm,display-truncation-length", NULL);
205 } 207 }
206 display_character = rtas_token("display-character"); 208 display_character = rtas_token("display-character");
@@ -293,10 +295,10 @@ EXPORT_SYMBOL(rtas_progress); /* needed by rtas_flash module */
293 295
294int rtas_token(const char *service) 296int rtas_token(const char *service)
295{ 297{
296 int *tokp; 298 const int *tokp;
297 if (rtas.dev == NULL) 299 if (rtas.dev == NULL)
298 return RTAS_UNKNOWN_SERVICE; 300 return RTAS_UNKNOWN_SERVICE;
299 tokp = (int *) get_property(rtas.dev, service, NULL); 301 tokp = get_property(rtas.dev, service, NULL);
300 return tokp ? *tokp : RTAS_UNKNOWN_SERVICE; 302 return tokp ? *tokp : RTAS_UNKNOWN_SERVICE;
301} 303}
302EXPORT_SYMBOL(rtas_token); 304EXPORT_SYMBOL(rtas_token);
@@ -626,6 +628,9 @@ void rtas_os_term(char *str)
626{ 628{
627 int status; 629 int status;
628 630
631 if (panic_timeout)
632 return;
633
629 if (RTAS_UNKNOWN_SERVICE == rtas_token("ibm,os-term")) 634 if (RTAS_UNKNOWN_SERVICE == rtas_token("ibm,os-term"))
630 return; 635 return;
631 636
@@ -687,15 +692,14 @@ static int rtas_ibm_suspend_me(struct rtas_args *args)
687 int i; 692 int i;
688 long state; 693 long state;
689 long rc; 694 long rc;
690 unsigned long dummy; 695 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
691
692 struct rtas_suspend_me_data data; 696 struct rtas_suspend_me_data data;
693 697
694 /* Make sure the state is valid */ 698 /* Make sure the state is valid */
695 rc = plpar_hcall(H_VASI_STATE, 699 rc = plpar_hcall(H_VASI_STATE, retbuf,
696 ((u64)args->args[0] << 32) | args->args[1], 700 ((u64)args->args[0] << 32) | args->args[1]);
697 0, 0, 0, 701
698 &state, &dummy, &dummy); 702 state = retbuf[0];
699 703
700 if (rc) { 704 if (rc) {
701 printk(KERN_ERR "rtas_ibm_suspend_me: vasi_state returned %ld\n",rc); 705 printk(KERN_ERR "rtas_ibm_suspend_me: vasi_state returned %ld\n",rc);
@@ -845,15 +849,15 @@ void __init rtas_initialize(void)
845 */ 849 */
846 rtas.dev = of_find_node_by_name(NULL, "rtas"); 850 rtas.dev = of_find_node_by_name(NULL, "rtas");
847 if (rtas.dev) { 851 if (rtas.dev) {
848 u32 *basep, *entryp; 852 const u32 *basep, *entryp, *sizep;
849 u32 *sizep;
850 853
851 basep = (u32 *)get_property(rtas.dev, "linux,rtas-base", NULL); 854 basep = get_property(rtas.dev, "linux,rtas-base", NULL);
852 sizep = (u32 *)get_property(rtas.dev, "rtas-size", NULL); 855 sizep = get_property(rtas.dev, "rtas-size", NULL);
853 if (basep != NULL && sizep != NULL) { 856 if (basep != NULL && sizep != NULL) {
854 rtas.base = *basep; 857 rtas.base = *basep;
855 rtas.size = *sizep; 858 rtas.size = *sizep;
856 entryp = (u32 *)get_property(rtas.dev, "linux,rtas-entry", NULL); 859 entryp = get_property(rtas.dev,
860 "linux,rtas-entry", NULL);
857 if (entryp == NULL) /* Ugh */ 861 if (entryp == NULL) /* Ugh */
858 rtas.entry = rtas.base; 862 rtas.entry = rtas.base;
859 else 863 else
@@ -909,6 +913,11 @@ int __init early_init_dt_scan_rtas(unsigned long node,
909 basep = of_get_flat_dt_prop(node, "get-term-char", NULL); 913 basep = of_get_flat_dt_prop(node, "get-term-char", NULL);
910 if (basep) 914 if (basep)
911 rtas_getchar_token = *basep; 915 rtas_getchar_token = *basep;
916
917 if (rtas_putchar_token != RTAS_UNKNOWN_SERVICE &&
918 rtas_getchar_token != RTAS_UNKNOWN_SERVICE)
919 udbg_init_rtas_console();
920
912#endif 921#endif
913 922
914 /* break now */ 923 /* break now */
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
index cda022657324..b4a0de79c060 100644
--- a/arch/powerpc/kernel/rtas_pci.c
+++ b/arch/powerpc/kernel/rtas_pci.c
@@ -57,7 +57,7 @@ static inline int config_access_valid(struct pci_dn *dn, int where)
57 57
58static int of_device_available(struct device_node * dn) 58static int of_device_available(struct device_node * dn)
59{ 59{
60 char * status; 60 const char *status;
61 61
62 status = get_property(dn, "status", NULL); 62 status = get_property(dn, "status", NULL);
63 63
@@ -81,8 +81,7 @@ int rtas_read_config(struct pci_dn *pdn, int where, int size, u32 *val)
81 if (!config_access_valid(pdn, where)) 81 if (!config_access_valid(pdn, where))
82 return PCIBIOS_BAD_REGISTER_NUMBER; 82 return PCIBIOS_BAD_REGISTER_NUMBER;
83 83
84 addr = ((where & 0xf00) << 20) | (pdn->busno << 16) | 84 addr = rtas_config_addr(pdn->busno, pdn->devfn, where);
85 (pdn->devfn << 8) | (where & 0xff);
86 buid = pdn->phb->buid; 85 buid = pdn->phb->buid;
87 if (buid) { 86 if (buid) {
88 ret = rtas_call(ibm_read_pci_config, 4, 2, &returnval, 87 ret = rtas_call(ibm_read_pci_config, 4, 2, &returnval,
@@ -134,8 +133,7 @@ int rtas_write_config(struct pci_dn *pdn, int where, int size, u32 val)
134 if (!config_access_valid(pdn, where)) 133 if (!config_access_valid(pdn, where))
135 return PCIBIOS_BAD_REGISTER_NUMBER; 134 return PCIBIOS_BAD_REGISTER_NUMBER;
136 135
137 addr = ((where & 0xf00) << 20) | (pdn->busno << 16) | 136 addr = rtas_config_addr(pdn->busno, pdn->devfn, where);
138 (pdn->devfn << 8) | (where & 0xff);
139 buid = pdn->phb->buid; 137 buid = pdn->phb->buid;
140 if (buid) { 138 if (buid) {
141 ret = rtas_call(ibm_write_pci_config, 5, 1, NULL, addr, 139 ret = rtas_call(ibm_write_pci_config, 5, 1, NULL, addr,
@@ -178,7 +176,7 @@ struct pci_ops rtas_pci_ops = {
178 176
179int is_python(struct device_node *dev) 177int is_python(struct device_node *dev)
180{ 178{
181 char *model = (char *)get_property(dev, "model", NULL); 179 const char *model = get_property(dev, "model", NULL);
182 180
183 if (model && strstr(model, "Python")) 181 if (model && strstr(model, "Python"))
184 return 1; 182 return 1;
@@ -234,7 +232,7 @@ void __init init_pci_config_tokens (void)
234unsigned long __devinit get_phb_buid (struct device_node *phb) 232unsigned long __devinit get_phb_buid (struct device_node *phb)
235{ 233{
236 int addr_cells; 234 int addr_cells;
237 unsigned int *buid_vals; 235 const unsigned int *buid_vals;
238 unsigned int len; 236 unsigned int len;
239 unsigned long buid; 237 unsigned long buid;
240 238
@@ -247,7 +245,7 @@ unsigned long __devinit get_phb_buid (struct device_node *phb)
247 if (phb->parent->parent) 245 if (phb->parent->parent)
248 return 0; 246 return 0;
249 247
250 buid_vals = (unsigned int *) get_property(phb, "reg", &len); 248 buid_vals = get_property(phb, "reg", &len);
251 if (buid_vals == NULL) 249 if (buid_vals == NULL)
252 return 0; 250 return 0;
253 251
@@ -264,10 +262,10 @@ unsigned long __devinit get_phb_buid (struct device_node *phb)
264static int phb_set_bus_ranges(struct device_node *dev, 262static int phb_set_bus_ranges(struct device_node *dev,
265 struct pci_controller *phb) 263 struct pci_controller *phb)
266{ 264{
267 int *bus_range; 265 const int *bus_range;
268 unsigned int len; 266 unsigned int len;
269 267
270 bus_range = (int *) get_property(dev, "bus-range", &len); 268 bus_range = get_property(dev, "bus-range", &len);
271 if (bus_range == NULL || len < 2 * sizeof(int)) { 269 if (bus_range == NULL || len < 2 * sizeof(int)) {
272 return 1; 270 return 1;
273 } 271 }
@@ -325,15 +323,15 @@ unsigned long __init find_and_init_phbs(void)
325 * in chosen. 323 * in chosen.
326 */ 324 */
327 if (of_chosen) { 325 if (of_chosen) {
328 int *prop; 326 const int *prop;
329 327
330 prop = (int *)get_property(of_chosen, "linux,pci-probe-only", 328 prop = get_property(of_chosen,
331 NULL); 329 "linux,pci-probe-only", NULL);
332 if (prop) 330 if (prop)
333 pci_probe_only = *prop; 331 pci_probe_only = *prop;
334 332
335 prop = (int *)get_property(of_chosen, 333 prop = get_property(of_chosen,
336 "linux,pci-assign-all-buses", NULL); 334 "linux,pci-assign-all-buses", NULL);
337 if (prop) 335 if (prop)
338 pci_assign_all_buses = *prop; 336 pci_assign_all_buses = *prop;
339 } 337 }
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 499c3861074f..0af3fc1bdcc9 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -304,19 +304,21 @@ struct seq_operations cpuinfo_op = {
304void __init check_for_initrd(void) 304void __init check_for_initrd(void)
305{ 305{
306#ifdef CONFIG_BLK_DEV_INITRD 306#ifdef CONFIG_BLK_DEV_INITRD
307 unsigned long *prop; 307 const unsigned int *prop;
308 int len;
308 309
309 DBG(" -> check_for_initrd()\n"); 310 DBG(" -> check_for_initrd()\n");
310 311
311 if (of_chosen) { 312 if (of_chosen) {
312 prop = (unsigned long *)get_property(of_chosen, 313 prop = get_property(of_chosen, "linux,initrd-start", &len);
313 "linux,initrd-start", NULL);
314 if (prop != NULL) { 314 if (prop != NULL) {
315 initrd_start = (unsigned long)__va(*prop); 315 initrd_start = (unsigned long)
316 prop = (unsigned long *)get_property(of_chosen, 316 __va(of_read_ulong(prop, len / 4));
317 "linux,initrd-end", NULL); 317 prop = get_property(of_chosen,
318 "linux,initrd-end", &len);
318 if (prop != NULL) { 319 if (prop != NULL) {
319 initrd_end = (unsigned long)__va(*prop); 320 initrd_end = (unsigned long)
321 __va(of_read_ulong(prop, len / 4));
320 initrd_below_start_ok = 1; 322 initrd_below_start_ok = 1;
321 } else 323 } else
322 initrd_start = 0; 324 initrd_start = 0;
@@ -366,15 +368,14 @@ void __init smp_setup_cpu_maps(void)
366 int cpu = 0; 368 int cpu = 0;
367 369
368 while ((dn = of_find_node_by_type(dn, "cpu")) && cpu < NR_CPUS) { 370 while ((dn = of_find_node_by_type(dn, "cpu")) && cpu < NR_CPUS) {
369 int *intserv; 371 const int *intserv;
370 int j, len = sizeof(u32), nthreads = 1; 372 int j, len = sizeof(u32), nthreads = 1;
371 373
372 intserv = (int *)get_property(dn, "ibm,ppc-interrupt-server#s", 374 intserv = get_property(dn, "ibm,ppc-interrupt-server#s", &len);
373 &len);
374 if (intserv) 375 if (intserv)
375 nthreads = len / sizeof(int); 376 nthreads = len / sizeof(int);
376 else { 377 else {
377 intserv = (int *) get_property(dn, "reg", NULL); 378 intserv = get_property(dn, "reg", NULL);
378 if (!intserv) 379 if (!intserv)
379 intserv = &cpu; /* assume logical == phys */ 380 intserv = &cpu; /* assume logical == phys */
380 } 381 }
@@ -395,13 +396,12 @@ void __init smp_setup_cpu_maps(void)
395 if (machine_is(pseries) && firmware_has_feature(FW_FEATURE_LPAR) && 396 if (machine_is(pseries) && firmware_has_feature(FW_FEATURE_LPAR) &&
396 (dn = of_find_node_by_path("/rtas"))) { 397 (dn = of_find_node_by_path("/rtas"))) {
397 int num_addr_cell, num_size_cell, maxcpus; 398 int num_addr_cell, num_size_cell, maxcpus;
398 unsigned int *ireg; 399 const unsigned int *ireg;
399 400
400 num_addr_cell = prom_n_addr_cells(dn); 401 num_addr_cell = prom_n_addr_cells(dn);
401 num_size_cell = prom_n_size_cells(dn); 402 num_size_cell = prom_n_size_cells(dn);
402 403
403 ireg = (unsigned int *) 404 ireg = get_property(dn, "ibm,lrdr-capacity", NULL);
404 get_property(dn, "ibm,lrdr-capacity", NULL);
405 405
406 if (!ireg) 406 if (!ireg)
407 goto out; 407 goto out;
@@ -444,6 +444,8 @@ void __init smp_setup_cpu_maps(void)
444 444
445int __initdata do_early_xmon; 445int __initdata do_early_xmon;
446#ifdef CONFIG_XMON 446#ifdef CONFIG_XMON
447extern int xmon_no_auto_backtrace;
448
447static int __init early_xmon(char *p) 449static int __init early_xmon(char *p)
448{ 450{
449 /* ensure xmon is enabled */ 451 /* ensure xmon is enabled */
@@ -452,6 +454,8 @@ static int __init early_xmon(char *p)
452 xmon_init(1); 454 xmon_init(1);
453 if (strncmp(p, "off", 3) == 0) 455 if (strncmp(p, "off", 3) == 0)
454 xmon_init(0); 456 xmon_init(0);
457 if (strncmp(p, "nobt", 4) == 0)
458 xmon_no_auto_backtrace = 1;
455 if (strncmp(p, "early", 5) != 0) 459 if (strncmp(p, "early", 5) != 0)
456 return 0; 460 return 0;
457 } 461 }
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index fd1785e4c9bb..00d6b8addd78 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -56,7 +56,6 @@
56#include <asm/page.h> 56#include <asm/page.h>
57#include <asm/mmu.h> 57#include <asm/mmu.h>
58#include <asm/lmb.h> 58#include <asm/lmb.h>
59#include <asm/iseries/it_lp_naca.h>
60#include <asm/firmware.h> 59#include <asm/firmware.h>
61#include <asm/xmon.h> 60#include <asm/xmon.h>
62#include <asm/udbg.h> 61#include <asm/udbg.h>
@@ -79,10 +78,10 @@ u64 ppc64_pft_size;
79 * before we've read this from the device tree. 78 * before we've read this from the device tree.
80 */ 79 */
81struct ppc64_caches ppc64_caches = { 80struct ppc64_caches ppc64_caches = {
82 .dline_size = 0x80, 81 .dline_size = 0x40,
83 .log_dline_size = 7, 82 .log_dline_size = 6,
84 .iline_size = 0x80, 83 .iline_size = 0x40,
85 .log_iline_size = 7 84 .log_iline_size = 6
86}; 85};
87EXPORT_SYMBOL_GPL(ppc64_caches); 86EXPORT_SYMBOL_GPL(ppc64_caches);
88 87
@@ -107,7 +106,7 @@ static int smt_enabled_cmdline;
107static void check_smt_enabled(void) 106static void check_smt_enabled(void)
108{ 107{
109 struct device_node *dn; 108 struct device_node *dn;
110 char *smt_option; 109 const char *smt_option;
111 110
112 /* Allow the command line to overrule the OF option */ 111 /* Allow the command line to overrule the OF option */
113 if (smt_enabled_cmdline) 112 if (smt_enabled_cmdline)
@@ -116,7 +115,7 @@ static void check_smt_enabled(void)
116 dn = of_find_node_by_path("/options"); 115 dn = of_find_node_by_path("/options");
117 116
118 if (dn) { 117 if (dn) {
119 smt_option = (char *)get_property(dn, "ibm,smt-enabled", NULL); 118 smt_option = get_property(dn, "ibm,smt-enabled", NULL);
120 119
121 if (smt_option) { 120 if (smt_option) {
122 if (!strcmp(smt_option, "on")) 121 if (!strcmp(smt_option, "on"))
@@ -293,7 +292,7 @@ static void __init initialize_cache_info(void)
293 */ 292 */
294 293
295 if ( num_cpus == 1 ) { 294 if ( num_cpus == 1 ) {
296 u32 *sizep, *lsizep; 295 const u32 *sizep, *lsizep;
297 u32 size, lsize; 296 u32 size, lsize;
298 const char *dc, *ic; 297 const char *dc, *ic;
299 298
@@ -308,10 +307,10 @@ static void __init initialize_cache_info(void)
308 307
309 size = 0; 308 size = 0;
310 lsize = cur_cpu_spec->dcache_bsize; 309 lsize = cur_cpu_spec->dcache_bsize;
311 sizep = (u32 *)get_property(np, "d-cache-size", NULL); 310 sizep = get_property(np, "d-cache-size", NULL);
312 if (sizep != NULL) 311 if (sizep != NULL)
313 size = *sizep; 312 size = *sizep;
314 lsizep = (u32 *) get_property(np, dc, NULL); 313 lsizep = get_property(np, dc, NULL);
315 if (lsizep != NULL) 314 if (lsizep != NULL)
316 lsize = *lsizep; 315 lsize = *lsizep;
317 if (sizep == 0 || lsizep == 0) 316 if (sizep == 0 || lsizep == 0)
@@ -325,10 +324,10 @@ static void __init initialize_cache_info(void)
325 324
326 size = 0; 325 size = 0;
327 lsize = cur_cpu_spec->icache_bsize; 326 lsize = cur_cpu_spec->icache_bsize;
328 sizep = (u32 *)get_property(np, "i-cache-size", NULL); 327 sizep = get_property(np, "i-cache-size", NULL);
329 if (sizep != NULL) 328 if (sizep != NULL)
330 size = *sizep; 329 size = *sizep;
331 lsizep = (u32 *)get_property(np, ic, NULL); 330 lsizep = get_property(np, ic, NULL);
332 if (lsizep != NULL) 331 if (lsizep != NULL)
333 lsize = *lsizep; 332 lsize = *lsizep;
334 if (sizep == 0 || lsizep == 0) 333 if (sizep == 0 || lsizep == 0)
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index fec228cd0163..406f308ddead 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -60,7 +60,7 @@ static int smt_snooze_cmdline;
60static int __init smt_setup(void) 60static int __init smt_setup(void)
61{ 61{
62 struct device_node *options; 62 struct device_node *options;
63 unsigned int *val; 63 const unsigned int *val;
64 unsigned int cpu; 64 unsigned int cpu;
65 65
66 if (!cpu_has_feature(CPU_FTR_SMT)) 66 if (!cpu_has_feature(CPU_FTR_SMT))
@@ -70,8 +70,7 @@ static int __init smt_setup(void)
70 if (!options) 70 if (!options)
71 return -ENODEV; 71 return -ENODEV;
72 72
73 val = (unsigned int *)get_property(options, "ibm,smt-snooze-delay", 73 val = get_property(options, "ibm,smt-snooze-delay", NULL);
74 NULL);
75 if (!smt_snooze_cmdline && val) { 74 if (!smt_snooze_cmdline && val) {
76 for_each_possible_cpu(cpu) 75 for_each_possible_cpu(cpu)
77 per_cpu(smt_snooze_delay, cpu) = *val; 76 per_cpu(smt_snooze_delay, cpu) = *val;
@@ -231,7 +230,7 @@ static void register_cpu_online(unsigned int cpu)
231 if (cur_cpu_spec->num_pmcs >= 8) 230 if (cur_cpu_spec->num_pmcs >= 8)
232 sysdev_create_file(s, &attr_pmc8); 231 sysdev_create_file(s, &attr_pmc8);
233 232
234 if (cpu_has_feature(CPU_FTR_SMT)) 233 if (cpu_has_feature(CPU_FTR_PURR))
235 sysdev_create_file(s, &attr_purr); 234 sysdev_create_file(s, &attr_purr);
236} 235}
237 236
@@ -273,7 +272,7 @@ static void unregister_cpu_online(unsigned int cpu)
273 if (cur_cpu_spec->num_pmcs >= 8) 272 if (cur_cpu_spec->num_pmcs >= 8)
274 sysdev_remove_file(s, &attr_pmc8); 273 sysdev_remove_file(s, &attr_pmc8);
275 274
276 if (cpu_has_feature(CPU_FTR_SMT)) 275 if (cpu_has_feature(CPU_FTR_PURR))
277 sysdev_remove_file(s, &attr_purr); 276 sysdev_remove_file(s, &attr_purr);
278} 277}
279#endif /* CONFIG_HOTPLUG_CPU */ 278#endif /* CONFIG_HOTPLUG_CPU */
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index a124499e65d9..7a3c3f791ade 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -860,19 +860,17 @@ EXPORT_SYMBOL(do_settimeofday);
860static int __init get_freq(char *name, int cells, unsigned long *val) 860static int __init get_freq(char *name, int cells, unsigned long *val)
861{ 861{
862 struct device_node *cpu; 862 struct device_node *cpu;
863 unsigned int *fp; 863 const unsigned int *fp;
864 int found = 0; 864 int found = 0;
865 865
866 /* The cpu node should have timebase and clock frequency properties */ 866 /* The cpu node should have timebase and clock frequency properties */
867 cpu = of_find_node_by_type(NULL, "cpu"); 867 cpu = of_find_node_by_type(NULL, "cpu");
868 868
869 if (cpu) { 869 if (cpu) {
870 fp = (unsigned int *)get_property(cpu, name, NULL); 870 fp = get_property(cpu, name, NULL);
871 if (fp) { 871 if (fp) {
872 found = 1; 872 found = 1;
873 *val = 0; 873 *val = of_read_ulong(fp, cells);
874 while (cells--)
875 *val = (*val << 32) | *fp++;
876 } 874 }
877 875
878 of_node_put(cpu); 876 of_node_put(cpu);
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 9b352bd0a460..d9f10f2fc372 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -598,6 +598,9 @@ static void parse_fpe(struct pt_regs *regs)
598#define INST_STSWI 0x7c0005aa 598#define INST_STSWI 0x7c0005aa
599#define INST_STSWX 0x7c00052a 599#define INST_STSWX 0x7c00052a
600 600
601#define INST_POPCNTB 0x7c0000f4
602#define INST_POPCNTB_MASK 0xfc0007fe
603
601static int emulate_string_inst(struct pt_regs *regs, u32 instword) 604static int emulate_string_inst(struct pt_regs *regs, u32 instword)
602{ 605{
603 u8 rT = (instword >> 21) & 0x1f; 606 u8 rT = (instword >> 21) & 0x1f;
@@ -666,6 +669,23 @@ static int emulate_string_inst(struct pt_regs *regs, u32 instword)
666 return 0; 669 return 0;
667} 670}
668 671
672static int emulate_popcntb_inst(struct pt_regs *regs, u32 instword)
673{
674 u32 ra,rs;
675 unsigned long tmp;
676
677 ra = (instword >> 16) & 0x1f;
678 rs = (instword >> 21) & 0x1f;
679
680 tmp = regs->gpr[rs];
681 tmp = tmp - ((tmp >> 1) & 0x5555555555555555ULL);
682 tmp = (tmp & 0x3333333333333333ULL) + ((tmp >> 2) & 0x3333333333333333ULL);
683 tmp = (tmp + (tmp >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
684 regs->gpr[ra] = tmp;
685
686 return 0;
687}
688
669static int emulate_instruction(struct pt_regs *regs) 689static int emulate_instruction(struct pt_regs *regs)
670{ 690{
671 u32 instword; 691 u32 instword;
@@ -703,6 +723,11 @@ static int emulate_instruction(struct pt_regs *regs)
703 if ((instword & INST_STRING_GEN_MASK) == INST_STRING) 723 if ((instword & INST_STRING_GEN_MASK) == INST_STRING)
704 return emulate_string_inst(regs, instword); 724 return emulate_string_inst(regs, instword);
705 725
726 /* Emulate the popcntb (Population Count Bytes) instruction. */
727 if ((instword & INST_POPCNTB_MASK) == INST_POPCNTB) {
728 return emulate_popcntb_inst(regs, instword);
729 }
730
706 return -EINVAL; 731 return -EINVAL;
707} 732}
708 733
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index fad8580f9081..cb87e71eec66 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -77,7 +77,7 @@ static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev)
77 } else 77 } else
78#endif 78#endif
79 { 79 {
80 unsigned char *dma_window; 80 const unsigned char *dma_window;
81 struct iommu_table *tbl; 81 struct iommu_table *tbl;
82 unsigned long offset, size; 82 unsigned long offset, size;
83 83
@@ -217,7 +217,7 @@ static void __devinit vio_dev_release(struct device *dev)
217struct vio_dev * __devinit vio_register_device_node(struct device_node *of_node) 217struct vio_dev * __devinit vio_register_device_node(struct device_node *of_node)
218{ 218{
219 struct vio_dev *viodev; 219 struct vio_dev *viodev;
220 unsigned int *unit_address; 220 const unsigned int *unit_address;
221 221
222 /* we need the 'device_type' property, in order to match with drivers */ 222 /* we need the 'device_type' property, in order to match with drivers */
223 if (of_node->type == NULL) { 223 if (of_node->type == NULL) {
@@ -227,7 +227,7 @@ struct vio_dev * __devinit vio_register_device_node(struct device_node *of_node)
227 return NULL; 227 return NULL;
228 } 228 }
229 229
230 unit_address = (unsigned int *)get_property(of_node, "reg", NULL); 230 unit_address = get_property(of_node, "reg", NULL);
231 if (unit_address == NULL) { 231 if (unit_address == NULL) {
232 printk(KERN_WARNING "%s: node %s missing 'reg'\n", 232 printk(KERN_WARNING "%s: node %s missing 'reg'\n",
233 __FUNCTION__, 233 __FUNCTION__,
@@ -249,7 +249,7 @@ struct vio_dev * __devinit vio_register_device_node(struct device_node *of_node)
249 viodev->type = of_node->type; 249 viodev->type = of_node->type;
250 viodev->unit_address = *unit_address; 250 viodev->unit_address = *unit_address;
251 if (firmware_has_feature(FW_FEATURE_ISERIES)) { 251 if (firmware_has_feature(FW_FEATURE_ISERIES)) {
252 unit_address = (unsigned int *)get_property(of_node, 252 unit_address = get_property(of_node,
253 "linux,unit_address", NULL); 253 "linux,unit_address", NULL);
254 if (unit_address != NULL) 254 if (unit_address != NULL)
255 viodev->unit_address = *unit_address; 255 viodev->unit_address = *unit_address;
@@ -423,7 +423,7 @@ static int vio_hotplug(struct device *dev, char **envp, int num_envp,
423{ 423{
424 const struct vio_dev *vio_dev = to_vio_dev(dev); 424 const struct vio_dev *vio_dev = to_vio_dev(dev);
425 struct device_node *dn = dev->platform_data; 425 struct device_node *dn = dev->platform_data;
426 char *cp; 426 const char *cp;
427 int length; 427 int length;
428 428
429 if (!num_envp) 429 if (!num_envp)
@@ -431,7 +431,7 @@ static int vio_hotplug(struct device *dev, char **envp, int num_envp,
431 431
432 if (!dn) 432 if (!dn)
433 return -ENODEV; 433 return -ENODEV;
434 cp = (char *)get_property(dn, "compatible", &length); 434 cp = get_property(dn, "compatible", &length);
435 if (!cp) 435 if (!cp)
436 return -ENODEV; 436 return -ENODEV;
437 437
@@ -493,11 +493,11 @@ static struct vio_dev *vio_find_name(const char *kobj_name)
493 */ 493 */
494struct vio_dev *vio_find_node(struct device_node *vnode) 494struct vio_dev *vio_find_node(struct device_node *vnode)
495{ 495{
496 uint32_t *unit_address; 496 const uint32_t *unit_address;
497 char kobj_name[BUS_ID_SIZE]; 497 char kobj_name[BUS_ID_SIZE];
498 498
499 /* construct the kobject name from the device node */ 499 /* construct the kobject name from the device node */
500 unit_address = (uint32_t *)get_property(vnode, "reg", NULL); 500 unit_address = get_property(vnode, "reg", NULL);
501 if (!unit_address) 501 if (!unit_address)
502 return NULL; 502 return NULL;
503 snprintf(kobj_name, BUS_ID_SIZE, "%x", *unit_address); 503 snprintf(kobj_name, BUS_ID_SIZE, "%x", *unit_address);
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index ff7096458249..336dd191f768 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -14,7 +14,6 @@ endif
14obj-$(CONFIG_PPC64) += checksum_64.o copypage_64.o copyuser_64.o \ 14obj-$(CONFIG_PPC64) += checksum_64.o copypage_64.o copyuser_64.o \
15 memcpy_64.o usercopy_64.o mem_64.o string.o \ 15 memcpy_64.o usercopy_64.o mem_64.o string.o \
16 strcase.o 16 strcase.o
17obj-$(CONFIG_PPC_ISERIES) += e2a.o
18obj-$(CONFIG_XMON) += sstep.o 17obj-$(CONFIG_XMON) += sstep.o
19 18
20ifeq ($(CONFIG_PPC64),y) 19ifeq ($(CONFIG_PPC64),y)
diff --git a/arch/powerpc/lib/e2a.c b/arch/powerpc/lib/e2a.c
deleted file mode 100644
index 4b72ed8fd50e..000000000000
--- a/arch/powerpc/lib/e2a.c
+++ /dev/null
@@ -1,116 +0,0 @@
1/*
2 * EBCDIC to ASCII conversion
3 *
4 * This function moved here from arch/powerpc/platforms/iseries/viopath.c
5 *
6 * (C) Copyright 2000-2004 IBM Corporation
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) anyu later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#include <linux/module.h>
25
26unsigned char e2a(unsigned char x)
27{
28 switch (x) {
29 case 0xF0:
30 return '0';
31 case 0xF1:
32 return '1';
33 case 0xF2:
34 return '2';
35 case 0xF3:
36 return '3';
37 case 0xF4:
38 return '4';
39 case 0xF5:
40 return '5';
41 case 0xF6:
42 return '6';
43 case 0xF7:
44 return '7';
45 case 0xF8:
46 return '8';
47 case 0xF9:
48 return '9';
49 case 0xC1:
50 return 'A';
51 case 0xC2:
52 return 'B';
53 case 0xC3:
54 return 'C';
55 case 0xC4:
56 return 'D';
57 case 0xC5:
58 return 'E';
59 case 0xC6:
60 return 'F';
61 case 0xC7:
62 return 'G';
63 case 0xC8:
64 return 'H';
65 case 0xC9:
66 return 'I';
67 case 0xD1:
68 return 'J';
69 case 0xD2:
70 return 'K';
71 case 0xD3:
72 return 'L';
73 case 0xD4:
74 return 'M';
75 case 0xD5:
76 return 'N';
77 case 0xD6:
78 return 'O';
79 case 0xD7:
80 return 'P';
81 case 0xD8:
82 return 'Q';
83 case 0xD9:
84 return 'R';
85 case 0xE2:
86 return 'S';
87 case 0xE3:
88 return 'T';
89 case 0xE4:
90 return 'U';
91 case 0xE5:
92 return 'V';
93 case 0xE6:
94 return 'W';
95 case 0xE7:
96 return 'X';
97 case 0xE8:
98 return 'Y';
99 case 0xE9:
100 return 'Z';
101 }
102 return ' ';
103}
104EXPORT_SYMBOL(e2a);
105
106unsigned char* strne2a(unsigned char *dest, const unsigned char *src, size_t n)
107{
108 int i;
109
110 n = strnlen(src, n);
111
112 for (i = 0; i < n; i++)
113 dest[i] = e2a(src[i]);
114
115 return dest;
116}
diff --git a/arch/powerpc/lib/locks.c b/arch/powerpc/lib/locks.c
index 077bed7dc52b..80b482ca30df 100644
--- a/arch/powerpc/lib/locks.c
+++ b/arch/powerpc/lib/locks.c
@@ -23,6 +23,7 @@
23#include <asm/hvcall.h> 23#include <asm/hvcall.h>
24#include <asm/iseries/hv_call.h> 24#include <asm/iseries/hv_call.h>
25#include <asm/smp.h> 25#include <asm/smp.h>
26#include <asm/firmware.h>
26 27
27void __spin_yield(raw_spinlock_t *lock) 28void __spin_yield(raw_spinlock_t *lock)
28{ 29{
@@ -39,13 +40,12 @@ void __spin_yield(raw_spinlock_t *lock)
39 rmb(); 40 rmb();
40 if (lock->slock != lock_value) 41 if (lock->slock != lock_value)
41 return; /* something has changed */ 42 return; /* something has changed */
42#ifdef CONFIG_PPC_ISERIES 43 if (firmware_has_feature(FW_FEATURE_ISERIES))
43 HvCall2(HvCallBaseYieldProcessor, HvCall_YieldToProc, 44 HvCall2(HvCallBaseYieldProcessor, HvCall_YieldToProc,
44 ((u64)holder_cpu << 32) | yield_count); 45 ((u64)holder_cpu << 32) | yield_count);
45#else 46 else
46 plpar_hcall_norets(H_CONFER, get_hard_smp_processor_id(holder_cpu), 47 plpar_hcall_norets(H_CONFER,
47 yield_count); 48 get_hard_smp_processor_id(holder_cpu), yield_count);
48#endif
49} 49}
50 50
51/* 51/*
@@ -69,13 +69,12 @@ void __rw_yield(raw_rwlock_t *rw)
69 rmb(); 69 rmb();
70 if (rw->lock != lock_value) 70 if (rw->lock != lock_value)
71 return; /* something has changed */ 71 return; /* something has changed */
72#ifdef CONFIG_PPC_ISERIES 72 if (firmware_has_feature(FW_FEATURE_ISERIES))
73 HvCall2(HvCallBaseYieldProcessor, HvCall_YieldToProc, 73 HvCall2(HvCallBaseYieldProcessor, HvCall_YieldToProc,
74 ((u64)holder_cpu << 32) | yield_count); 74 ((u64)holder_cpu << 32) | yield_count);
75#else 75 else
76 plpar_hcall_norets(H_CONFER, get_hard_smp_processor_id(holder_cpu), 76 plpar_hcall_norets(H_CONFER,
77 yield_count); 77 get_hard_smp_processor_id(holder_cpu), yield_count);
78#endif
79} 78}
80#endif 79#endif
81 80
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index fbe23933f731..6c0f1c7d83e5 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -159,12 +159,12 @@ static struct device_node * __cpuinit find_cpu_node(unsigned int cpu)
159{ 159{
160 unsigned int hw_cpuid = get_hard_smp_processor_id(cpu); 160 unsigned int hw_cpuid = get_hard_smp_processor_id(cpu);
161 struct device_node *cpu_node = NULL; 161 struct device_node *cpu_node = NULL;
162 unsigned int *interrupt_server, *reg; 162 const unsigned int *interrupt_server, *reg;
163 int len; 163 int len;
164 164
165 while ((cpu_node = of_find_node_by_type(cpu_node, "cpu")) != NULL) { 165 while ((cpu_node = of_find_node_by_type(cpu_node, "cpu")) != NULL) {
166 /* Try interrupt server first */ 166 /* Try interrupt server first */
167 interrupt_server = (unsigned int *)get_property(cpu_node, 167 interrupt_server = get_property(cpu_node,
168 "ibm,ppc-interrupt-server#s", &len); 168 "ibm,ppc-interrupt-server#s", &len);
169 169
170 len = len / sizeof(u32); 170 len = len / sizeof(u32);
@@ -175,8 +175,7 @@ static struct device_node * __cpuinit find_cpu_node(unsigned int cpu)
175 return cpu_node; 175 return cpu_node;
176 } 176 }
177 } else { 177 } else {
178 reg = (unsigned int *)get_property(cpu_node, 178 reg = get_property(cpu_node, "reg", &len);
179 "reg", &len);
180 if (reg && (len > 0) && (reg[0] == hw_cpuid)) 179 if (reg && (len > 0) && (reg[0] == hw_cpuid))
181 return cpu_node; 180 return cpu_node;
182 } 181 }
@@ -186,9 +185,9 @@ static struct device_node * __cpuinit find_cpu_node(unsigned int cpu)
186} 185}
187 186
188/* must hold reference to node during call */ 187/* must hold reference to node during call */
189static int *of_get_associativity(struct device_node *dev) 188static const int *of_get_associativity(struct device_node *dev)
190{ 189{
191 return (unsigned int *)get_property(dev, "ibm,associativity", NULL); 190 return get_property(dev, "ibm,associativity", NULL);
192} 191}
193 192
194/* Returns nid in the range [0..MAX_NUMNODES-1], or -1 if no useful numa 193/* Returns nid in the range [0..MAX_NUMNODES-1], or -1 if no useful numa
@@ -197,7 +196,7 @@ static int *of_get_associativity(struct device_node *dev)
197static int of_node_to_nid_single(struct device_node *device) 196static int of_node_to_nid_single(struct device_node *device)
198{ 197{
199 int nid = -1; 198 int nid = -1;
200 unsigned int *tmp; 199 const unsigned int *tmp;
201 200
202 if (min_common_depth == -1) 201 if (min_common_depth == -1)
203 goto out; 202 goto out;
@@ -255,7 +254,7 @@ EXPORT_SYMBOL_GPL(of_node_to_nid);
255static int __init find_min_common_depth(void) 254static int __init find_min_common_depth(void)
256{ 255{
257 int depth; 256 int depth;
258 unsigned int *ref_points; 257 const unsigned int *ref_points;
259 struct device_node *rtas_root; 258 struct device_node *rtas_root;
260 unsigned int len; 259 unsigned int len;
261 260
@@ -270,7 +269,7 @@ static int __init find_min_common_depth(void)
270 * configuration (should be all 0's) and the second is for a normal 269 * configuration (should be all 0's) and the second is for a normal
271 * NUMA configuration. 270 * NUMA configuration.
272 */ 271 */
273 ref_points = (unsigned int *)get_property(rtas_root, 272 ref_points = get_property(rtas_root,
274 "ibm,associativity-reference-points", &len); 273 "ibm,associativity-reference-points", &len);
275 274
276 if ((len >= 1) && ref_points) { 275 if ((len >= 1) && ref_points) {
@@ -297,7 +296,7 @@ static void __init get_n_mem_cells(int *n_addr_cells, int *n_size_cells)
297 of_node_put(memory); 296 of_node_put(memory);
298} 297}
299 298
300static unsigned long __devinit read_n_cells(int n, unsigned int **buf) 299static unsigned long __devinit read_n_cells(int n, const unsigned int **buf)
301{ 300{
302 unsigned long result = 0; 301 unsigned long result = 0;
303 302
@@ -435,15 +434,13 @@ static int __init parse_numa_properties(void)
435 unsigned long size; 434 unsigned long size;
436 int nid; 435 int nid;
437 int ranges; 436 int ranges;
438 unsigned int *memcell_buf; 437 const unsigned int *memcell_buf;
439 unsigned int len; 438 unsigned int len;
440 439
441 memcell_buf = (unsigned int *)get_property(memory, 440 memcell_buf = get_property(memory,
442 "linux,usable-memory", &len); 441 "linux,usable-memory", &len);
443 if (!memcell_buf || len <= 0) 442 if (!memcell_buf || len <= 0)
444 memcell_buf = 443 memcell_buf = get_property(memory, "reg", &len);
445 (unsigned int *)get_property(memory, "reg",
446 &len);
447 if (!memcell_buf || len <= 0) 444 if (!memcell_buf || len <= 0)
448 continue; 445 continue;
449 446
@@ -787,10 +784,10 @@ int hot_add_scn_to_nid(unsigned long scn_addr)
787 while ((memory = of_find_node_by_type(memory, "memory")) != NULL) { 784 while ((memory = of_find_node_by_type(memory, "memory")) != NULL) {
788 unsigned long start, size; 785 unsigned long start, size;
789 int ranges; 786 int ranges;
790 unsigned int *memcell_buf; 787 const unsigned int *memcell_buf;
791 unsigned int len; 788 unsigned int len;
792 789
793 memcell_buf = (unsigned int *)get_property(memory, "reg", &len); 790 memcell_buf = get_property(memory, "reg", &len);
794 if (!memcell_buf || len <= 0) 791 if (!memcell_buf || len <= 0)
795 continue; 792 continue;
796 793
diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
index de0c8842415c..d3733912adb4 100644
--- a/arch/powerpc/mm/slb.c
+++ b/arch/powerpc/mm/slb.c
@@ -22,6 +22,8 @@
22#include <asm/paca.h> 22#include <asm/paca.h>
23#include <asm/cputable.h> 23#include <asm/cputable.h>
24#include <asm/cacheflush.h> 24#include <asm/cacheflush.h>
25#include <asm/smp.h>
26#include <linux/compiler.h>
25 27
26#ifdef DEBUG 28#ifdef DEBUG
27#define DBG(fmt...) udbg_printf(fmt) 29#define DBG(fmt...) udbg_printf(fmt)
@@ -50,9 +52,32 @@ static inline unsigned long mk_vsid_data(unsigned long ea, unsigned long flags)
50 return (get_kernel_vsid(ea) << SLB_VSID_SHIFT) | flags; 52 return (get_kernel_vsid(ea) << SLB_VSID_SHIFT) | flags;
51} 53}
52 54
53static inline void create_slbe(unsigned long ea, unsigned long flags, 55static inline void slb_shadow_update(unsigned long esid, unsigned long vsid,
54 unsigned long entry) 56 unsigned long entry)
55{ 57{
58 /*
59 * Clear the ESID first so the entry is not valid while we are
60 * updating it.
61 */
62 get_slb_shadow()->save_area[entry].esid = 0;
63 barrier();
64 get_slb_shadow()->save_area[entry].vsid = vsid;
65 barrier();
66 get_slb_shadow()->save_area[entry].esid = esid;
67
68}
69
70static inline void create_shadowed_slbe(unsigned long ea, unsigned long flags,
71 unsigned long entry)
72{
73 /*
74 * Updating the shadow buffer before writing the SLB ensures
75 * we don't get a stale entry here if we get preempted by PHYP
76 * between these two statements.
77 */
78 slb_shadow_update(mk_esid_data(ea, entry), mk_vsid_data(ea, flags),
79 entry);
80
56 asm volatile("slbmte %0,%1" : 81 asm volatile("slbmte %0,%1" :
57 : "r" (mk_vsid_data(ea, flags)), 82 : "r" (mk_vsid_data(ea, flags)),
58 "r" (mk_esid_data(ea, entry)) 83 "r" (mk_esid_data(ea, entry))
@@ -77,6 +102,10 @@ void slb_flush_and_rebolt(void)
77 if ((ksp_esid_data & ESID_MASK) == PAGE_OFFSET) 102 if ((ksp_esid_data & ESID_MASK) == PAGE_OFFSET)
78 ksp_esid_data &= ~SLB_ESID_V; 103 ksp_esid_data &= ~SLB_ESID_V;
79 104
105 /* Only third entry (stack) may change here so only resave that */
106 slb_shadow_update(ksp_esid_data,
107 mk_vsid_data(ksp_esid_data, lflags), 2);
108
80 /* We need to do this all in asm, so we're sure we don't touch 109 /* We need to do this all in asm, so we're sure we don't touch
81 * the stack between the slbia and rebolting it. */ 110 * the stack between the slbia and rebolting it. */
82 asm volatile("isync\n" 111 asm volatile("isync\n"
@@ -209,9 +238,9 @@ void slb_initialize(void)
209 asm volatile("isync":::"memory"); 238 asm volatile("isync":::"memory");
210 asm volatile("slbmte %0,%0"::"r" (0) : "memory"); 239 asm volatile("slbmte %0,%0"::"r" (0) : "memory");
211 asm volatile("isync; slbia; isync":::"memory"); 240 asm volatile("isync; slbia; isync":::"memory");
212 create_slbe(PAGE_OFFSET, lflags, 0); 241 create_shadowed_slbe(PAGE_OFFSET, lflags, 0);
213 242
214 create_slbe(VMALLOC_START, vflags, 1); 243 create_shadowed_slbe(VMALLOC_START, vflags, 1);
215 244
216 /* We don't bolt the stack for the time being - we're in boot, 245 /* We don't bolt the stack for the time being - we're in boot,
217 * so the stack is in the bolted segment. By the time it goes 246 * so the stack is in the bolted segment. By the time it goes
diff --git a/arch/powerpc/mm/tlb_64.c b/arch/powerpc/mm/tlb_64.c
index f6eef78efd29..b58baa65c4a7 100644
--- a/arch/powerpc/mm/tlb_64.c
+++ b/arch/powerpc/mm/tlb_64.c
@@ -146,6 +146,7 @@ void hpte_update(struct mm_struct *mm, unsigned long addr,
146 psize = mmu_huge_psize; 146 psize = mmu_huge_psize;
147#else 147#else
148 BUG(); 148 BUG();
149 psize = pte_pagesize_index(pte); /* shutup gcc */
149#endif 150#endif
150 } else 151 } else
151 psize = pte_pagesize_index(pte); 152 psize = pte_pagesize_index(pte);
diff --git a/arch/powerpc/platforms/83xx/mpc834x_itx.c b/arch/powerpc/platforms/83xx/mpc834x_itx.c
index cf3967a66fb5..969fbb6d8c46 100644
--- a/arch/powerpc/platforms/83xx/mpc834x_itx.c
+++ b/arch/powerpc/platforms/83xx/mpc834x_itx.c
@@ -60,8 +60,8 @@ static void __init mpc834x_itx_setup_arch(void)
60 60
61 np = of_find_node_by_type(NULL, "cpu"); 61 np = of_find_node_by_type(NULL, "cpu");
62 if (np != 0) { 62 if (np != 0) {
63 unsigned int *fp = 63 const unsigned int *fp =
64 (int *)get_property(np, "clock-frequency", NULL); 64 get_property(np, "clock-frequency", NULL);
65 if (fp != 0) 65 if (fp != 0)
66 loops_per_jiffy = *fp / HZ; 66 loops_per_jiffy = *fp / HZ;
67 else 67 else
diff --git a/arch/powerpc/platforms/83xx/mpc834x_sys.c b/arch/powerpc/platforms/83xx/mpc834x_sys.c
index 32df239d1c48..677196187a4e 100644
--- a/arch/powerpc/platforms/83xx/mpc834x_sys.c
+++ b/arch/powerpc/platforms/83xx/mpc834x_sys.c
@@ -57,8 +57,8 @@ static void __init mpc834x_sys_setup_arch(void)
57 57
58 np = of_find_node_by_type(NULL, "cpu"); 58 np = of_find_node_by_type(NULL, "cpu");
59 if (np != 0) { 59 if (np != 0) {
60 unsigned int *fp = 60 const unsigned int *fp =
61 (int *)get_property(np, "clock-frequency", NULL); 61 get_property(np, "clock-frequency", NULL);
62 if (fp != 0) 62 if (fp != 0)
63 loops_per_jiffy = *fp / HZ; 63 loops_per_jiffy = *fp / HZ;
64 else 64 else
diff --git a/arch/powerpc/platforms/83xx/pci.c b/arch/powerpc/platforms/83xx/pci.c
index 5d84a9ccd103..4557ac5255c1 100644
--- a/arch/powerpc/platforms/83xx/pci.c
+++ b/arch/powerpc/platforms/83xx/pci.c
@@ -59,7 +59,7 @@ int __init add_bridge(struct device_node *dev)
59 int len; 59 int len;
60 struct pci_controller *hose; 60 struct pci_controller *hose;
61 struct resource rsrc; 61 struct resource rsrc;
62 int *bus_range; 62 const int *bus_range;
63 int primary = 1, has_address = 0; 63 int primary = 1, has_address = 0;
64 phys_addr_t immr = get_immrbase(); 64 phys_addr_t immr = get_immrbase();
65 65
@@ -69,7 +69,7 @@ int __init add_bridge(struct device_node *dev)
69 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0); 69 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
70 70
71 /* Get bus range if any */ 71 /* Get bus range if any */
72 bus_range = (int *)get_property(dev, "bus-range", &len); 72 bus_range = get_property(dev, "bus-range", &len);
73 if (bus_range == NULL || len < 2 * sizeof(int)) { 73 if (bus_range == NULL || len < 2 * sizeof(int)) {
74 printk(KERN_WARNING "Can't get bus-range for %s, assume" 74 printk(KERN_WARNING "Can't get bus-range for %s, assume"
75 " bus 0\n", dev->full_name); 75 " bus 0\n", dev->full_name);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index 9d2acfbbeccd..cae6b73357d5 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -121,9 +121,9 @@ static void __init mpc85xx_ads_setup_arch(void)
121 121
122 cpu = of_find_node_by_type(NULL, "cpu"); 122 cpu = of_find_node_by_type(NULL, "cpu");
123 if (cpu != 0) { 123 if (cpu != 0) {
124 unsigned int *fp; 124 const unsigned int *fp;
125 125
126 fp = (int *)get_property(cpu, "clock-frequency", NULL); 126 fp = get_property(cpu, "clock-frequency", NULL);
127 if (fp != 0) 127 if (fp != 0)
128 loops_per_jiffy = *fp / HZ; 128 loops_per_jiffy = *fp / HZ;
129 else 129 else
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index 1d357d32a29f..4c1fede6470e 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -241,9 +241,9 @@ mpc85xx_cds_setup_arch(void)
241 241
242 cpu = of_find_node_by_type(NULL, "cpu"); 242 cpu = of_find_node_by_type(NULL, "cpu");
243 if (cpu != 0) { 243 if (cpu != 0) {
244 unsigned int *fp; 244 const unsigned int *fp;
245 245
246 fp = (int *)get_property(cpu, "clock-frequency", NULL); 246 fp = get_property(cpu, "clock-frequency", NULL);
247 if (fp != 0) 247 if (fp != 0)
248 loops_per_jiffy = *fp / HZ; 248 loops_per_jiffy = *fp / HZ;
249 else 249 else
diff --git a/arch/powerpc/platforms/85xx/pci.c b/arch/powerpc/platforms/85xx/pci.c
index 1d51f3242ab1..05930eeb6e7f 100644
--- a/arch/powerpc/platforms/85xx/pci.c
+++ b/arch/powerpc/platforms/85xx/pci.c
@@ -41,7 +41,7 @@ int __init add_bridge(struct device_node *dev)
41 int len; 41 int len;
42 struct pci_controller *hose; 42 struct pci_controller *hose;
43 struct resource rsrc; 43 struct resource rsrc;
44 int *bus_range; 44 const int *bus_range;
45 int primary = 1, has_address = 0; 45 int primary = 1, has_address = 0;
46 phys_addr_t immr = get_immrbase(); 46 phys_addr_t immr = get_immrbase();
47 47
@@ -51,7 +51,7 @@ int __init add_bridge(struct device_node *dev)
51 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0); 51 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
52 52
53 /* Get bus range if any */ 53 /* Get bus range if any */
54 bus_range = (int *) get_property(dev, "bus-range", &len); 54 bus_range = get_property(dev, "bus-range", &len);
55 if (bus_range == NULL || len < 2 * sizeof(int)) { 55 if (bus_range == NULL || len < 2 * sizeof(int)) {
56 printk(KERN_WARNING "Can't get bus-range for %s, assume" 56 printk(KERN_WARNING "Can't get bus-range for %s, assume"
57 " bus 0\n", dev->full_name); 57 " bus 0\n", dev->full_name);
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index 5e583cf38786..b637e8157f7b 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -347,9 +347,9 @@ mpc86xx_hpcn_setup_arch(void)
347 347
348 np = of_find_node_by_type(NULL, "cpu"); 348 np = of_find_node_by_type(NULL, "cpu");
349 if (np != 0) { 349 if (np != 0) {
350 unsigned int *fp; 350 const unsigned int *fp;
351 351
352 fp = (int *)get_property(np, "clock-frequency", NULL); 352 fp = get_property(np, "clock-frequency", NULL);
353 if (fp != 0) 353 if (fp != 0)
354 loops_per_jiffy = *fp / HZ; 354 loops_per_jiffy = *fp / HZ;
355 else 355 else
diff --git a/arch/powerpc/platforms/86xx/pci.c b/arch/powerpc/platforms/86xx/pci.c
index a8c8f0a44055..481e18ed5be9 100644
--- a/arch/powerpc/platforms/86xx/pci.c
+++ b/arch/powerpc/platforms/86xx/pci.c
@@ -153,7 +153,7 @@ int __init add_bridge(struct device_node *dev)
153 int len; 153 int len;
154 struct pci_controller *hose; 154 struct pci_controller *hose;
155 struct resource rsrc; 155 struct resource rsrc;
156 int *bus_range; 156 const int *bus_range;
157 int has_address = 0; 157 int has_address = 0;
158 int primary = 0; 158 int primary = 0;
159 159
@@ -163,7 +163,7 @@ int __init add_bridge(struct device_node *dev)
163 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0); 163 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
164 164
165 /* Get bus range if any */ 165 /* Get bus range if any */
166 bus_range = (int *) get_property(dev, "bus-range", &len); 166 bus_range = get_property(dev, "bus-range", &len);
167 if (bus_range == NULL || len < 2 * sizeof(int)) 167 if (bus_range == NULL || len < 2 * sizeof(int))
168 printk(KERN_WARNING "Can't get bus-range for %s, assume" 168 printk(KERN_WARNING "Can't get bus-range for %s, assume"
169 " bus 0\n", dev->full_name); 169 " bus 0\n", dev->full_name);
diff --git a/arch/powerpc/platforms/Makefile b/arch/powerpc/platforms/Makefile
index 5cf46dc57895..e58fa953a50b 100644
--- a/arch/powerpc/platforms/Makefile
+++ b/arch/powerpc/platforms/Makefile
@@ -13,5 +13,6 @@ obj-$(CONFIG_PPC_86xx) += 86xx/
13obj-$(CONFIG_PPC_PSERIES) += pseries/ 13obj-$(CONFIG_PPC_PSERIES) += pseries/
14obj-$(CONFIG_PPC_ISERIES) += iseries/ 14obj-$(CONFIG_PPC_ISERIES) += iseries/
15obj-$(CONFIG_PPC_MAPLE) += maple/ 15obj-$(CONFIG_PPC_MAPLE) += maple/
16obj-$(CONFIG_PPC_PASEMI) += pasemi/
16obj-$(CONFIG_PPC_CELL) += cell/ 17obj-$(CONFIG_PPC_CELL) += cell/
17obj-$(CONFIG_EMBEDDED6xx) += embedded6xx/ 18obj-$(CONFIG_EMBEDDED6xx) += embedded6xx/
diff --git a/arch/powerpc/platforms/cell/cbe_regs.c b/arch/powerpc/platforms/cell/cbe_regs.c
index ce696c1cca75..3f3859d12e00 100644
--- a/arch/powerpc/platforms/cell/cbe_regs.c
+++ b/arch/powerpc/platforms/cell/cbe_regs.c
@@ -97,7 +97,7 @@ void __init cbe_regs_init(void)
97 struct cbe_regs_map *map = &cbe_regs_maps[cbe_regs_map_count++]; 97 struct cbe_regs_map *map = &cbe_regs_maps[cbe_regs_map_count++];
98 98
99 /* That hack must die die die ! */ 99 /* That hack must die die die ! */
100 struct address_prop { 100 const struct address_prop {
101 unsigned long address; 101 unsigned long address;
102 unsigned int len; 102 unsigned int len;
103 } __attribute__((packed)) *prop; 103 } __attribute__((packed)) *prop;
@@ -114,13 +114,11 @@ void __init cbe_regs_init(void)
114 if (cbe_thread_map[i].cpu_node == cpu) 114 if (cbe_thread_map[i].cpu_node == cpu)
115 cbe_thread_map[i].regs = map; 115 cbe_thread_map[i].regs = map;
116 116
117 prop = (struct address_prop *)get_property(cpu, "pervasive", 117 prop = get_property(cpu, "pervasive", NULL);
118 NULL);
119 if (prop != NULL) 118 if (prop != NULL)
120 map->pmd_regs = ioremap(prop->address, prop->len); 119 map->pmd_regs = ioremap(prop->address, prop->len);
121 120
122 prop = (struct address_prop *)get_property(cpu, "iic", 121 prop = get_property(cpu, "iic", NULL);
123 NULL);
124 if (prop != NULL) 122 if (prop != NULL)
125 map->iic_regs = ioremap(prop->address, prop->len); 123 map->iic_regs = ioremap(prop->address, prop->len);
126 } 124 }
diff --git a/arch/powerpc/platforms/cell/interrupt.c b/arch/powerpc/platforms/cell/interrupt.c
index d7bbb61109f9..6b57a47c5d37 100644
--- a/arch/powerpc/platforms/cell/interrupt.c
+++ b/arch/powerpc/platforms/cell/interrupt.c
@@ -89,17 +89,17 @@ static struct irq_chip iic_chip = {
89/* Get an IRQ number from the pending state register of the IIC */ 89/* Get an IRQ number from the pending state register of the IIC */
90static unsigned int iic_get_irq(struct pt_regs *regs) 90static unsigned int iic_get_irq(struct pt_regs *regs)
91{ 91{
92 struct cbe_iic_pending_bits pending; 92 struct cbe_iic_pending_bits pending;
93 struct iic *iic; 93 struct iic *iic;
94 94
95 iic = &__get_cpu_var(iic); 95 iic = &__get_cpu_var(iic);
96 *(unsigned long *) &pending = 96 *(unsigned long *) &pending =
97 in_be64((unsigned long __iomem *) &iic->regs->pending_destr); 97 in_be64((unsigned long __iomem *) &iic->regs->pending_destr);
98 iic->eoi_stack[++iic->eoi_ptr] = pending.prio; 98 iic->eoi_stack[++iic->eoi_ptr] = pending.prio;
99 BUG_ON(iic->eoi_ptr > 15); 99 BUG_ON(iic->eoi_ptr > 15);
100 if (pending.flags & CBE_IIC_IRQ_VALID) 100 if (pending.flags & CBE_IIC_IRQ_VALID)
101 return irq_linear_revmap(iic->host, 101 return irq_linear_revmap(iic->host,
102 iic_pending_to_hwnum(pending)); 102 iic_pending_to_hwnum(pending));
103 return NO_IRQ; 103 return NO_IRQ;
104} 104}
105 105
@@ -250,16 +250,15 @@ static int __init setup_iic(void)
250 struct resource r0, r1; 250 struct resource r0, r1;
251 struct irq_host *host; 251 struct irq_host *host;
252 int found = 0; 252 int found = 0;
253 u32 *np; 253 const u32 *np;
254 254
255 for (dn = NULL; 255 for (dn = NULL;
256 (dn = of_find_node_by_name(dn,"interrupt-controller")) != NULL;) { 256 (dn = of_find_node_by_name(dn,"interrupt-controller")) != NULL;) {
257 if (!device_is_compatible(dn, 257 if (!device_is_compatible(dn,
258 "IBM,CBEA-Internal-Interrupt-Controller")) 258 "IBM,CBEA-Internal-Interrupt-Controller"))
259 continue; 259 continue;
260 np = (u32 *)get_property(dn, "ibm,interrupt-server-ranges", 260 np = get_property(dn, "ibm,interrupt-server-ranges", NULL);
261 NULL); 261 if (np == NULL) {
262 if (np == NULL) {
263 printk(KERN_WARNING "IIC: CPU association not found\n"); 262 printk(KERN_WARNING "IIC: CPU association not found\n");
264 of_node_put(dn); 263 of_node_put(dn);
265 return -ENODEV; 264 return -ENODEV;
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index a35004e14c69..d2b20eba5b87 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -308,15 +308,16 @@ static void cell_do_map_iommu(struct cell_iommu *iommu,
308 308
309static void iommu_devnode_setup(struct device_node *d) 309static void iommu_devnode_setup(struct device_node *d)
310{ 310{
311 unsigned int *ioid; 311 const unsigned int *ioid;
312 unsigned long *dma_window, map_start, map_size, token; 312 unsigned long map_start, map_size, token;
313 const unsigned long *dma_window;
313 struct cell_iommu *iommu; 314 struct cell_iommu *iommu;
314 315
315 ioid = (unsigned int *)get_property(d, "ioid", NULL); 316 ioid = get_property(d, "ioid", NULL);
316 if (!ioid) 317 if (!ioid)
317 pr_debug("No ioid entry found !\n"); 318 pr_debug("No ioid entry found !\n");
318 319
319 dma_window = (unsigned long *)get_property(d, "ibm,dma-window", NULL); 320 dma_window = get_property(d, "ibm,dma-window", NULL);
320 if (!dma_window) 321 if (!dma_window)
321 pr_debug("No ibm,dma-window entry found !\n"); 322 pr_debug("No ibm,dma-window entry found !\n");
322 323
@@ -371,8 +372,9 @@ static int cell_map_iommu_hardcoded(int num_nodes)
371 372
372static int cell_map_iommu(void) 373static int cell_map_iommu(void)
373{ 374{
374 unsigned int num_nodes = 0, *node_id; 375 unsigned int num_nodes = 0;
375 unsigned long *base, *mmio_base; 376 const unsigned int *node_id;
377 const unsigned long *base, *mmio_base;
376 struct device_node *dn; 378 struct device_node *dn;
377 struct cell_iommu *iommu = NULL; 379 struct cell_iommu *iommu = NULL;
378 380
@@ -381,7 +383,7 @@ static int cell_map_iommu(void)
381 for(dn = of_find_node_by_type(NULL, "cpu"); 383 for(dn = of_find_node_by_type(NULL, "cpu");
382 dn; 384 dn;
383 dn = of_find_node_by_type(dn, "cpu")) { 385 dn = of_find_node_by_type(dn, "cpu")) {
384 node_id = (unsigned int *)get_property(dn, "node-id", NULL); 386 node_id = get_property(dn, "node-id", NULL);
385 387
386 if (num_nodes < *node_id) 388 if (num_nodes < *node_id)
387 num_nodes = *node_id; 389 num_nodes = *node_id;
@@ -396,9 +398,9 @@ static int cell_map_iommu(void)
396 dn; 398 dn;
397 dn = of_find_node_by_type(dn, "cpu")) { 399 dn = of_find_node_by_type(dn, "cpu")) {
398 400
399 node_id = (unsigned int *)get_property(dn, "node-id", NULL); 401 node_id = get_property(dn, "node-id", NULL);
400 base = (unsigned long *)get_property(dn, "ioc-cache", NULL); 402 base = get_property(dn, "ioc-cache", NULL);
401 mmio_base = (unsigned long *)get_property(dn, "ioc-translation", NULL); 403 mmio_base = get_property(dn, "ioc-translation", NULL);
402 404
403 if (!base || !mmio_base || !node_id) 405 if (!base || !mmio_base || !node_id)
404 return cell_map_iommu_hardcoded(num_nodes); 406 return cell_map_iommu_hardcoded(num_nodes);
diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c
index 282987d6d4a2..22c228a49c33 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -150,10 +150,6 @@ static int __init cell_probe(void)
150 !of_flat_dt_is_compatible(root, "IBM,CPBW-1.0")) 150 !of_flat_dt_is_compatible(root, "IBM,CPBW-1.0"))
151 return 0; 151 return 0;
152 152
153#ifdef CONFIG_UDBG_RTAS_CONSOLE
154 udbg_init_rtas_console();
155#endif
156
157 hpte_init_native(); 153 hpte_init_native();
158 154
159 return 1; 155 return 1;
diff --git a/arch/powerpc/platforms/cell/smp.c b/arch/powerpc/platforms/cell/smp.c
index 46aef0640742..1c0acbad7425 100644
--- a/arch/powerpc/platforms/cell/smp.c
+++ b/arch/powerpc/platforms/cell/smp.c
@@ -57,7 +57,7 @@
57 */ 57 */
58static cpumask_t of_spin_map; 58static cpumask_t of_spin_map;
59 59
60extern void pSeries_secondary_smp_init(unsigned long); 60extern void generic_secondary_smp_init(unsigned long);
61 61
62/** 62/**
63 * smp_startup_cpu() - start the given cpu 63 * smp_startup_cpu() - start the given cpu
@@ -74,7 +74,7 @@ static inline int __devinit smp_startup_cpu(unsigned int lcpu)
74{ 74{
75 int status; 75 int status;
76 unsigned long start_here = __pa((u32)*((unsigned long *) 76 unsigned long start_here = __pa((u32)*((unsigned long *)
77 pSeries_secondary_smp_init)); 77 generic_secondary_smp_init));
78 unsigned int pcpu; 78 unsigned int pcpu;
79 int start_cpu; 79 int start_cpu;
80 80
diff --git a/arch/powerpc/platforms/cell/spider-pic.c b/arch/powerpc/platforms/cell/spider-pic.c
index 15217bb0402f..742a03282b44 100644
--- a/arch/powerpc/platforms/cell/spider-pic.c
+++ b/arch/powerpc/platforms/cell/spider-pic.c
@@ -240,7 +240,7 @@ static void spider_irq_cascade(unsigned int irq, struct irq_desc *desc,
240static unsigned int __init spider_find_cascade_and_node(struct spider_pic *pic) 240static unsigned int __init spider_find_cascade_and_node(struct spider_pic *pic)
241{ 241{
242 unsigned int virq; 242 unsigned int virq;
243 u32 *imap, *tmp; 243 const u32 *imap, *tmp;
244 int imaplen, intsize, unit; 244 int imaplen, intsize, unit;
245 struct device_node *iic; 245 struct device_node *iic;
246 struct irq_host *iic_host; 246 struct irq_host *iic_host;
@@ -258,25 +258,25 @@ static unsigned int __init spider_find_cascade_and_node(struct spider_pic *pic)
258#endif 258#endif
259 259
260 /* Now do the horrible hacks */ 260 /* Now do the horrible hacks */
261 tmp = (u32 *)get_property(pic->of_node, "#interrupt-cells", NULL); 261 tmp = get_property(pic->of_node, "#interrupt-cells", NULL);
262 if (tmp == NULL) 262 if (tmp == NULL)
263 return NO_IRQ; 263 return NO_IRQ;
264 intsize = *tmp; 264 intsize = *tmp;
265 imap = (u32 *)get_property(pic->of_node, "interrupt-map", &imaplen); 265 imap = get_property(pic->of_node, "interrupt-map", &imaplen);
266 if (imap == NULL || imaplen < (intsize + 1)) 266 if (imap == NULL || imaplen < (intsize + 1))
267 return NO_IRQ; 267 return NO_IRQ;
268 iic = of_find_node_by_phandle(imap[intsize]); 268 iic = of_find_node_by_phandle(imap[intsize]);
269 if (iic == NULL) 269 if (iic == NULL)
270 return NO_IRQ; 270 return NO_IRQ;
271 imap += intsize + 1; 271 imap += intsize + 1;
272 tmp = (u32 *)get_property(iic, "#interrupt-cells", NULL); 272 tmp = get_property(iic, "#interrupt-cells", NULL);
273 if (tmp == NULL) 273 if (tmp == NULL)
274 return NO_IRQ; 274 return NO_IRQ;
275 intsize = *tmp; 275 intsize = *tmp;
276 /* Assume unit is last entry of interrupt specifier */ 276 /* Assume unit is last entry of interrupt specifier */
277 unit = imap[intsize - 1]; 277 unit = imap[intsize - 1];
278 /* Ok, we have a unit, now let's try to get the node */ 278 /* Ok, we have a unit, now let's try to get the node */
279 tmp = (u32 *)get_property(iic, "ibm,interrupt-server-ranges", NULL); 279 tmp = get_property(iic, "ibm,interrupt-server-ranges", NULL);
280 if (tmp == NULL) { 280 if (tmp == NULL) {
281 of_node_put(iic); 281 of_node_put(iic);
282 return NO_IRQ; 282 return NO_IRQ;
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index d06042deb021..3bd36d46ab4a 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -488,10 +488,10 @@ int spu_irq_class_1_bottom(struct spu *spu)
488 488
489static int __init find_spu_node_id(struct device_node *spe) 489static int __init find_spu_node_id(struct device_node *spe)
490{ 490{
491 unsigned int *id; 491 const unsigned int *id;
492 struct device_node *cpu; 492 struct device_node *cpu;
493 cpu = spe->parent->parent; 493 cpu = spe->parent->parent;
494 id = (unsigned int *)get_property(cpu, "node-id", NULL); 494 id = get_property(cpu, "node-id", NULL);
495 return id ? *id : 0; 495 return id ? *id : 0;
496} 496}
497 497
@@ -500,7 +500,7 @@ static int __init cell_spuprop_present(struct spu *spu, struct device_node *spe,
500{ 500{
501 static DEFINE_MUTEX(add_spumem_mutex); 501 static DEFINE_MUTEX(add_spumem_mutex);
502 502
503 struct address_prop { 503 const struct address_prop {
504 unsigned long address; 504 unsigned long address;
505 unsigned int len; 505 unsigned int len;
506 } __attribute__((packed)) *p; 506 } __attribute__((packed)) *p;
@@ -511,7 +511,7 @@ static int __init cell_spuprop_present(struct spu *spu, struct device_node *spe,
511 struct zone *zone; 511 struct zone *zone;
512 int ret; 512 int ret;
513 513
514 p = (void*)get_property(spe, prop, &proplen); 514 p = get_property(spe, prop, &proplen);
515 WARN_ON(proplen != sizeof (*p)); 515 WARN_ON(proplen != sizeof (*p));
516 516
517 start_pfn = p->address >> PAGE_SHIFT; 517 start_pfn = p->address >> PAGE_SHIFT;
@@ -531,12 +531,12 @@ static int __init cell_spuprop_present(struct spu *spu, struct device_node *spe,
531static void __iomem * __init map_spe_prop(struct spu *spu, 531static void __iomem * __init map_spe_prop(struct spu *spu,
532 struct device_node *n, const char *name) 532 struct device_node *n, const char *name)
533{ 533{
534 struct address_prop { 534 const struct address_prop {
535 unsigned long address; 535 unsigned long address;
536 unsigned int len; 536 unsigned int len;
537 } __attribute__((packed)) *prop; 537 } __attribute__((packed)) *prop;
538 538
539 void *p; 539 const void *p;
540 int proplen; 540 int proplen;
541 void* ret = NULL; 541 void* ret = NULL;
542 int err = 0; 542 int err = 0;
@@ -570,14 +570,14 @@ static int __init spu_map_interrupts(struct spu *spu, struct device_node *np)
570{ 570{
571 struct irq_host *host; 571 struct irq_host *host;
572 unsigned int isrc; 572 unsigned int isrc;
573 u32 *tmp; 573 const u32 *tmp;
574 574
575 host = iic_get_irq_host(spu->node); 575 host = iic_get_irq_host(spu->node);
576 if (host == NULL) 576 if (host == NULL)
577 return -ENODEV; 577 return -ENODEV;
578 578
579 /* Get the interrupt source from the device-tree */ 579 /* Get the interrupt source from the device-tree */
580 tmp = (u32 *)get_property(np, "isrc", NULL); 580 tmp = get_property(np, "isrc", NULL);
581 if (!tmp) 581 if (!tmp)
582 return -ENODEV; 582 return -ENODEV;
583 spu->isrc = isrc = tmp[0]; 583 spu->isrc = isrc = tmp[0];
@@ -593,7 +593,7 @@ static int __init spu_map_interrupts(struct spu *spu, struct device_node *np)
593 593
594static int __init spu_map_device(struct spu *spu, struct device_node *node) 594static int __init spu_map_device(struct spu *spu, struct device_node *node)
595{ 595{
596 char *prop; 596 const char *prop;
597 int ret; 597 int ret;
598 598
599 ret = -ENODEV; 599 ret = -ENODEV;
diff --git a/arch/powerpc/platforms/chrp/nvram.c b/arch/powerpc/platforms/chrp/nvram.c
index 150f67d6f90c..0dd4a64757d9 100644
--- a/arch/powerpc/platforms/chrp/nvram.c
+++ b/arch/powerpc/platforms/chrp/nvram.c
@@ -67,13 +67,14 @@ static void chrp_nvram_write(int addr, unsigned char val)
67void __init chrp_nvram_init(void) 67void __init chrp_nvram_init(void)
68{ 68{
69 struct device_node *nvram; 69 struct device_node *nvram;
70 unsigned int *nbytes_p, proplen; 70 const unsigned int *nbytes_p;
71 unsigned int proplen;
71 72
72 nvram = of_find_node_by_type(NULL, "nvram"); 73 nvram = of_find_node_by_type(NULL, "nvram");
73 if (nvram == NULL) 74 if (nvram == NULL)
74 return; 75 return;
75 76
76 nbytes_p = (unsigned int *)get_property(nvram, "#bytes", &proplen); 77 nbytes_p = get_property(nvram, "#bytes", &proplen);
77 if (nbytes_p == NULL || proplen != sizeof(unsigned int)) 78 if (nbytes_p == NULL || proplen != sizeof(unsigned int))
78 return; 79 return;
79 80
diff --git a/arch/powerpc/platforms/chrp/pci.c b/arch/powerpc/platforms/chrp/pci.c
index 6802cdc3168a..0f4340506c75 100644
--- a/arch/powerpc/platforms/chrp/pci.c
+++ b/arch/powerpc/platforms/chrp/pci.c
@@ -214,11 +214,11 @@ void __init
214chrp_find_bridges(void) 214chrp_find_bridges(void)
215{ 215{
216 struct device_node *dev; 216 struct device_node *dev;
217 int *bus_range; 217 const int *bus_range;
218 int len, index = -1; 218 int len, index = -1;
219 struct pci_controller *hose; 219 struct pci_controller *hose;
220 unsigned int *dma; 220 const unsigned int *dma;
221 char *model, *machine; 221 const char *model, *machine;
222 int is_longtrail = 0, is_mot = 0, is_pegasos = 0; 222 int is_longtrail = 0, is_mot = 0, is_pegasos = 0;
223 struct device_node *root = find_path_device("/"); 223 struct device_node *root = find_path_device("/");
224 struct resource r; 224 struct resource r;
@@ -246,7 +246,7 @@ chrp_find_bridges(void)
246 dev->full_name); 246 dev->full_name);
247 continue; 247 continue;
248 } 248 }
249 bus_range = (int *) get_property(dev, "bus-range", &len); 249 bus_range = get_property(dev, "bus-range", &len);
250 if (bus_range == NULL || len < 2 * sizeof(int)) { 250 if (bus_range == NULL || len < 2 * sizeof(int)) {
251 printk(KERN_WARNING "Can't get bus-range for %s\n", 251 printk(KERN_WARNING "Can't get bus-range for %s\n",
252 dev->full_name); 252 dev->full_name);
@@ -257,7 +257,7 @@ chrp_find_bridges(void)
257 else 257 else
258 printk(KERN_INFO "PCI buses %d..%d", 258 printk(KERN_INFO "PCI buses %d..%d",
259 bus_range[0], bus_range[1]); 259 bus_range[0], bus_range[1]);
260 printk(" controlled by %s", dev->type); 260 printk(" controlled by %s", dev->full_name);
261 if (!is_longtrail) 261 if (!is_longtrail)
262 printk(" at %llx", (unsigned long long)r.start); 262 printk(" at %llx", (unsigned long long)r.start);
263 printk("\n"); 263 printk("\n");
@@ -289,6 +289,19 @@ chrp_find_bridges(void)
289 setup_indirect_pci(hose, 0xfec00cf8, 0xfee00cfc); 289 setup_indirect_pci(hose, 0xfec00cf8, 0xfee00cfc);
290 } else if (is_pegasos == 2) { 290 } else if (is_pegasos == 2) {
291 setup_peg2(hose, dev); 291 setup_peg2(hose, dev);
292 } else if (!strncmp(model, "IBM,CPC710", 10)) {
293 setup_indirect_pci(hose,
294 r.start + 0x000f8000,
295 r.start + 0x000f8010);
296 if (index == 0) {
297 dma = get_property(dev, "system-dma-base",&len);
298 if (dma && len >= sizeof(*dma)) {
299 dma = (unsigned int *)
300 (((unsigned long)dma) +
301 len - sizeof(*dma));
302 pci_dram_offset = *dma;
303 }
304 }
292 } else { 305 } else {
293 printk("No methods for %s (model %s), using RTAS\n", 306 printk("No methods for %s (model %s), using RTAS\n",
294 dev->full_name, model); 307 dev->full_name, model);
@@ -299,15 +312,35 @@ chrp_find_bridges(void)
299 312
300 /* check the first bridge for a property that we can 313 /* check the first bridge for a property that we can
301 use to set pci_dram_offset */ 314 use to set pci_dram_offset */
302 dma = (unsigned int *) 315 dma = get_property(dev, "ibm,dma-ranges", &len);
303 get_property(dev, "ibm,dma-ranges", &len);
304 if (index == 0 && dma != NULL && len >= 6 * sizeof(*dma)) { 316 if (index == 0 && dma != NULL && len >= 6 * sizeof(*dma)) {
305 pci_dram_offset = dma[2] - dma[3]; 317 pci_dram_offset = dma[2] - dma[3];
306 printk("pci_dram_offset = %lx\n", pci_dram_offset); 318 printk("pci_dram_offset = %lx\n", pci_dram_offset);
307 } 319 }
308 } 320 }
321}
322
323/* SL82C105 IDE Control/Status Register */
324#define SL82C105_IDECSR 0x40
325
326/* Fixup for Winbond ATA quirk, required for briq */
327void chrp_pci_fixup_winbond_ata(struct pci_dev *sl82c105)
328{
329 u8 progif;
309 330
310 /* Do not fixup interrupts from OF tree on pegasos */ 331 /* If non-briq machines need that fixup too, please speak up */
311 if (is_pegasos) 332 if (!machine_is(chrp) || _chrp_type != _CHRP_briq)
312 ppc_md.pcibios_fixup = NULL; 333 return;
334
335 if ((sl82c105->class & 5) != 5) {
336 printk("W83C553: Switching SL82C105 IDE to PCI native mode\n");
337 /* Enable SL82C105 PCI native IDE mode */
338 pci_read_config_byte(sl82c105, PCI_CLASS_PROG, &progif);
339 pci_write_config_byte(sl82c105, PCI_CLASS_PROG, progif | 0x05);
340 sl82c105->class |= 0x05;
341 /* Disable SL82C105 second port */
342 pci_write_config_word(sl82c105, SL82C105_IDECSR, 0x0003);
343 }
313} 344}
345DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_WINBOND, PCI_DEVICE_ID_WINBOND_82C105,
346 chrp_pci_fixup_winbond_ata);
diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c
index 9c08ff322290..488dbd9b51ae 100644
--- a/arch/powerpc/platforms/chrp/setup.c
+++ b/arch/powerpc/platforms/chrp/setup.c
@@ -74,6 +74,9 @@ extern irqreturn_t xmon_irq(int, void *, struct pt_regs *);
74 74
75extern unsigned long loops_per_jiffy; 75extern unsigned long loops_per_jiffy;
76 76
77/* To be replaced by RTAS when available */
78static unsigned int *briq_SPOR;
79
77#ifdef CONFIG_SMP 80#ifdef CONFIG_SMP
78extern struct smp_ops_t chrp_smp_ops; 81extern struct smp_ops_t chrp_smp_ops;
79#endif 82#endif
@@ -92,6 +95,15 @@ static const char *gg2_cachemodes[4] = {
92 "Disabled", "Write-Through", "Copy-Back", "Transparent Mode" 95 "Disabled", "Write-Through", "Copy-Back", "Transparent Mode"
93}; 96};
94 97
98static const char *chrp_names[] = {
99 "Unknown",
100 "","","",
101 "Motorola",
102 "IBM or Longtrail",
103 "Genesi Pegasos",
104 "Total Impact Briq"
105};
106
95void chrp_show_cpuinfo(struct seq_file *m) 107void chrp_show_cpuinfo(struct seq_file *m)
96{ 108{
97 int i, sdramen; 109 int i, sdramen;
@@ -214,8 +226,7 @@ static void __init pegasos_set_l2cr(void)
214 /* Enable L2 cache if needed */ 226 /* Enable L2 cache if needed */
215 np = find_type_devices("cpu"); 227 np = find_type_devices("cpu");
216 if (np != NULL) { 228 if (np != NULL) {
217 unsigned int *l2cr = (unsigned int *) 229 const unsigned int *l2cr = get_property(np, "l2cr", NULL);
218 get_property (np, "l2cr", NULL);
219 if (l2cr == NULL) { 230 if (l2cr == NULL) {
220 printk ("Pegasos l2cr : no cpu l2cr property found\n"); 231 printk ("Pegasos l2cr : no cpu l2cr property found\n");
221 return; 232 return;
@@ -229,10 +240,18 @@ static void __init pegasos_set_l2cr(void)
229 } 240 }
230} 241}
231 242
243static void briq_restart(char *cmd)
244{
245 local_irq_disable();
246 if (briq_SPOR)
247 out_be32(briq_SPOR, 0);
248 for(;;);
249}
250
232void __init chrp_setup_arch(void) 251void __init chrp_setup_arch(void)
233{ 252{
234 struct device_node *root = find_path_device ("/"); 253 struct device_node *root = find_path_device ("/");
235 char *machine = NULL; 254 const char *machine = NULL;
236 255
237 /* init to some ~sane value until calibrate_delay() runs */ 256 /* init to some ~sane value until calibrate_delay() runs */
238 loops_per_jiffy = 50000000/HZ; 257 loops_per_jiffy = 50000000/HZ;
@@ -245,11 +264,16 @@ void __init chrp_setup_arch(void)
245 _chrp_type = _CHRP_IBM; 264 _chrp_type = _CHRP_IBM;
246 } else if (machine && strncmp(machine, "MOT", 3) == 0) { 265 } else if (machine && strncmp(machine, "MOT", 3) == 0) {
247 _chrp_type = _CHRP_Motorola; 266 _chrp_type = _CHRP_Motorola;
267 } else if (machine && strncmp(machine, "TotalImpact,BRIQ-1", 18) == 0) {
268 _chrp_type = _CHRP_briq;
269 /* Map the SPOR register on briq and change the restart hook */
270 briq_SPOR = (unsigned int *)ioremap(0xff0000e8, 4);
271 ppc_md.restart = briq_restart;
248 } else { 272 } else {
249 /* Let's assume it is an IBM chrp if all else fails */ 273 /* Let's assume it is an IBM chrp if all else fails */
250 _chrp_type = _CHRP_IBM; 274 _chrp_type = _CHRP_IBM;
251 } 275 }
252 printk("chrp type = %x\n", _chrp_type); 276 printk("chrp type = %x [%s]\n", _chrp_type, chrp_names[_chrp_type]);
253 277
254 rtas_initialize(); 278 rtas_initialize();
255 if (rtas_token("display-character") >= 0) 279 if (rtas_token("display-character") >= 0)
@@ -328,7 +352,7 @@ static void __init chrp_find_openpic(void)
328 struct device_node *np, *root; 352 struct device_node *np, *root;
329 int len, i, j; 353 int len, i, j;
330 int isu_size, idu_size; 354 int isu_size, idu_size;
331 unsigned int *iranges, *opprop = NULL; 355 const unsigned int *iranges, *opprop = NULL;
332 int oplen = 0; 356 int oplen = 0;
333 unsigned long opaddr; 357 unsigned long opaddr;
334 int na = 1; 358 int na = 1;
@@ -338,8 +362,7 @@ static void __init chrp_find_openpic(void)
338 return; 362 return;
339 root = of_find_node_by_path("/"); 363 root = of_find_node_by_path("/");
340 if (root) { 364 if (root) {
341 opprop = (unsigned int *) get_property 365 opprop = get_property(root, "platform-open-pic", &oplen);
342 (root, "platform-open-pic", &oplen);
343 na = prom_n_addr_cells(root); 366 na = prom_n_addr_cells(root);
344 } 367 }
345 if (opprop && oplen >= na * sizeof(unsigned int)) { 368 if (opprop && oplen >= na * sizeof(unsigned int)) {
@@ -356,7 +379,7 @@ static void __init chrp_find_openpic(void)
356 379
357 printk(KERN_INFO "OpenPIC at %lx\n", opaddr); 380 printk(KERN_INFO "OpenPIC at %lx\n", opaddr);
358 381
359 iranges = (unsigned int *) get_property(np, "interrupt-ranges", &len); 382 iranges = get_property(np, "interrupt-ranges", &len);
360 if (iranges == NULL) 383 if (iranges == NULL)
361 len = 0; /* non-distributed mpic */ 384 len = 0; /* non-distributed mpic */
362 else 385 else
@@ -442,8 +465,8 @@ static void __init chrp_find_8259(void)
442 * from anyway 465 * from anyway
443 */ 466 */
444 for (np = find_devices("pci"); np != NULL; np = np->next) { 467 for (np = find_devices("pci"); np != NULL; np = np->next) {
445 unsigned int *addrp = (unsigned int *) 468 const unsigned int *addrp = get_property(np,
446 get_property(np, "8259-interrupt-acknowledge", NULL); 469 "8259-interrupt-acknowledge", NULL);
447 470
448 if (addrp == NULL) 471 if (addrp == NULL)
449 continue; 472 continue;
@@ -502,7 +525,7 @@ void __init
502chrp_init2(void) 525chrp_init2(void)
503{ 526{
504 struct device_node *device; 527 struct device_node *device;
505 unsigned int *p = NULL; 528 const unsigned int *p = NULL;
506 529
507#ifdef CONFIG_NVRAM 530#ifdef CONFIG_NVRAM
508 chrp_nvram_init(); 531 chrp_nvram_init();
@@ -520,8 +543,7 @@ chrp_init2(void)
520 */ 543 */
521 device = find_devices("rtas"); 544 device = find_devices("rtas");
522 if (device) 545 if (device)
523 p = (unsigned int *) get_property 546 p = get_property(device, "rtas-event-scan-rate", NULL);
524 (device, "rtas-event-scan-rate", NULL);
525 if (p && *p) { 547 if (p && *p) {
526 /* 548 /*
527 * Arrange to call chrp_event_scan at least *p times 549 * Arrange to call chrp_event_scan at least *p times
diff --git a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
index 5d393eb94935..e4f2b9df5e17 100644
--- a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
+++ b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
@@ -95,7 +95,7 @@ void mpc7448_hpc2_fixup_irq(struct pci_dev *dev)
95{ 95{
96 struct pci_controller *hose; 96 struct pci_controller *hose;
97 struct device_node *node; 97 struct device_node *node;
98 unsigned int *interrupt; 98 const unsigned int *interrupt;
99 int busnr; 99 int busnr;
100 int len; 100 int len;
101 u8 slot; 101 u8 slot;
@@ -112,7 +112,7 @@ void mpc7448_hpc2_fixup_irq(struct pci_dev *dev)
112 if (!node) 112 if (!node)
113 printk(KERN_ERR "No pci node found\n"); 113 printk(KERN_ERR "No pci node found\n");
114 114
115 interrupt = (unsigned int *) get_property(node, "interrupt-map", &len); 115 interrupt = get_property(node, "interrupt-map", &len);
116 slot = find_slot_by_devfn(interrupt, dev->devfn); 116 slot = find_slot_by_devfn(interrupt, dev->devfn);
117 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); 117 pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin);
118 if (pin == 0 || pin > 4) 118 if (pin == 0 || pin > 4)
@@ -141,9 +141,9 @@ static void __init mpc7448_hpc2_setup_arch(void)
141 141
142 cpu = of_find_node_by_type(NULL, "cpu"); 142 cpu = of_find_node_by_type(NULL, "cpu");
143 if (cpu != 0) { 143 if (cpu != 0) {
144 unsigned int *fp; 144 const unsigned int *fp;
145 145
146 fp = (int *)get_property(cpu, "clock-frequency", NULL); 146 fp = get_property(cpu, "clock-frequency", NULL);
147 if (fp != 0) 147 if (fp != 0)
148 loops_per_jiffy = *fp / HZ; 148 loops_per_jiffy = *fp / HZ;
149 else 149 else
diff --git a/arch/powerpc/platforms/iseries/Kconfig b/arch/powerpc/platforms/iseries/Kconfig
index 3d957a30c8c2..887b68804e6d 100644
--- a/arch/powerpc/platforms/iseries/Kconfig
+++ b/arch/powerpc/platforms/iseries/Kconfig
@@ -3,13 +3,17 @@ menu "iSeries device drivers"
3 depends on PPC_ISERIES 3 depends on PPC_ISERIES
4 4
5config VIOCONS 5config VIOCONS
6 tristate "iSeries Virtual Console Support" 6 tristate "iSeries Virtual Console Support (Obsolete)"
7 help
8 This is the old virtual console driver for legacy iSeries.
9 You should use the iSeries Hypervisor Virtual Console
10 support instead.
7 11
8config VIODASD 12config VIODASD
9 tristate "iSeries Virtual I/O disk support" 13 tristate "iSeries Virtual I/O disk support"
10 help 14 help
11 If you are running on an iSeries system and you want to use 15 If you are running on an iSeries system and you want to use
12 virtual disks created and managed by OS/400, say Y. 16 virtual disks created and managed by OS/400, say Y.
13 17
14config VIOCD 18config VIOCD
15 tristate "iSeries Virtual I/O CD support" 19 tristate "iSeries Virtual I/O CD support"
diff --git a/arch/powerpc/platforms/iseries/dt.c b/arch/powerpc/platforms/iseries/dt.c
index d194140c1ebf..e305deee7f44 100644
--- a/arch/powerpc/platforms/iseries/dt.c
+++ b/arch/powerpc/platforms/iseries/dt.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (c) 2005-2006 Michael Ellerman, IBM Corporation 2 * Copyright (C) 2005-2006 Michael Ellerman, IBM Corporation
3 * Copyright (C) 2000-2004, IBM Corporation
3 * 4 *
4 * Description: 5 * Description:
5 * This file contains all the routines to build a flattened device 6 * This file contains all the routines to build a flattened device
@@ -33,13 +34,13 @@
33#include <asm/iseries/hv_types.h> 34#include <asm/iseries/hv_types.h>
34#include <asm/iseries/hv_lp_config.h> 35#include <asm/iseries/hv_lp_config.h>
35#include <asm/iseries/hv_call_xm.h> 36#include <asm/iseries/hv_call_xm.h>
36#include <asm/iseries/it_exp_vpd_panel.h>
37#include <asm/udbg.h> 37#include <asm/udbg.h>
38 38
39#include "processor_vpd.h" 39#include "processor_vpd.h"
40#include "call_hpt.h" 40#include "call_hpt.h"
41#include "call_pci.h" 41#include "call_pci.h"
42#include "pci.h" 42#include "pci.h"
43#include "it_exp_vpd_panel.h"
43 44
44#ifdef DEBUG 45#ifdef DEBUG
45#define DBG(fmt...) udbg_printf(fmt) 46#define DBG(fmt...) udbg_printf(fmt)
@@ -76,6 +77,43 @@ static char __initdata device_type_pci[] = "pci";
76static char __initdata device_type_vdevice[] = "vdevice"; 77static char __initdata device_type_vdevice[] = "vdevice";
77static char __initdata device_type_vscsi[] = "vscsi"; 78static char __initdata device_type_vscsi[] = "vscsi";
78 79
80
81/* EBCDIC to ASCII conversion routines */
82
83static unsigned char __init e2a(unsigned char x)
84{
85 switch (x) {
86 case 0x81 ... 0x89:
87 return x - 0x81 + 'a';
88 case 0x91 ... 0x99:
89 return x - 0x91 + 'j';
90 case 0xA2 ... 0xA9:
91 return x - 0xA2 + 's';
92 case 0xC1 ... 0xC9:
93 return x - 0xC1 + 'A';
94 case 0xD1 ... 0xD9:
95 return x - 0xD1 + 'J';
96 case 0xE2 ... 0xE9:
97 return x - 0xE2 + 'S';
98 case 0xF0 ... 0xF9:
99 return x - 0xF0 + '0';
100 }
101 return ' ';
102}
103
104static unsigned char * __init strne2a(unsigned char *dest,
105 const unsigned char *src, size_t n)
106{
107 int i;
108
109 n = strnlen(src, n);
110
111 for (i = 0; i < n; i++)
112 dest[i] = e2a(src[i]);
113
114 return dest;
115}
116
79static struct iseries_flat_dt * __init dt_init(void) 117static struct iseries_flat_dt * __init dt_init(void)
80{ 118{
81 struct iseries_flat_dt *dt; 119 struct iseries_flat_dt *dt;
@@ -298,7 +336,8 @@ static void __init dt_vdevices(struct iseries_flat_dt *dt)
298 dt_prop_u32(dt, "#address-cells", 1); 336 dt_prop_u32(dt, "#address-cells", 1);
299 dt_prop_u32(dt, "#size-cells", 0); 337 dt_prop_u32(dt, "#size-cells", 0);
300 338
301 dt_do_vdevice(dt, "vty", reg, -1, device_type_serial, NULL, 1); 339 dt_do_vdevice(dt, "vty", reg, -1, device_type_serial,
340 "IBM,iSeries-vty", 1);
302 reg++; 341 reg++;
303 342
304 dt_do_vdevice(dt, "v-scsi", reg, -1, device_type_vscsi, 343 dt_do_vdevice(dt, "v-scsi", reg, -1, device_type_vscsi,
diff --git a/arch/powerpc/platforms/iseries/hvlpconfig.c b/arch/powerpc/platforms/iseries/hvlpconfig.c
index 663a1affb4bb..f0475f0b1853 100644
--- a/arch/powerpc/platforms/iseries/hvlpconfig.c
+++ b/arch/powerpc/platforms/iseries/hvlpconfig.c
@@ -18,9 +18,22 @@
18 18
19#include <linux/module.h> 19#include <linux/module.h>
20#include <asm/iseries/hv_lp_config.h> 20#include <asm/iseries/hv_lp_config.h>
21#include "it_lp_naca.h"
21 22
22HvLpIndex HvLpConfig_getLpIndex_outline(void) 23HvLpIndex HvLpConfig_getLpIndex_outline(void)
23{ 24{
24 return HvLpConfig_getLpIndex(); 25 return HvLpConfig_getLpIndex();
25} 26}
26EXPORT_SYMBOL(HvLpConfig_getLpIndex_outline); 27EXPORT_SYMBOL(HvLpConfig_getLpIndex_outline);
28
29HvLpIndex HvLpConfig_getLpIndex(void)
30{
31 return itLpNaca.xLpIndex;
32}
33EXPORT_SYMBOL(HvLpConfig_getLpIndex);
34
35HvLpIndex HvLpConfig_getPrimaryLpIndex(void)
36{
37 return itLpNaca.xPrimaryLpIndex;
38}
39EXPORT_SYMBOL_GPL(HvLpConfig_getPrimaryLpIndex);
diff --git a/arch/powerpc/platforms/iseries/iommu.c b/arch/powerpc/platforms/iseries/iommu.c
index e3bd2015f2c9..f4cbbcf8773a 100644
--- a/arch/powerpc/platforms/iseries/iommu.c
+++ b/arch/powerpc/platforms/iseries/iommu.c
@@ -88,6 +88,23 @@ static void tce_free_iSeries(struct iommu_table *tbl, long index, long npages)
88} 88}
89 89
90/* 90/*
91 * Structure passed to HvCallXm_getTceTableParms
92 */
93struct iommu_table_cb {
94 unsigned long itc_busno; /* Bus number for this tce table */
95 unsigned long itc_start; /* Will be NULL for secondary */
96 unsigned long itc_totalsize; /* Size (in pages) of whole table */
97 unsigned long itc_offset; /* Index into real tce table of the
98 start of our section */
99 unsigned long itc_size; /* Size (in pages) of our section */
100 unsigned long itc_index; /* Index of this tce table */
101 unsigned short itc_maxtables; /* Max num of tables for partition */
102 unsigned char itc_virtbus; /* Flag to indicate virtual bus */
103 unsigned char itc_slotno; /* IOA Tce Slot Index */
104 unsigned char itc_rsvd[4];
105};
106
107/*
91 * Call Hv with the architected data structure to get TCE table info. 108 * Call Hv with the architected data structure to get TCE table info.
92 * info. Put the returned data into the Linux representation of the 109 * info. Put the returned data into the Linux representation of the
93 * TCE table data. 110 * TCE table data.
@@ -162,7 +179,7 @@ void iommu_devnode_init_iSeries(struct device_node *dn)
162{ 179{
163 struct iommu_table *tbl; 180 struct iommu_table *tbl;
164 struct pci_dn *pdn = PCI_DN(dn); 181 struct pci_dn *pdn = PCI_DN(dn);
165 u32 *lsn = (u32 *)get_property(dn, "linux,logical-slot-number", NULL); 182 const u32 *lsn = get_property(dn, "linux,logical-slot-number", NULL);
166 183
167 BUG_ON(lsn == NULL); 184 BUG_ON(lsn == NULL);
168 185
diff --git a/include/asm-powerpc/iseries/it_exp_vpd_panel.h b/arch/powerpc/platforms/iseries/it_exp_vpd_panel.h
index 304a609ae21a..6de9097b7f57 100644
--- a/include/asm-powerpc/iseries/it_exp_vpd_panel.h
+++ b/arch/powerpc/platforms/iseries/it_exp_vpd_panel.h
@@ -15,8 +15,8 @@
15 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */ 17 */
18#ifndef _ASM_POWERPC_ISERIES_IT_EXT_VPD_PANEL_H 18#ifndef _PLATFORMS_ISERIES_IT_EXT_VPD_PANEL_H
19#define _ASM_POWERPC_ISERIES_IT_EXT_VPD_PANEL_H 19#define _PLATFORMS_ISERIES_IT_EXT_VPD_PANEL_H
20 20
21/* 21/*
22 * This struct maps the panel information 22 * This struct maps the panel information
@@ -48,4 +48,4 @@ struct ItExtVpdPanel {
48 48
49extern struct ItExtVpdPanel xItExtVpdPanel; 49extern struct ItExtVpdPanel xItExtVpdPanel;
50 50
51#endif /* _ASM_POWERPC_ISERIES_IT_EXT_VPD_PANEL_H */ 51#endif /* _PLATFORMS_ISERIES_IT_EXT_VPD_PANEL_H */
diff --git a/include/asm-powerpc/iseries/it_lp_naca.h b/arch/powerpc/platforms/iseries/it_lp_naca.h
index 4fdcf052927f..9bbf58986819 100644
--- a/include/asm-powerpc/iseries/it_lp_naca.h
+++ b/arch/powerpc/platforms/iseries/it_lp_naca.h
@@ -15,8 +15,8 @@
15 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */ 17 */
18#ifndef _ASM_POWERPC_ISERIES_IT_LP_NACA_H 18#ifndef _PLATFORMS_ISERIES_IT_LP_NACA_H
19#define _ASM_POWERPC_ISERIES_IT_LP_NACA_H 19#define _PLATFORMS_ISERIES_IT_LP_NACA_H
20 20
21#include <linux/types.h> 21#include <linux/types.h>
22 22
@@ -77,4 +77,4 @@ extern struct ItLpNaca itLpNaca;
77#define ITLPNACA_HWSYNCEDTBS 0x20 /* Hardware synced TBs */ 77#define ITLPNACA_HWSYNCEDTBS 0x20 /* Hardware synced TBs */
78#define ITLPNACA_HMTINT 0x10 /* Utilize MHT for interrupts */ 78#define ITLPNACA_HMTINT 0x10 /* Utilize MHT for interrupts */
79 79
80#endif /* _ASM_POWERPC_ISERIES_IT_LP_NACA_H */ 80#endif /* _PLATFORMS_ISERIES_IT_LP_NACA_H */
diff --git a/arch/powerpc/platforms/iseries/lpardata.c b/arch/powerpc/platforms/iseries/lpardata.c
index a7769445d6c7..8162049bb04d 100644
--- a/arch/powerpc/platforms/iseries/lpardata.c
+++ b/arch/powerpc/platforms/iseries/lpardata.c
@@ -13,12 +13,10 @@
13#include <asm/processor.h> 13#include <asm/processor.h>
14#include <asm/ptrace.h> 14#include <asm/ptrace.h>
15#include <asm/abs_addr.h> 15#include <asm/abs_addr.h>
16#include <asm/iseries/it_lp_naca.h>
17#include <asm/lppaca.h> 16#include <asm/lppaca.h>
18#include <asm/iseries/it_lp_reg_save.h> 17#include <asm/iseries/it_lp_reg_save.h>
19#include <asm/paca.h> 18#include <asm/paca.h>
20#include <asm/iseries/lpar_map.h> 19#include <asm/iseries/lpar_map.h>
21#include <asm/iseries/it_exp_vpd_panel.h>
22#include <asm/iseries/it_lp_queue.h> 20#include <asm/iseries/it_lp_queue.h>
23 21
24#include "naca.h" 22#include "naca.h"
@@ -27,6 +25,8 @@
27#include "ipl_parms.h" 25#include "ipl_parms.h"
28#include "processor_vpd.h" 26#include "processor_vpd.h"
29#include "release_data.h" 27#include "release_data.h"
28#include "it_exp_vpd_panel.h"
29#include "it_lp_naca.h"
30 30
31/* The HvReleaseData is the root of the information shared between 31/* The HvReleaseData is the root of the information shared between
32 * the hypervisor and Linux. 32 * the hypervisor and Linux.
@@ -127,14 +127,12 @@ struct ItLpNaca itLpNaca = {
127 (u64)instruction_access_slb_iSeries /* 0x480 I-SLB */ 127 (u64)instruction_access_slb_iSeries /* 0x480 I-SLB */
128 } 128 }
129}; 129};
130EXPORT_SYMBOL(itLpNaca);
131 130
132/* May be filled in by the hypervisor so cannot end up in the BSS */ 131/* May be filled in by the hypervisor so cannot end up in the BSS */
133struct ItIplParmsReal xItIplParmsReal __attribute__((__section__(".data"))); 132struct ItIplParmsReal xItIplParmsReal __attribute__((__section__(".data")));
134 133
135/* May be filled in by the hypervisor so cannot end up in the BSS */ 134/* May be filled in by the hypervisor so cannot end up in the BSS */
136struct ItExtVpdPanel xItExtVpdPanel __attribute__((__section__(".data"))); 135struct ItExtVpdPanel xItExtVpdPanel __attribute__((__section__(".data")));
137EXPORT_SYMBOL(xItExtVpdPanel);
138 136
139#define maxPhysicalProcessors 32 137#define maxPhysicalProcessors 32
140 138
diff --git a/arch/powerpc/platforms/iseries/lpevents.c b/arch/powerpc/platforms/iseries/lpevents.c
index 2a9f81ea27d6..98c1c2440aad 100644
--- a/arch/powerpc/platforms/iseries/lpevents.c
+++ b/arch/powerpc/platforms/iseries/lpevents.c
@@ -20,7 +20,7 @@
20#include <asm/iseries/it_lp_queue.h> 20#include <asm/iseries/it_lp_queue.h>
21#include <asm/iseries/hv_lp_event.h> 21#include <asm/iseries/hv_lp_event.h>
22#include <asm/iseries/hv_call_event.h> 22#include <asm/iseries/hv_call_event.h>
23#include <asm/iseries/it_lp_naca.h> 23#include "it_lp_naca.h"
24 24
25/* 25/*
26 * The LpQueue is used to pass event data from the hypervisor to 26 * The LpQueue is used to pass event data from the hypervisor to
diff --git a/arch/powerpc/platforms/iseries/main_store.h b/arch/powerpc/platforms/iseries/main_store.h
index 74f6889f834f..1a7a3f50e40b 100644
--- a/arch/powerpc/platforms/iseries/main_store.h
+++ b/arch/powerpc/platforms/iseries/main_store.h
@@ -61,9 +61,9 @@ struct IoHriMainStoreSegment4 {
61}; 61};
62 62
63/* Main Store VPD for Power4 */ 63/* Main Store VPD for Power4 */
64struct IoHriMainStoreChipInfo1 { 64struct __attribute((packed)) IoHriMainStoreChipInfo1 {
65 u32 chipMfgID __attribute((packed)); 65 u32 chipMfgID;
66 char chipECLevel[4] __attribute((packed)); 66 char chipECLevel[4];
67}; 67};
68 68
69struct IoHriMainStoreVpdIdData { 69struct IoHriMainStoreVpdIdData {
@@ -73,72 +73,72 @@ struct IoHriMainStoreVpdIdData {
73 char serialNumber[12]; 73 char serialNumber[12];
74}; 74};
75 75
76struct IoHriMainStoreVpdFruData { 76struct __attribute((packed)) IoHriMainStoreVpdFruData {
77 char fruLabel[8] __attribute((packed)); 77 char fruLabel[8];
78 u8 numberOfSlots __attribute((packed)); 78 u8 numberOfSlots;
79 u8 pluggingType __attribute((packed)); 79 u8 pluggingType;
80 u16 slotMapIndex __attribute((packed)); 80 u16 slotMapIndex;
81}; 81};
82 82
83struct IoHriMainStoreAdrRangeBlock { 83struct __attribute((packed)) IoHriMainStoreAdrRangeBlock {
84 void *blockStart __attribute((packed)); 84 void *blockStart;
85 void *blockEnd __attribute((packed)); 85 void *blockEnd;
86 u32 blockProcChipId __attribute((packed)); 86 u32 blockProcChipId;
87}; 87};
88 88
89#define MaxAreaAdrRangeBlocks 4 89#define MaxAreaAdrRangeBlocks 4
90 90
91struct IoHriMainStoreArea4 { 91struct __attribute((packed)) IoHriMainStoreArea4 {
92 u32 msVpdFormat __attribute((packed)); 92 u32 msVpdFormat;
93 u8 containedVpdType __attribute((packed)); 93 u8 containedVpdType;
94 u8 reserved1 __attribute((packed)); 94 u8 reserved1;
95 u16 reserved2 __attribute((packed)); 95 u16 reserved2;
96 96
97 u64 msExists __attribute((packed)); 97 u64 msExists;
98 u64 msFunctional __attribute((packed)); 98 u64 msFunctional;
99 99
100 u32 memorySize __attribute((packed)); 100 u32 memorySize;
101 u32 procNodeId __attribute((packed)); 101 u32 procNodeId;
102 102
103 u32 numAdrRangeBlocks __attribute((packed)); 103 u32 numAdrRangeBlocks;
104 struct IoHriMainStoreAdrRangeBlock xAdrRangeBlock[MaxAreaAdrRangeBlocks] __attribute((packed)); 104 struct IoHriMainStoreAdrRangeBlock xAdrRangeBlock[MaxAreaAdrRangeBlocks];
105 105
106 struct IoHriMainStoreChipInfo1 chipInfo0 __attribute((packed)); 106 struct IoHriMainStoreChipInfo1 chipInfo0;
107 struct IoHriMainStoreChipInfo1 chipInfo1 __attribute((packed)); 107 struct IoHriMainStoreChipInfo1 chipInfo1;
108 struct IoHriMainStoreChipInfo1 chipInfo2 __attribute((packed)); 108 struct IoHriMainStoreChipInfo1 chipInfo2;
109 struct IoHriMainStoreChipInfo1 chipInfo3 __attribute((packed)); 109 struct IoHriMainStoreChipInfo1 chipInfo3;
110 struct IoHriMainStoreChipInfo1 chipInfo4 __attribute((packed)); 110 struct IoHriMainStoreChipInfo1 chipInfo4;
111 struct IoHriMainStoreChipInfo1 chipInfo5 __attribute((packed)); 111 struct IoHriMainStoreChipInfo1 chipInfo5;
112 struct IoHriMainStoreChipInfo1 chipInfo6 __attribute((packed)); 112 struct IoHriMainStoreChipInfo1 chipInfo6;
113 struct IoHriMainStoreChipInfo1 chipInfo7 __attribute((packed)); 113 struct IoHriMainStoreChipInfo1 chipInfo7;
114 114
115 void *msRamAreaArray __attribute((packed)); 115 void *msRamAreaArray;
116 u32 msRamAreaArrayNumEntries __attribute((packed)); 116 u32 msRamAreaArrayNumEntries;
117 u32 msRamAreaArrayEntrySize __attribute((packed)); 117 u32 msRamAreaArrayEntrySize;
118 118
119 u32 numaDimmExists __attribute((packed)); 119 u32 numaDimmExists;
120 u32 numaDimmFunctional __attribute((packed)); 120 u32 numaDimmFunctional;
121 void *numaDimmArray __attribute((packed)); 121 void *numaDimmArray;
122 u32 numaDimmArrayNumEntries __attribute((packed)); 122 u32 numaDimmArrayNumEntries;
123 u32 numaDimmArrayEntrySize __attribute((packed)); 123 u32 numaDimmArrayEntrySize;
124 124
125 struct IoHriMainStoreVpdIdData idData __attribute((packed)); 125 struct IoHriMainStoreVpdIdData idData;
126 126
127 u64 powerData __attribute((packed)); 127 u64 powerData;
128 u64 cardAssemblyPartNum __attribute((packed)); 128 u64 cardAssemblyPartNum;
129 u64 chipSerialNum __attribute((packed)); 129 u64 chipSerialNum;
130 130
131 u64 reserved3 __attribute((packed)); 131 u64 reserved3;
132 char reserved4[16] __attribute((packed)); 132 char reserved4[16];
133 133
134 struct IoHriMainStoreVpdFruData fruData __attribute((packed)); 134 struct IoHriMainStoreVpdFruData fruData;
135 135
136 u8 vpdPortNum __attribute((packed)); 136 u8 vpdPortNum;
137 u8 reserved5 __attribute((packed)); 137 u8 reserved5;
138 u8 frameId __attribute((packed)); 138 u8 frameId;
139 u8 rackUnit __attribute((packed)); 139 u8 rackUnit;
140 char asciiKeywordVpd[256] __attribute((packed)); 140 char asciiKeywordVpd[256];
141 u32 reserved6 __attribute((packed)); 141 u32 reserved6;
142}; 142};
143 143
144 144
diff --git a/arch/powerpc/platforms/iseries/pci.c b/arch/powerpc/platforms/iseries/pci.c
index 35bcc98111f5..3eb12065df23 100644
--- a/arch/powerpc/platforms/iseries/pci.c
+++ b/arch/powerpc/platforms/iseries/pci.c
@@ -34,6 +34,7 @@
34#include <asm/pci-bridge.h> 34#include <asm/pci-bridge.h>
35#include <asm/iommu.h> 35#include <asm/iommu.h>
36#include <asm/abs_addr.h> 36#include <asm/abs_addr.h>
37#include <asm/firmware.h>
37 38
38#include <asm/iseries/hv_call_xm.h> 39#include <asm/iseries/hv_call_xm.h>
39#include <asm/iseries/mf.h> 40#include <asm/iseries/mf.h>
@@ -176,12 +177,12 @@ void iSeries_pcibios_init(void)
176 } 177 }
177 while ((node = of_get_next_child(root, node)) != NULL) { 178 while ((node = of_get_next_child(root, node)) != NULL) {
178 HvBusNumber bus; 179 HvBusNumber bus;
179 u32 *busp; 180 const u32 *busp;
180 181
181 if ((node->type == NULL) || (strcmp(node->type, "pci") != 0)) 182 if ((node->type == NULL) || (strcmp(node->type, "pci") != 0))
182 continue; 183 continue;
183 184
184 busp = (u32 *)get_property(node, "bus-range", NULL); 185 busp = get_property(node, "bus-range", NULL);
185 if (busp == NULL) 186 if (busp == NULL)
186 continue; 187 continue;
187 bus = *busp; 188 bus = *busp;
@@ -221,10 +222,9 @@ void __init iSeries_pci_final_fixup(void)
221 222
222 if (node != NULL) { 223 if (node != NULL) {
223 struct pci_dn *pdn = PCI_DN(node); 224 struct pci_dn *pdn = PCI_DN(node);
224 u32 *agent; 225 const u32 *agent;
225 226
226 agent = (u32 *)get_property(node, "linux,agent-id", 227 agent = get_property(node, "linux,agent-id", NULL);
227 NULL);
228 if ((pdn != NULL) && (agent != NULL)) { 228 if ((pdn != NULL) && (agent != NULL)) {
229 u8 irq = iSeries_allocate_IRQ(pdn->busno, 0, 229 u8 irq = iSeries_allocate_IRQ(pdn->busno, 0,
230 pdn->bussubno); 230 pdn->bussubno);
@@ -271,46 +271,6 @@ void pcibios_fixup_resources(struct pci_dev *pdev)
271} 271}
272 272
273/* 273/*
274 * I/0 Memory copy MUST use mmio commands on iSeries
275 * To do; For performance, include the hv call directly
276 */
277void iSeries_memset_io(volatile void __iomem *dest, char c, size_t Count)
278{
279 u8 ByteValue = c;
280 long NumberOfBytes = Count;
281
282 while (NumberOfBytes > 0) {
283 iSeries_Write_Byte(ByteValue, dest++);
284 -- NumberOfBytes;
285 }
286}
287EXPORT_SYMBOL(iSeries_memset_io);
288
289void iSeries_memcpy_toio(volatile void __iomem *dest, void *source, size_t count)
290{
291 char *src = source;
292 long NumberOfBytes = count;
293
294 while (NumberOfBytes > 0) {
295 iSeries_Write_Byte(*src++, dest++);
296 -- NumberOfBytes;
297 }
298}
299EXPORT_SYMBOL(iSeries_memcpy_toio);
300
301void iSeries_memcpy_fromio(void *dest, const volatile void __iomem *src, size_t count)
302{
303 char *dst = dest;
304 long NumberOfBytes = count;
305
306 while (NumberOfBytes > 0) {
307 *dst++ = iSeries_Read_Byte(src++);
308 -- NumberOfBytes;
309 }
310}
311EXPORT_SYMBOL(iSeries_memcpy_fromio);
312
313/*
314 * Look down the chain to find the matching Device Device 274 * Look down the chain to find the matching Device Device
315 */ 275 */
316static struct device_node *find_Device_Node(int bus, int devfn) 276static struct device_node *find_Device_Node(int bus, int devfn)
@@ -492,7 +452,7 @@ static inline struct device_node *xlate_iomm_address(
492 * iSeries_Read_Word = Read Word (16 bit) 452 * iSeries_Read_Word = Read Word (16 bit)
493 * iSeries_Read_Long = Read Long (32 bit) 453 * iSeries_Read_Long = Read Long (32 bit)
494 */ 454 */
495u8 iSeries_Read_Byte(const volatile void __iomem *IoAddress) 455static u8 iSeries_Read_Byte(const volatile void __iomem *IoAddress)
496{ 456{
497 u64 BarOffset; 457 u64 BarOffset;
498 u64 dsa; 458 u64 dsa;
@@ -519,9 +479,8 @@ u8 iSeries_Read_Byte(const volatile void __iomem *IoAddress)
519 479
520 return (u8)ret.value; 480 return (u8)ret.value;
521} 481}
522EXPORT_SYMBOL(iSeries_Read_Byte);
523 482
524u16 iSeries_Read_Word(const volatile void __iomem *IoAddress) 483static u16 iSeries_Read_Word(const volatile void __iomem *IoAddress)
525{ 484{
526 u64 BarOffset; 485 u64 BarOffset;
527 u64 dsa; 486 u64 dsa;
@@ -549,9 +508,8 @@ u16 iSeries_Read_Word(const volatile void __iomem *IoAddress)
549 508
550 return swab16((u16)ret.value); 509 return swab16((u16)ret.value);
551} 510}
552EXPORT_SYMBOL(iSeries_Read_Word);
553 511
554u32 iSeries_Read_Long(const volatile void __iomem *IoAddress) 512static u32 iSeries_Read_Long(const volatile void __iomem *IoAddress)
555{ 513{
556 u64 BarOffset; 514 u64 BarOffset;
557 u64 dsa; 515 u64 dsa;
@@ -579,7 +537,6 @@ u32 iSeries_Read_Long(const volatile void __iomem *IoAddress)
579 537
580 return swab32((u32)ret.value); 538 return swab32((u32)ret.value);
581} 539}
582EXPORT_SYMBOL(iSeries_Read_Long);
583 540
584/* 541/*
585 * Write MM I/O Instructions for the iSeries 542 * Write MM I/O Instructions for the iSeries
@@ -588,7 +545,7 @@ EXPORT_SYMBOL(iSeries_Read_Long);
588 * iSeries_Write_Word = Write Word(16 bit) 545 * iSeries_Write_Word = Write Word(16 bit)
589 * iSeries_Write_Long = Write Long(32 bit) 546 * iSeries_Write_Long = Write Long(32 bit)
590 */ 547 */
591void iSeries_Write_Byte(u8 data, volatile void __iomem *IoAddress) 548static void iSeries_Write_Byte(u8 data, volatile void __iomem *IoAddress)
592{ 549{
593 u64 BarOffset; 550 u64 BarOffset;
594 u64 dsa; 551 u64 dsa;
@@ -613,9 +570,8 @@ void iSeries_Write_Byte(u8 data, volatile void __iomem *IoAddress)
613 rc = HvCall4(HvCallPciBarStore8, dsa, BarOffset, data, 0); 570 rc = HvCall4(HvCallPciBarStore8, dsa, BarOffset, data, 0);
614 } while (CheckReturnCode("WWB", DevNode, &retry, rc) != 0); 571 } while (CheckReturnCode("WWB", DevNode, &retry, rc) != 0);
615} 572}
616EXPORT_SYMBOL(iSeries_Write_Byte);
617 573
618void iSeries_Write_Word(u16 data, volatile void __iomem *IoAddress) 574static void iSeries_Write_Word(u16 data, volatile void __iomem *IoAddress)
619{ 575{
620 u64 BarOffset; 576 u64 BarOffset;
621 u64 dsa; 577 u64 dsa;
@@ -640,9 +596,8 @@ void iSeries_Write_Word(u16 data, volatile void __iomem *IoAddress)
640 rc = HvCall4(HvCallPciBarStore16, dsa, BarOffset, swab16(data), 0); 596 rc = HvCall4(HvCallPciBarStore16, dsa, BarOffset, swab16(data), 0);
641 } while (CheckReturnCode("WWW", DevNode, &retry, rc) != 0); 597 } while (CheckReturnCode("WWW", DevNode, &retry, rc) != 0);
642} 598}
643EXPORT_SYMBOL(iSeries_Write_Word);
644 599
645void iSeries_Write_Long(u32 data, volatile void __iomem *IoAddress) 600static void iSeries_Write_Long(u32 data, volatile void __iomem *IoAddress)
646{ 601{
647 u64 BarOffset; 602 u64 BarOffset;
648 u64 dsa; 603 u64 dsa;
@@ -667,4 +622,224 @@ void iSeries_Write_Long(u32 data, volatile void __iomem *IoAddress)
667 rc = HvCall4(HvCallPciBarStore32, dsa, BarOffset, swab32(data), 0); 622 rc = HvCall4(HvCallPciBarStore32, dsa, BarOffset, swab32(data), 0);
668 } while (CheckReturnCode("WWL", DevNode, &retry, rc) != 0); 623 } while (CheckReturnCode("WWL", DevNode, &retry, rc) != 0);
669} 624}
670EXPORT_SYMBOL(iSeries_Write_Long); 625
626extern unsigned char __raw_readb(const volatile void __iomem *addr)
627{
628 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
629
630 return *(volatile unsigned char __force *)addr;
631}
632EXPORT_SYMBOL(__raw_readb);
633
634extern unsigned short __raw_readw(const volatile void __iomem *addr)
635{
636 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
637
638 return *(volatile unsigned short __force *)addr;
639}
640EXPORT_SYMBOL(__raw_readw);
641
642extern unsigned int __raw_readl(const volatile void __iomem *addr)
643{
644 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
645
646 return *(volatile unsigned int __force *)addr;
647}
648EXPORT_SYMBOL(__raw_readl);
649
650extern unsigned long __raw_readq(const volatile void __iomem *addr)
651{
652 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
653
654 return *(volatile unsigned long __force *)addr;
655}
656EXPORT_SYMBOL(__raw_readq);
657
658extern void __raw_writeb(unsigned char v, volatile void __iomem *addr)
659{
660 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
661
662 *(volatile unsigned char __force *)addr = v;
663}
664EXPORT_SYMBOL(__raw_writeb);
665
666extern void __raw_writew(unsigned short v, volatile void __iomem *addr)
667{
668 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
669
670 *(volatile unsigned short __force *)addr = v;
671}
672EXPORT_SYMBOL(__raw_writew);
673
674extern void __raw_writel(unsigned int v, volatile void __iomem *addr)
675{
676 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
677
678 *(volatile unsigned int __force *)addr = v;
679}
680EXPORT_SYMBOL(__raw_writel);
681
682extern void __raw_writeq(unsigned long v, volatile void __iomem *addr)
683{
684 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
685
686 *(volatile unsigned long __force *)addr = v;
687}
688EXPORT_SYMBOL(__raw_writeq);
689
690int in_8(const volatile unsigned char __iomem *addr)
691{
692 if (firmware_has_feature(FW_FEATURE_ISERIES))
693 return iSeries_Read_Byte(addr);
694 return __in_8(addr);
695}
696EXPORT_SYMBOL(in_8);
697
698void out_8(volatile unsigned char __iomem *addr, int val)
699{
700 if (firmware_has_feature(FW_FEATURE_ISERIES))
701 iSeries_Write_Byte(val, addr);
702 else
703 __out_8(addr, val);
704}
705EXPORT_SYMBOL(out_8);
706
707int in_le16(const volatile unsigned short __iomem *addr)
708{
709 if (firmware_has_feature(FW_FEATURE_ISERIES))
710 return iSeries_Read_Word(addr);
711 return __in_le16(addr);
712}
713EXPORT_SYMBOL(in_le16);
714
715int in_be16(const volatile unsigned short __iomem *addr)
716{
717 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
718
719 return __in_be16(addr);
720}
721EXPORT_SYMBOL(in_be16);
722
723void out_le16(volatile unsigned short __iomem *addr, int val)
724{
725 if (firmware_has_feature(FW_FEATURE_ISERIES))
726 iSeries_Write_Word(val, addr);
727 else
728 __out_le16(addr, val);
729}
730EXPORT_SYMBOL(out_le16);
731
732void out_be16(volatile unsigned short __iomem *addr, int val)
733{
734 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
735
736 __out_be16(addr, val);
737}
738EXPORT_SYMBOL(out_be16);
739
740unsigned in_le32(const volatile unsigned __iomem *addr)
741{
742 if (firmware_has_feature(FW_FEATURE_ISERIES))
743 return iSeries_Read_Long(addr);
744 return __in_le32(addr);
745}
746EXPORT_SYMBOL(in_le32);
747
748unsigned in_be32(const volatile unsigned __iomem *addr)
749{
750 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
751
752 return __in_be32(addr);
753}
754EXPORT_SYMBOL(in_be32);
755
756void out_le32(volatile unsigned __iomem *addr, int val)
757{
758 if (firmware_has_feature(FW_FEATURE_ISERIES))
759 iSeries_Write_Long(val, addr);
760 else
761 __out_le32(addr, val);
762}
763EXPORT_SYMBOL(out_le32);
764
765void out_be32(volatile unsigned __iomem *addr, int val)
766{
767 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
768
769 __out_be32(addr, val);
770}
771EXPORT_SYMBOL(out_be32);
772
773unsigned long in_le64(const volatile unsigned long __iomem *addr)
774{
775 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
776
777 return __in_le64(addr);
778}
779EXPORT_SYMBOL(in_le64);
780
781unsigned long in_be64(const volatile unsigned long __iomem *addr)
782{
783 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
784
785 return __in_be64(addr);
786}
787EXPORT_SYMBOL(in_be64);
788
789void out_le64(volatile unsigned long __iomem *addr, unsigned long val)
790{
791 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
792
793 __out_le64(addr, val);
794}
795EXPORT_SYMBOL(out_le64);
796
797void out_be64(volatile unsigned long __iomem *addr, unsigned long val)
798{
799 BUG_ON(firmware_has_feature(FW_FEATURE_ISERIES));
800
801 __out_be64(addr, val);
802}
803EXPORT_SYMBOL(out_be64);
804
805void memset_io(volatile void __iomem *addr, int c, unsigned long n)
806{
807 if (firmware_has_feature(FW_FEATURE_ISERIES)) {
808 volatile char __iomem *d = addr;
809
810 while (n-- > 0) {
811 iSeries_Write_Byte(c, d++);
812 }
813 } else
814 eeh_memset_io(addr, c, n);
815}
816EXPORT_SYMBOL(memset_io);
817
818void memcpy_fromio(void *dest, const volatile void __iomem *src,
819 unsigned long n)
820{
821 if (firmware_has_feature(FW_FEATURE_ISERIES)) {
822 char *d = dest;
823 const volatile char __iomem *s = src;
824
825 while (n-- > 0) {
826 *d++ = iSeries_Read_Byte(s++);
827 }
828 } else
829 eeh_memcpy_fromio(dest, src, n);
830}
831EXPORT_SYMBOL(memcpy_fromio);
832
833void memcpy_toio(volatile void __iomem *dest, const void *src, unsigned long n)
834{
835 if (firmware_has_feature(FW_FEATURE_ISERIES)) {
836 const char *s = src;
837 volatile char __iomem *d = dest;
838
839 while (n-- > 0) {
840 iSeries_Write_Byte(*s++, d++);
841 }
842 } else
843 eeh_memcpy_toio(dest, src, n);
844}
845EXPORT_SYMBOL(memcpy_toio);
diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c
index c9605d773a77..7f1953066ff8 100644
--- a/arch/powerpc/platforms/iseries/setup.c
+++ b/arch/powerpc/platforms/iseries/setup.c
@@ -59,6 +59,7 @@
59#include "irq.h" 59#include "irq.h"
60#include "vpd_areas.h" 60#include "vpd_areas.h"
61#include "processor_vpd.h" 61#include "processor_vpd.h"
62#include "it_lp_naca.h"
62#include "main_store.h" 63#include "main_store.h"
63#include "call_sm.h" 64#include "call_sm.h"
64#include "call_hpt.h" 65#include "call_hpt.h"
diff --git a/arch/powerpc/platforms/iseries/viopath.c b/arch/powerpc/platforms/iseries/viopath.c
index 622a30149b48..9baa4ee82592 100644
--- a/arch/powerpc/platforms/iseries/viopath.c
+++ b/arch/powerpc/platforms/iseries/viopath.c
@@ -41,8 +41,8 @@
41 41
42#include <asm/system.h> 42#include <asm/system.h>
43#include <asm/uaccess.h> 43#include <asm/uaccess.h>
44#include <asm/prom.h>
44#include <asm/iseries/hv_types.h> 45#include <asm/iseries/hv_types.h>
45#include <asm/iseries/it_exp_vpd_panel.h>
46#include <asm/iseries/hv_lp_event.h> 46#include <asm/iseries/hv_lp_event.h>
47#include <asm/iseries/hv_lp_config.h> 47#include <asm/iseries/hv_lp_config.h>
48#include <asm/iseries/mf.h> 48#include <asm/iseries/mf.h>
@@ -116,6 +116,8 @@ static int proc_viopath_show(struct seq_file *m, void *v)
116 dma_addr_t handle; 116 dma_addr_t handle;
117 HvLpEvent_Rc hvrc; 117 HvLpEvent_Rc hvrc;
118 DECLARE_MUTEX_LOCKED(Semaphore); 118 DECLARE_MUTEX_LOCKED(Semaphore);
119 struct device_node *node;
120 const char *sysid;
119 121
120 buf = kmalloc(HW_PAGE_SIZE, GFP_KERNEL); 122 buf = kmalloc(HW_PAGE_SIZE, GFP_KERNEL);
121 if (!buf) 123 if (!buf)
@@ -143,20 +145,26 @@ static int proc_viopath_show(struct seq_file *m, void *v)
143 145
144 buf[HW_PAGE_SIZE-1] = '\0'; 146 buf[HW_PAGE_SIZE-1] = '\0';
145 seq_printf(m, "%s", buf); 147 seq_printf(m, "%s", buf);
146 seq_printf(m, "AVAILABLE_VETH=%x\n", vlanMap);
147 seq_printf(m, "SRLNBR=%c%c%c%c%c%c%c\n",
148 e2a(xItExtVpdPanel.mfgID[2]),
149 e2a(xItExtVpdPanel.mfgID[3]),
150 e2a(xItExtVpdPanel.systemSerial[1]),
151 e2a(xItExtVpdPanel.systemSerial[2]),
152 e2a(xItExtVpdPanel.systemSerial[3]),
153 e2a(xItExtVpdPanel.systemSerial[4]),
154 e2a(xItExtVpdPanel.systemSerial[5]));
155 148
156 dma_unmap_single(iSeries_vio_dev, handle, HW_PAGE_SIZE, 149 dma_unmap_single(iSeries_vio_dev, handle, HW_PAGE_SIZE,
157 DMA_FROM_DEVICE); 150 DMA_FROM_DEVICE);
158 kfree(buf); 151 kfree(buf);
159 152
153 seq_printf(m, "AVAILABLE_VETH=%x\n", vlanMap);
154
155 node = of_find_node_by_path("/");
156 sysid = NULL;
157 if (node != NULL)
158 sysid = get_property(node, "system-id", NULL);
159
160 if (sysid == NULL)
161 seq_printf(m, "SRLNBR=<UNKNOWN>\n");
162 else
163 /* Skip "IBM," on front of serial number, see dt.c */
164 seq_printf(m, "SRLNBR=%s\n", sysid + 4);
165
166 of_node_put(node);
167
160 return 0; 168 return 0;
161} 169}
162 170
diff --git a/arch/powerpc/platforms/iseries/vpdinfo.c b/arch/powerpc/platforms/iseries/vpdinfo.c
index 23a6d1e5b429..9f83878a0c2e 100644
--- a/arch/powerpc/platforms/iseries/vpdinfo.c
+++ b/arch/powerpc/platforms/iseries/vpdinfo.c
@@ -188,7 +188,7 @@ static void __init iSeries_Parse_Vpd(u8 *VpdData, int VpdDataLen,
188{ 188{
189 u8 *TagPtr = VpdData; 189 u8 *TagPtr = VpdData;
190 int DataLen = VpdDataLen - 3; 190 int DataLen = VpdDataLen - 3;
191 u8 PhbId; 191 u8 PhbId = 0xff;
192 192
193 while ((*TagPtr != VpdEndOfAreaTag) && (DataLen > 0)) { 193 while ((*TagPtr != VpdEndOfAreaTag) && (DataLen > 0)) {
194 int AreaLen = *(TagPtr + 1) + (*(TagPtr + 2) * 256); 194 int AreaLen = *(TagPtr + 1) + (*(TagPtr + 2) * 256);
@@ -205,15 +205,16 @@ static void __init iSeries_Parse_Vpd(u8 *VpdData, int VpdDataLen,
205 } 205 }
206} 206}
207 207
208static void __init iSeries_Get_Location_Code(u16 bus, HvAgentId agent, 208static int __init iSeries_Get_Location_Code(u16 bus, HvAgentId agent,
209 u8 *frame, char card[4]) 209 u8 *frame, char card[4])
210{ 210{
211 int status = 0;
211 int BusVpdLen = 0; 212 int BusVpdLen = 0;
212 u8 *BusVpdPtr = kmalloc(BUS_VPDSIZE, GFP_KERNEL); 213 u8 *BusVpdPtr = kmalloc(BUS_VPDSIZE, GFP_KERNEL);
213 214
214 if (BusVpdPtr == NULL) { 215 if (BusVpdPtr == NULL) {
215 printk("PCI: Bus VPD Buffer allocation failure.\n"); 216 printk("PCI: Bus VPD Buffer allocation failure.\n");
216 return; 217 return 0;
217 } 218 }
218 BusVpdLen = HvCallPci_getBusVpd(bus, iseries_hv_addr(BusVpdPtr), 219 BusVpdLen = HvCallPci_getBusVpd(bus, iseries_hv_addr(BusVpdPtr),
219 BUS_VPDSIZE); 220 BUS_VPDSIZE);
@@ -228,8 +229,10 @@ static void __init iSeries_Get_Location_Code(u16 bus, HvAgentId agent,
228 goto out_free; 229 goto out_free;
229 } 230 }
230 iSeries_Parse_Vpd(BusVpdPtr, BusVpdLen, agent, frame, card); 231 iSeries_Parse_Vpd(BusVpdPtr, BusVpdLen, agent, frame, card);
232 status = 1;
231out_free: 233out_free:
232 kfree(BusVpdPtr); 234 kfree(BusVpdPtr);
235 return status;
233} 236}
234 237
235/* 238/*
@@ -246,7 +249,7 @@ void __init iSeries_Device_Information(struct pci_dev *PciDev, int count)
246 struct device_node *DevNode = PciDev->sysdata; 249 struct device_node *DevNode = PciDev->sysdata;
247 struct pci_dn *pdn; 250 struct pci_dn *pdn;
248 u16 bus; 251 u16 bus;
249 u8 frame; 252 u8 frame = 0;
250 char card[4]; 253 char card[4];
251 HvSubBusNumber subbus; 254 HvSubBusNumber subbus;
252 HvAgentId agent; 255 HvAgentId agent;
@@ -262,10 +265,11 @@ void __init iSeries_Device_Information(struct pci_dev *PciDev, int count)
262 subbus = pdn->bussubno; 265 subbus = pdn->bussubno;
263 agent = ISERIES_PCI_AGENTID(ISERIES_GET_DEVICE_FROM_SUBBUS(subbus), 266 agent = ISERIES_PCI_AGENTID(ISERIES_GET_DEVICE_FROM_SUBBUS(subbus),
264 ISERIES_GET_FUNCTION_FROM_SUBBUS(subbus)); 267 ISERIES_GET_FUNCTION_FROM_SUBBUS(subbus));
265 iSeries_Get_Location_Code(bus, agent, &frame, card);
266 268
267 printk("%d. PCI: Bus%3d, Device%3d, Vendor %04X Frame%3d, Card %4s ", 269 if (iSeries_Get_Location_Code(bus, agent, &frame, card)) {
268 count, bus, PCI_SLOT(PciDev->devfn), PciDev->vendor, 270 printk("%d. PCI: Bus%3d, Device%3d, Vendor %04X Frame%3d, "
269 frame, card); 271 "Card %4s 0x%04X\n", count, bus,
270 printk("0x%04X\n", (int)(PciDev->class >> 8)); 272 PCI_SLOT(PciDev->devfn), PciDev->vendor, frame,
273 card, (int)(PciDev->class >> 8));
274 }
271} 275}
diff --git a/arch/powerpc/platforms/maple/pci.c b/arch/powerpc/platforms/maple/pci.c
index 63a1670d3bfd..c3aa46b8e2b9 100644
--- a/arch/powerpc/platforms/maple/pci.c
+++ b/arch/powerpc/platforms/maple/pci.c
@@ -38,16 +38,16 @@ static struct pci_controller *u3_agp, *u3_ht;
38static int __init fixup_one_level_bus_range(struct device_node *node, int higher) 38static int __init fixup_one_level_bus_range(struct device_node *node, int higher)
39{ 39{
40 for (; node != 0;node = node->sibling) { 40 for (; node != 0;node = node->sibling) {
41 int * bus_range; 41 const int *bus_range;
42 unsigned int *class_code; 42 const unsigned int *class_code;
43 int len; 43 int len;
44 44
45 /* For PCI<->PCI bridges or CardBus bridges, we go down */ 45 /* For PCI<->PCI bridges or CardBus bridges, we go down */
46 class_code = (unsigned int *) get_property(node, "class-code", NULL); 46 class_code = get_property(node, "class-code", NULL);
47 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI && 47 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
48 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) 48 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS))
49 continue; 49 continue;
50 bus_range = (int *) get_property(node, "bus-range", &len); 50 bus_range = get_property(node, "bus-range", &len);
51 if (bus_range != NULL && len > 2 * sizeof(int)) { 51 if (bus_range != NULL && len > 2 * sizeof(int)) {
52 if (bus_range[1] > higher) 52 if (bus_range[1] > higher)
53 higher = bus_range[1]; 53 higher = bus_range[1];
@@ -65,30 +65,36 @@ static int __init fixup_one_level_bus_range(struct device_node *node, int higher
65 */ 65 */
66static void __init fixup_bus_range(struct device_node *bridge) 66static void __init fixup_bus_range(struct device_node *bridge)
67{ 67{
68 int * bus_range; 68 int *bus_range;
69 struct property *prop;
69 int len; 70 int len;
70 71
71 /* Lookup the "bus-range" property for the hose */ 72 /* Lookup the "bus-range" property for the hose */
72 bus_range = (int *) get_property(bridge, "bus-range", &len); 73 prop = of_find_property(bridge, "bus-range", &len);
73 if (bus_range == NULL || len < 2 * sizeof(int)) { 74 if (prop == NULL || prop->value == NULL || len < 2 * sizeof(int)) {
74 printk(KERN_WARNING "Can't get bus-range for %s\n", 75 printk(KERN_WARNING "Can't get bus-range for %s\n",
75 bridge->full_name); 76 bridge->full_name);
76 return; 77 return;
77 } 78 }
79 bus_range = (int *)prop->value;
78 bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]); 80 bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]);
79} 81}
80 82
81 83
82#define U3_AGP_CFA0(devfn, off) \ 84static unsigned long u3_agp_cfa0(u8 devfn, u8 off)
83 ((1 << (unsigned long)PCI_SLOT(dev_fn)) \ 85{
84 | (((unsigned long)PCI_FUNC(dev_fn)) << 8) \ 86 return (1 << (unsigned long)PCI_SLOT(devfn)) |
85 | (((unsigned long)(off)) & 0xFCUL)) 87 ((unsigned long)PCI_FUNC(devfn) << 8) |
88 ((unsigned long)off & 0xFCUL);
89}
86 90
87#define U3_AGP_CFA1(bus, devfn, off) \ 91static unsigned long u3_agp_cfa1(u8 bus, u8 devfn, u8 off)
88 ((((unsigned long)(bus)) << 16) \ 92{
89 |(((unsigned long)(devfn)) << 8) \ 93 return ((unsigned long)bus << 16) |
90 |(((unsigned long)(off)) & 0xFCUL) \ 94 ((unsigned long)devfn << 8) |
91 |1UL) 95 ((unsigned long)off & 0xFCUL) |
96 1UL;
97}
92 98
93static unsigned long u3_agp_cfg_access(struct pci_controller* hose, 99static unsigned long u3_agp_cfg_access(struct pci_controller* hose,
94 u8 bus, u8 dev_fn, u8 offset) 100 u8 bus, u8 dev_fn, u8 offset)
@@ -98,9 +104,9 @@ static unsigned long u3_agp_cfg_access(struct pci_controller* hose,
98 if (bus == hose->first_busno) { 104 if (bus == hose->first_busno) {
99 if (dev_fn < (11 << 3)) 105 if (dev_fn < (11 << 3))
100 return 0; 106 return 0;
101 caddr = U3_AGP_CFA0(dev_fn, offset); 107 caddr = u3_agp_cfa0(dev_fn, offset);
102 } else 108 } else
103 caddr = U3_AGP_CFA1(bus, dev_fn, offset); 109 caddr = u3_agp_cfa1(bus, dev_fn, offset);
104 110
105 /* Uninorth will return garbage if we don't read back the value ! */ 111 /* Uninorth will return garbage if we don't read back the value ! */
106 do { 112 do {
@@ -182,13 +188,15 @@ static struct pci_ops u3_agp_pci_ops =
182 u3_agp_write_config 188 u3_agp_write_config
183}; 189};
184 190
191static unsigned long u3_ht_cfa0(u8 devfn, u8 off)
192{
193 return (devfn << 8) | off;
194}
185 195
186#define U3_HT_CFA0(devfn, off) \ 196static unsigned long u3_ht_cfa1(u8 bus, u8 devfn, u8 off)
187 ((((unsigned long)devfn) << 8) | offset) 197{
188#define U3_HT_CFA1(bus, devfn, off) \ 198 return u3_ht_cfa0(devfn, off) + (bus << 16) + 0x01000000UL;
189 (U3_HT_CFA0(devfn, off) \ 199}
190 + (((unsigned long)bus) << 16) \
191 + 0x01000000UL)
192 200
193static unsigned long u3_ht_cfg_access(struct pci_controller* hose, 201static unsigned long u3_ht_cfg_access(struct pci_controller* hose,
194 u8 bus, u8 devfn, u8 offset) 202 u8 bus, u8 devfn, u8 offset)
@@ -196,9 +204,9 @@ static unsigned long u3_ht_cfg_access(struct pci_controller* hose,
196 if (bus == hose->first_busno) { 204 if (bus == hose->first_busno) {
197 if (PCI_SLOT(devfn) == 0) 205 if (PCI_SLOT(devfn) == 0)
198 return 0; 206 return 0;
199 return ((unsigned long)hose->cfg_data) + U3_HT_CFA0(devfn, offset); 207 return ((unsigned long)hose->cfg_data) + u3_ht_cfa0(devfn, offset);
200 } else 208 } else
201 return ((unsigned long)hose->cfg_data) + U3_HT_CFA1(bus, devfn, offset); 209 return ((unsigned long)hose->cfg_data) + u3_ht_cfa1(bus, devfn, offset);
202} 210}
203 211
204static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn, 212static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn,
@@ -211,6 +219,9 @@ static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn,
211 if (hose == NULL) 219 if (hose == NULL)
212 return PCIBIOS_DEVICE_NOT_FOUND; 220 return PCIBIOS_DEVICE_NOT_FOUND;
213 221
222 if (offset > 0xff)
223 return PCIBIOS_BAD_REGISTER_NUMBER;
224
214 addr = u3_ht_cfg_access(hose, bus->number, devfn, offset); 225 addr = u3_ht_cfg_access(hose, bus->number, devfn, offset);
215 if (!addr) 226 if (!addr)
216 return PCIBIOS_DEVICE_NOT_FOUND; 227 return PCIBIOS_DEVICE_NOT_FOUND;
@@ -243,6 +254,9 @@ static int u3_ht_write_config(struct pci_bus *bus, unsigned int devfn,
243 if (hose == NULL) 254 if (hose == NULL)
244 return PCIBIOS_DEVICE_NOT_FOUND; 255 return PCIBIOS_DEVICE_NOT_FOUND;
245 256
257 if (offset > 0xff)
258 return PCIBIOS_BAD_REGISTER_NUMBER;
259
246 addr = u3_ht_cfg_access(hose, bus->number, devfn, offset); 260 addr = u3_ht_cfg_access(hose, bus->number, devfn, offset);
247 if (!addr) 261 if (!addr)
248 return PCIBIOS_DEVICE_NOT_FOUND; 262 return PCIBIOS_DEVICE_NOT_FOUND;
@@ -314,12 +328,12 @@ static int __init add_bridge(struct device_node *dev)
314 int len; 328 int len;
315 struct pci_controller *hose; 329 struct pci_controller *hose;
316 char* disp_name; 330 char* disp_name;
317 int *bus_range; 331 const int *bus_range;
318 int primary = 1; 332 int primary = 1;
319 333
320 DBG("Adding PCI host bridge %s\n", dev->full_name); 334 DBG("Adding PCI host bridge %s\n", dev->full_name);
321 335
322 bus_range = (int *) get_property(dev, "bus-range", &len); 336 bus_range = get_property(dev, "bus-range", &len);
323 if (bus_range == NULL || len < 2 * sizeof(int)) { 337 if (bus_range == NULL || len < 2 * sizeof(int)) {
324 printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n", 338 printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n",
325 dev->full_name); 339 dev->full_name);
diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c
index 57567dfb9819..fe6b9bff61b9 100644
--- a/arch/powerpc/platforms/maple/setup.c
+++ b/arch/powerpc/platforms/maple/setup.c
@@ -99,8 +99,7 @@ static unsigned long maple_find_nvram_base(void)
99static void maple_restart(char *cmd) 99static void maple_restart(char *cmd)
100{ 100{
101 unsigned int maple_nvram_base; 101 unsigned int maple_nvram_base;
102 unsigned int maple_nvram_offset; 102 const unsigned int *maple_nvram_offset, *maple_nvram_command;
103 unsigned int maple_nvram_command;
104 struct device_node *sp; 103 struct device_node *sp;
105 104
106 maple_nvram_base = maple_find_nvram_base(); 105 maple_nvram_base = maple_find_nvram_base();
@@ -113,14 +112,12 @@ static void maple_restart(char *cmd)
113 printk(KERN_EMERG "Maple: Unable to find Service Processor\n"); 112 printk(KERN_EMERG "Maple: Unable to find Service Processor\n");
114 goto fail; 113 goto fail;
115 } 114 }
116 maple_nvram_offset = *(unsigned int*) get_property(sp, 115 maple_nvram_offset = get_property(sp, "restart-addr", NULL);
117 "restart-addr", NULL); 116 maple_nvram_command = get_property(sp, "restart-value", NULL);
118 maple_nvram_command = *(unsigned int*) get_property(sp,
119 "restart-value", NULL);
120 of_node_put(sp); 117 of_node_put(sp);
121 118
122 /* send command */ 119 /* send command */
123 outb_p(maple_nvram_command, maple_nvram_base + maple_nvram_offset); 120 outb_p(*maple_nvram_command, maple_nvram_base + *maple_nvram_offset);
124 for (;;) ; 121 for (;;) ;
125 fail: 122 fail:
126 printk(KERN_EMERG "Maple: Manual Restart Required\n"); 123 printk(KERN_EMERG "Maple: Manual Restart Required\n");
@@ -129,8 +126,7 @@ static void maple_restart(char *cmd)
129static void maple_power_off(void) 126static void maple_power_off(void)
130{ 127{
131 unsigned int maple_nvram_base; 128 unsigned int maple_nvram_base;
132 unsigned int maple_nvram_offset; 129 const unsigned int *maple_nvram_offset, *maple_nvram_command;
133 unsigned int maple_nvram_command;
134 struct device_node *sp; 130 struct device_node *sp;
135 131
136 maple_nvram_base = maple_find_nvram_base(); 132 maple_nvram_base = maple_find_nvram_base();
@@ -143,14 +139,12 @@ static void maple_power_off(void)
143 printk(KERN_EMERG "Maple: Unable to find Service Processor\n"); 139 printk(KERN_EMERG "Maple: Unable to find Service Processor\n");
144 goto fail; 140 goto fail;
145 } 141 }
146 maple_nvram_offset = *(unsigned int*) get_property(sp, 142 maple_nvram_offset = get_property(sp, "power-off-addr", NULL);
147 "power-off-addr", NULL); 143 maple_nvram_command = get_property(sp, "power-off-value", NULL);
148 maple_nvram_command = *(unsigned int*) get_property(sp,
149 "power-off-value", NULL);
150 of_node_put(sp); 144 of_node_put(sp);
151 145
152 /* send command */ 146 /* send command */
153 outb_p(maple_nvram_command, maple_nvram_base + maple_nvram_offset); 147 outb_p(*maple_nvram_command, maple_nvram_base + *maple_nvram_offset);
154 for (;;) ; 148 for (;;) ;
155 fail: 149 fail:
156 printk(KERN_EMERG "Maple: Manual Power-Down Required\n"); 150 printk(KERN_EMERG "Maple: Manual Power-Down Required\n");
@@ -211,7 +205,7 @@ static void __init maple_init_early(void)
211static void __init maple_init_IRQ(void) 205static void __init maple_init_IRQ(void)
212{ 206{
213 struct device_node *root, *np, *mpic_node = NULL; 207 struct device_node *root, *np, *mpic_node = NULL;
214 unsigned int *opprop; 208 const unsigned int *opprop;
215 unsigned long openpic_addr = 0; 209 unsigned long openpic_addr = 0;
216 int naddr, n, i, opplen, has_isus = 0; 210 int naddr, n, i, opplen, has_isus = 0;
217 struct mpic *mpic; 211 struct mpic *mpic;
@@ -241,8 +235,7 @@ static void __init maple_init_IRQ(void)
241 /* Find address list in /platform-open-pic */ 235 /* Find address list in /platform-open-pic */
242 root = of_find_node_by_path("/"); 236 root = of_find_node_by_path("/");
243 naddr = prom_n_addr_cells(root); 237 naddr = prom_n_addr_cells(root);
244 opprop = (unsigned int *) get_property(root, "platform-open-pic", 238 opprop = get_property(root, "platform-open-pic", &opplen);
245 &opplen);
246 if (opprop != 0) { 239 if (opprop != 0) {
247 openpic_addr = of_read_number(opprop, naddr); 240 openpic_addr = of_read_number(opprop, naddr);
248 has_isus = (opplen > naddr); 241 has_isus = (opplen > naddr);
diff --git a/arch/powerpc/platforms/pasemi/Makefile b/arch/powerpc/platforms/pasemi/Makefile
new file mode 100644
index 000000000000..1be1a993c5f5
--- /dev/null
+++ b/arch/powerpc/platforms/pasemi/Makefile
@@ -0,0 +1 @@
obj-y += setup.o pci.o time.o
diff --git a/arch/powerpc/platforms/pasemi/pasemi.h b/arch/powerpc/platforms/pasemi/pasemi.h
new file mode 100644
index 000000000000..fd71d72736b2
--- /dev/null
+++ b/arch/powerpc/platforms/pasemi/pasemi.h
@@ -0,0 +1,8 @@
1#ifndef _PASEMI_PASEMI_H
2#define _PASEMI_PASEMI_H
3
4extern unsigned long pas_get_boot_time(void);
5extern void pas_pci_init(void);
6extern void pas_pcibios_fixup(void);
7
8#endif /* _PASEMI_PASEMI_H */
diff --git a/arch/powerpc/platforms/pasemi/pci.c b/arch/powerpc/platforms/pasemi/pci.c
new file mode 100644
index 000000000000..4679c5230413
--- /dev/null
+++ b/arch/powerpc/platforms/pasemi/pci.c
@@ -0,0 +1,198 @@
1/*
2 * Copyright (C) 2006 PA Semi, Inc
3 *
4 * Authors: Kip Walker, PA Semi
5 * Olof Johansson, PA Semi
6 *
7 * Maintained by: Olof Johansson <olof@lixom.net>
8 *
9 * Based on arch/powerpc/platforms/maple/pci.c
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25
26#include <linux/kernel.h>
27#include <linux/pci.h>
28
29#include <asm/pci-bridge.h>
30#include <asm/machdep.h>
31
32#include <asm/ppc-pci.h>
33
34#define PA_PXP_CFA(bus, devfn, off) (((bus) << 20) | ((devfn) << 12) | (off))
35
36#define CONFIG_OFFSET_VALID(off) ((off) < 4096)
37
38static unsigned long pa_pxp_cfg_addr(struct pci_controller *hose,
39 u8 bus, u8 devfn, int offset)
40{
41 return ((unsigned long)hose->cfg_data) + PA_PXP_CFA(bus, devfn, offset);
42}
43
44static int pa_pxp_read_config(struct pci_bus *bus, unsigned int devfn,
45 int offset, int len, u32 *val)
46{
47 struct pci_controller *hose;
48 unsigned long addr;
49
50 hose = pci_bus_to_host(bus);
51 if (!hose)
52 return PCIBIOS_DEVICE_NOT_FOUND;
53
54 if (!CONFIG_OFFSET_VALID(offset))
55 return PCIBIOS_BAD_REGISTER_NUMBER;
56
57 addr = pa_pxp_cfg_addr(hose, bus->number, devfn, offset);
58
59 /*
60 * Note: the caller has already checked that offset is
61 * suitably aligned and that len is 1, 2 or 4.
62 */
63 switch (len) {
64 case 1:
65 *val = in_8((u8 *)addr);
66 break;
67 case 2:
68 *val = in_le16((u16 *)addr);
69 break;
70 default:
71 *val = in_le32((u32 *)addr);
72 break;
73 }
74
75 return PCIBIOS_SUCCESSFUL;
76}
77
78static int pa_pxp_write_config(struct pci_bus *bus, unsigned int devfn,
79 int offset, int len, u32 val)
80{
81 struct pci_controller *hose;
82 unsigned long addr;
83
84 hose = pci_bus_to_host(bus);
85 if (!hose)
86 return PCIBIOS_DEVICE_NOT_FOUND;
87
88 if (!CONFIG_OFFSET_VALID(offset))
89 return PCIBIOS_BAD_REGISTER_NUMBER;
90
91 addr = pa_pxp_cfg_addr(hose, bus->number, devfn, offset);
92
93 /*
94 * Note: the caller has already checked that offset is
95 * suitably aligned and that len is 1, 2 or 4.
96 */
97 switch (len) {
98 case 1:
99 out_8((u8 *)addr, val);
100 (void) in_8((u8 *)addr);
101 break;
102 case 2:
103 out_le16((u16 *)addr, val);
104 (void) in_le16((u16 *)addr);
105 break;
106 default:
107 out_le32((u32 *)addr, val);
108 (void) in_le32((u32 *)addr);
109 break;
110 }
111 return PCIBIOS_SUCCESSFUL;
112}
113
114static struct pci_ops pa_pxp_ops = {
115 pa_pxp_read_config,
116 pa_pxp_write_config,
117};
118
119static void __init setup_pa_pxp(struct pci_controller *hose)
120{
121 hose->ops = &pa_pxp_ops;
122 hose->cfg_data = ioremap(0xe0000000, 0x10000000);
123}
124
125static int __init add_bridge(struct device_node *dev)
126{
127 struct pci_controller *hose;
128
129 pr_debug("Adding PCI host bridge %s\n", dev->full_name);
130
131 hose = pcibios_alloc_controller(dev);
132 if (!hose)
133 return -ENOMEM;
134
135 hose->first_busno = 0;
136 hose->last_busno = 0xff;
137
138 setup_pa_pxp(hose);
139
140 printk(KERN_INFO "Found PA-PXP PCI host bridge.\n");
141
142 /* Interpret the "ranges" property */
143 /* This also maps the I/O region and sets isa_io/mem_base */
144 pci_process_bridge_OF_ranges(hose, dev, 1);
145 pci_setup_phb_io(hose, 1);
146
147 return 0;
148}
149
150
151void __init pas_pcibios_fixup(void)
152{
153 struct pci_dev *dev = NULL;
154
155 for_each_pci_dev(dev)
156 pci_read_irq_line(dev);
157}
158
159static void __init pas_fixup_phb_resources(void)
160{
161 struct pci_controller *hose, *tmp;
162
163 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
164 unsigned long offset = (unsigned long)hose->io_base_virt - pci_io_base;
165 hose->io_resource.start += offset;
166 hose->io_resource.end += offset;
167 printk(KERN_INFO "PCI Host %d, io start: %lx; io end: %lx\n",
168 hose->global_number,
169 hose->io_resource.start, hose->io_resource.end);
170 }
171}
172
173
174void __init pas_pci_init(void)
175{
176 struct device_node *np, *root;
177
178 root = of_find_node_by_path("/");
179 if (!root) {
180 printk(KERN_CRIT "pas_pci_init: can't find root "
181 "of device tree\n");
182 return;
183 }
184
185 for (np = NULL; (np = of_get_next_child(root, np)) != NULL;)
186 if (np->name && !strcmp(np->name, "pxp") && !add_bridge(np))
187 of_node_get(np);
188
189 of_node_put(root);
190
191 pas_fixup_phb_resources();
192
193 /* Setup the linkage between OF nodes and PHBs */
194 pci_devs_phb_init();
195
196 /* Use the common resource allocation mechanism */
197 pci_probe_only = 1;
198}
diff --git a/arch/powerpc/platforms/pasemi/setup.c b/arch/powerpc/platforms/pasemi/setup.c
new file mode 100644
index 000000000000..628482671c15
--- /dev/null
+++ b/arch/powerpc/platforms/pasemi/setup.c
@@ -0,0 +1,188 @@
1/*
2 * Copyright (C) 2006 PA Semi, Inc
3 *
4 * Authors: Kip Walker, PA Semi
5 * Olof Johansson, PA Semi
6 *
7 * Maintained by: Olof Johansson <olof@lixom.net>
8 *
9 * Based on arch/powerpc/platforms/maple/setup.c
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#include <linux/config.h>
26#include <linux/errno.h>
27#include <linux/kernel.h>
28#include <linux/delay.h>
29#include <linux/console.h>
30
31#include <asm/prom.h>
32#include <asm/system.h>
33#include <asm/iommu.h>
34#include <asm/machdep.h>
35#include <asm/mpic.h>
36#include <asm/smp.h>
37#include <asm/time.h>
38
39#include "pasemi.h"
40
41static void pas_restart(char *cmd)
42{
43 printk("restart unimplemented, looping...\n");
44 for (;;) ;
45}
46
47static void pas_power_off(void)
48{
49 printk("power off unimplemented, looping...\n");
50 for (;;) ;
51}
52
53static void pas_halt(void)
54{
55 pas_power_off();
56}
57
58#ifdef CONFIG_SMP
59struct smp_ops_t pas_smp_ops = {
60 .probe = smp_mpic_probe,
61 .message_pass = smp_mpic_message_pass,
62 .kick_cpu = smp_generic_kick_cpu,
63 .setup_cpu = smp_mpic_setup_cpu,
64 .give_timebase = smp_generic_give_timebase,
65 .take_timebase = smp_generic_take_timebase,
66};
67#endif /* CONFIG_SMP */
68
69void __init pas_setup_arch(void)
70{
71#ifdef CONFIG_SMP
72 /* Setup SMP callback */
73 smp_ops = &pas_smp_ops;
74#endif
75 /* Lookup PCI hosts */
76 pas_pci_init();
77
78#ifdef CONFIG_DUMMY_CONSOLE
79 conswitchp = &dummy_con;
80#endif
81
82 printk(KERN_DEBUG "Using default idle loop\n");
83}
84
85static void iommu_dev_setup_null(struct pci_dev *dev) { }
86static void iommu_bus_setup_null(struct pci_bus *bus) { }
87
88static void __init pas_init_early(void)
89{
90 /* No iommu code yet */
91 ppc_md.iommu_dev_setup = iommu_dev_setup_null;
92 ppc_md.iommu_bus_setup = iommu_bus_setup_null;
93 pci_direct_iommu_init();
94}
95
96/* No legacy IO on our parts */
97static int pas_check_legacy_ioport(unsigned int baseport)
98{
99 return -ENODEV;
100}
101
102static __init void pas_init_IRQ(void)
103{
104 struct device_node *np;
105 struct device_node *root, *mpic_node;
106 unsigned long openpic_addr;
107 const unsigned int *opprop;
108 int naddr, opplen;
109 struct mpic *mpic;
110
111 mpic_node = NULL;
112
113 for_each_node_by_type(np, "interrupt-controller")
114 if (device_is_compatible(np, "open-pic")) {
115 mpic_node = np;
116 break;
117 }
118 if (!mpic_node)
119 for_each_node_by_type(np, "open-pic") {
120 mpic_node = np;
121 break;
122 }
123 if (!mpic_node) {
124 printk(KERN_ERR
125 "Failed to locate the MPIC interrupt controller\n");
126 return;
127 }
128
129 /* Find address list in /platform-open-pic */
130 root = of_find_node_by_path("/");
131 naddr = prom_n_addr_cells(root);
132 opprop = get_property(root, "platform-open-pic", &opplen);
133 if (!opprop) {
134 printk(KERN_ERR "No platform-open-pic property.\n");
135 of_node_put(root);
136 return;
137 }
138 openpic_addr = of_read_number(opprop, naddr);
139 printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr);
140 of_node_put(root);
141
142 mpic = mpic_alloc(mpic_node, openpic_addr, MPIC_PRIMARY, 0, 0,
143 " PAS-OPIC ");
144 BUG_ON(!mpic);
145
146 mpic_assign_isu(mpic, 0, openpic_addr + 0x10000);
147 mpic_init(mpic);
148 of_node_put(mpic_node);
149 of_node_put(root);
150}
151
152static void __init pas_progress(char *s, unsigned short hex)
153{
154 printk("[%04x] : %s\n", hex, s ? s : "");
155}
156
157
158/*
159 * Called very early, MMU is off, device-tree isn't unflattened
160 */
161static int __init pas_probe(void)
162{
163 unsigned long root = of_get_flat_dt_root();
164
165 if (!of_flat_dt_is_compatible(root, "PA6T-1682M"))
166 return 0;
167
168 hpte_init_native();
169
170 return 1;
171}
172
173define_machine(pas) {
174 .name = "PA Semi PA6T-1682M",
175 .probe = pas_probe,
176 .setup_arch = pas_setup_arch,
177 .init_early = pas_init_early,
178 .init_IRQ = pas_init_IRQ,
179 .get_irq = mpic_get_irq,
180 .pcibios_fixup = pas_pcibios_fixup,
181 .restart = pas_restart,
182 .power_off = pas_power_off,
183 .halt = pas_halt,
184 .get_boot_time = pas_get_boot_time,
185 .calibrate_decr = generic_calibrate_decr,
186 .check_legacy_ioport = pas_check_legacy_ioport,
187 .progress = pas_progress,
188};
diff --git a/arch/powerpc/platforms/pasemi/time.c b/arch/powerpc/platforms/pasemi/time.c
new file mode 100644
index 000000000000..9bd410b8fec6
--- /dev/null
+++ b/arch/powerpc/platforms/pasemi/time.c
@@ -0,0 +1,29 @@
1/*
2 * Copyright (C) 2006 PA Semi, Inc
3 *
4 * Maintained by: Olof Johansson <olof@lixom.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/config.h>
21#include <linux/time.h>
22
23#include <asm/time.h>
24
25unsigned long __init pas_get_boot_time(void)
26{
27 /* Let's just return a fake date right now */
28 return mktime(2006, 1, 1, 12, 0, 0);
29}
diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c
index d66415491055..afa593a8544a 100644
--- a/arch/powerpc/platforms/powermac/backlight.c
+++ b/arch/powerpc/platforms/powermac/backlight.c
@@ -60,7 +60,8 @@ int pmac_has_backlight_type(const char *type)
60 struct device_node* bk_node = find_devices("backlight"); 60 struct device_node* bk_node = find_devices("backlight");
61 61
62 if (bk_node) { 62 if (bk_node) {
63 char *prop = get_property(bk_node, "backlight-control", NULL); 63 const char *prop = get_property(bk_node,
64 "backlight-control", NULL);
64 if (prop && strncmp(prop, type, strlen(type)) == 0) 65 if (prop && strncmp(prop, type, strlen(type)) == 0)
65 return 1; 66 return 1;
66 } 67 }
diff --git a/arch/powerpc/platforms/powermac/cpufreq_32.c b/arch/powerpc/platforms/powermac/cpufreq_32.c
index 62926248bdb8..c2b6b4134f68 100644
--- a/arch/powerpc/platforms/powermac/cpufreq_32.c
+++ b/arch/powerpc/platforms/powermac/cpufreq_32.c
@@ -421,7 +421,7 @@ static int pmac_cpufreq_cpu_init(struct cpufreq_policy *policy)
421 421
422static u32 read_gpio(struct device_node *np) 422static u32 read_gpio(struct device_node *np)
423{ 423{
424 u32 *reg = (u32 *)get_property(np, "reg", NULL); 424 const u32 *reg = get_property(np, "reg", NULL);
425 u32 offset; 425 u32 offset;
426 426
427 if (reg == NULL) 427 if (reg == NULL)
@@ -497,7 +497,7 @@ static int pmac_cpufreq_init_MacRISC3(struct device_node *cpunode)
497 "frequency-gpio"); 497 "frequency-gpio");
498 struct device_node *slew_done_gpio_np = of_find_node_by_name(NULL, 498 struct device_node *slew_done_gpio_np = of_find_node_by_name(NULL,
499 "slewing-done"); 499 "slewing-done");
500 u32 *value; 500 const u32 *value;
501 501
502 /* 502 /*
503 * Check to see if it's GPIO driven or PMU only 503 * Check to see if it's GPIO driven or PMU only
@@ -519,15 +519,15 @@ static int pmac_cpufreq_init_MacRISC3(struct device_node *cpunode)
519 */ 519 */
520 if (frequency_gpio && slew_done_gpio) { 520 if (frequency_gpio && slew_done_gpio) {
521 int lenp, rc; 521 int lenp, rc;
522 u32 *freqs, *ratio; 522 const u32 *freqs, *ratio;
523 523
524 freqs = (u32 *)get_property(cpunode, "bus-frequencies", &lenp); 524 freqs = get_property(cpunode, "bus-frequencies", &lenp);
525 lenp /= sizeof(u32); 525 lenp /= sizeof(u32);
526 if (freqs == NULL || lenp != 2) { 526 if (freqs == NULL || lenp != 2) {
527 printk(KERN_ERR "cpufreq: bus-frequencies incorrect or missing\n"); 527 printk(KERN_ERR "cpufreq: bus-frequencies incorrect or missing\n");
528 return 1; 528 return 1;
529 } 529 }
530 ratio = (u32 *)get_property(cpunode, "processor-to-bus-ratio*2", NULL); 530 ratio = get_property(cpunode, "processor-to-bus-ratio*2", NULL);
531 if (ratio == NULL) { 531 if (ratio == NULL) {
532 printk(KERN_ERR "cpufreq: processor-to-bus-ratio*2 missing\n"); 532 printk(KERN_ERR "cpufreq: processor-to-bus-ratio*2 missing\n");
533 return 1; 533 return 1;
@@ -562,7 +562,7 @@ static int pmac_cpufreq_init_MacRISC3(struct device_node *cpunode)
562 /* If we use the PMU, look for the min & max frequencies in the 562 /* If we use the PMU, look for the min & max frequencies in the
563 * device-tree 563 * device-tree
564 */ 564 */
565 value = (u32 *)get_property(cpunode, "min-clock-frequency", NULL); 565 value = get_property(cpunode, "min-clock-frequency", NULL);
566 if (!value) 566 if (!value)
567 return 1; 567 return 1;
568 low_freq = (*value) / 1000; 568 low_freq = (*value) / 1000;
@@ -571,7 +571,7 @@ static int pmac_cpufreq_init_MacRISC3(struct device_node *cpunode)
571 if (low_freq < 100000) 571 if (low_freq < 100000)
572 low_freq *= 10; 572 low_freq *= 10;
573 573
574 value = (u32 *)get_property(cpunode, "max-clock-frequency", NULL); 574 value = get_property(cpunode, "max-clock-frequency", NULL);
575 if (!value) 575 if (!value)
576 return 1; 576 return 1;
577 hi_freq = (*value) / 1000; 577 hi_freq = (*value) / 1000;
@@ -611,13 +611,14 @@ static int pmac_cpufreq_init_7447A(struct device_node *cpunode)
611static int pmac_cpufreq_init_750FX(struct device_node *cpunode) 611static int pmac_cpufreq_init_750FX(struct device_node *cpunode)
612{ 612{
613 struct device_node *volt_gpio_np; 613 struct device_node *volt_gpio_np;
614 u32 pvr, *value; 614 u32 pvr;
615 const u32 *value;
615 616
616 if (get_property(cpunode, "dynamic-power-step", NULL) == NULL) 617 if (get_property(cpunode, "dynamic-power-step", NULL) == NULL)
617 return 1; 618 return 1;
618 619
619 hi_freq = cur_freq; 620 hi_freq = cur_freq;
620 value = (u32 *)get_property(cpunode, "reduced-clock-frequency", NULL); 621 value = get_property(cpunode, "reduced-clock-frequency", NULL);
621 if (!value) 622 if (!value)
622 return 1; 623 return 1;
623 low_freq = (*value) / 1000; 624 low_freq = (*value) / 1000;
@@ -650,7 +651,7 @@ static int pmac_cpufreq_init_750FX(struct device_node *cpunode)
650static int __init pmac_cpufreq_setup(void) 651static int __init pmac_cpufreq_setup(void)
651{ 652{
652 struct device_node *cpunode; 653 struct device_node *cpunode;
653 u32 *value; 654 const u32 *value;
654 655
655 if (strstr(cmd_line, "nocpufreq")) 656 if (strstr(cmd_line, "nocpufreq"))
656 return 0; 657 return 0;
@@ -661,7 +662,7 @@ static int __init pmac_cpufreq_setup(void)
661 goto out; 662 goto out;
662 663
663 /* Get current cpu clock freq */ 664 /* Get current cpu clock freq */
664 value = (u32 *)get_property(cpunode, "clock-frequency", NULL); 665 value = get_property(cpunode, "clock-frequency", NULL);
665 if (!value) 666 if (!value)
666 goto out; 667 goto out;
667 cur_freq = (*value) / 1000; 668 cur_freq = (*value) / 1000;
diff --git a/arch/powerpc/platforms/powermac/cpufreq_64.c b/arch/powerpc/platforms/powermac/cpufreq_64.c
index 7b1156ea5341..d30466d74194 100644
--- a/arch/powerpc/platforms/powermac/cpufreq_64.c
+++ b/arch/powerpc/platforms/powermac/cpufreq_64.c
@@ -89,7 +89,7 @@ static DEFINE_MUTEX(g5_switch_mutex);
89 89
90#ifdef CONFIG_PMAC_SMU 90#ifdef CONFIG_PMAC_SMU
91 91
92static u32 *g5_pmode_data; 92static const u32 *g5_pmode_data;
93static int g5_pmode_max; 93static int g5_pmode_max;
94 94
95static struct smu_sdbp_fvt *g5_fvt_table; /* table of op. points */ 95static struct smu_sdbp_fvt *g5_fvt_table; /* table of op. points */
@@ -391,7 +391,8 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
391 unsigned int psize, ssize; 391 unsigned int psize, ssize;
392 unsigned long max_freq; 392 unsigned long max_freq;
393 char *freq_method, *volt_method; 393 char *freq_method, *volt_method;
394 u32 *valp, pvr_hi; 394 const u32 *valp;
395 u32 pvr_hi;
395 int use_volts_vdnap = 0; 396 int use_volts_vdnap = 0;
396 int use_volts_smu = 0; 397 int use_volts_smu = 0;
397 int rc = -ENODEV; 398 int rc = -ENODEV;
@@ -409,8 +410,7 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
409 /* Get first CPU node */ 410 /* Get first CPU node */
410 for (cpunode = NULL; 411 for (cpunode = NULL;
411 (cpunode = of_get_next_child(cpus, cpunode)) != NULL;) { 412 (cpunode = of_get_next_child(cpus, cpunode)) != NULL;) {
412 u32 *reg = 413 const u32 *reg = get_property(cpunode, "reg", NULL);
413 (u32 *)get_property(cpunode, "reg", NULL);
414 if (reg == NULL || (*reg) != 0) 414 if (reg == NULL || (*reg) != 0)
415 continue; 415 continue;
416 if (!strcmp(cpunode->type, "cpu")) 416 if (!strcmp(cpunode->type, "cpu"))
@@ -422,7 +422,7 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
422 } 422 }
423 423
424 /* Check 970FX for now */ 424 /* Check 970FX for now */
425 valp = (u32 *)get_property(cpunode, "cpu-version", NULL); 425 valp = get_property(cpunode, "cpu-version", NULL);
426 if (!valp) { 426 if (!valp) {
427 DBG("No cpu-version property !\n"); 427 DBG("No cpu-version property !\n");
428 goto bail_noprops; 428 goto bail_noprops;
@@ -434,7 +434,7 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
434 } 434 }
435 435
436 /* Look for the powertune data in the device-tree */ 436 /* Look for the powertune data in the device-tree */
437 g5_pmode_data = (u32 *)get_property(cpunode, "power-mode-data",&psize); 437 g5_pmode_data = get_property(cpunode, "power-mode-data",&psize);
438 if (!g5_pmode_data) { 438 if (!g5_pmode_data) {
439 DBG("No power-mode-data !\n"); 439 DBG("No power-mode-data !\n");
440 goto bail_noprops; 440 goto bail_noprops;
@@ -442,7 +442,7 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
442 g5_pmode_max = psize / sizeof(u32) - 1; 442 g5_pmode_max = psize / sizeof(u32) - 1;
443 443
444 if (use_volts_smu) { 444 if (use_volts_smu) {
445 struct smu_sdbp_header *shdr; 445 const struct smu_sdbp_header *shdr;
446 446
447 /* Look for the FVT table */ 447 /* Look for the FVT table */
448 shdr = smu_get_sdb_partition(SMU_SDB_FVT_ID, NULL); 448 shdr = smu_get_sdb_partition(SMU_SDB_FVT_ID, NULL);
@@ -493,7 +493,7 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
493 * half freq in this version. So far, I haven't yet seen a machine 493 * half freq in this version. So far, I haven't yet seen a machine
494 * supporting anything else. 494 * supporting anything else.
495 */ 495 */
496 valp = (u32 *)get_property(cpunode, "clock-frequency", NULL); 496 valp = get_property(cpunode, "clock-frequency", NULL);
497 if (!valp) 497 if (!valp)
498 return -ENODEV; 498 return -ENODEV;
499 max_freq = (*valp)/1000; 499 max_freq = (*valp)/1000;
@@ -541,8 +541,8 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
541static int __init g5_pm72_cpufreq_init(struct device_node *cpus) 541static int __init g5_pm72_cpufreq_init(struct device_node *cpus)
542{ 542{
543 struct device_node *cpuid = NULL, *hwclock = NULL, *cpunode = NULL; 543 struct device_node *cpuid = NULL, *hwclock = NULL, *cpunode = NULL;
544 u8 *eeprom = NULL; 544 const u8 *eeprom = NULL;
545 u32 *valp; 545 const u32 *valp;
546 u64 max_freq, min_freq, ih, il; 546 u64 max_freq, min_freq, ih, il;
547 int has_volt = 1, rc = 0; 547 int has_volt = 1, rc = 0;
548 548
@@ -563,7 +563,7 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpus)
563 /* Lookup the cpuid eeprom node */ 563 /* Lookup the cpuid eeprom node */
564 cpuid = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/cpuid@a0"); 564 cpuid = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/cpuid@a0");
565 if (cpuid != NULL) 565 if (cpuid != NULL)
566 eeprom = (u8 *)get_property(cpuid, "cpuid", NULL); 566 eeprom = get_property(cpuid, "cpuid", NULL);
567 if (eeprom == NULL) { 567 if (eeprom == NULL) {
568 printk(KERN_ERR "cpufreq: Can't find cpuid EEPROM !\n"); 568 printk(KERN_ERR "cpufreq: Can't find cpuid EEPROM !\n");
569 rc = -ENODEV; 569 rc = -ENODEV;
@@ -573,7 +573,8 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpus)
573 /* Lookup the i2c hwclock */ 573 /* Lookup the i2c hwclock */
574 for (hwclock = NULL; 574 for (hwclock = NULL;
575 (hwclock = of_find_node_by_name(hwclock, "i2c-hwclock")) != NULL;){ 575 (hwclock = of_find_node_by_name(hwclock, "i2c-hwclock")) != NULL;){
576 char *loc = get_property(hwclock, "hwctrl-location", NULL); 576 const char *loc = get_property(hwclock,
577 "hwctrl-location", NULL);
577 if (loc == NULL) 578 if (loc == NULL)
578 continue; 579 continue;
579 if (strcmp(loc, "CPU CLOCK")) 580 if (strcmp(loc, "CPU CLOCK"))
@@ -637,7 +638,7 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpus)
637 */ 638 */
638 639
639 /* Get max frequency from device-tree */ 640 /* Get max frequency from device-tree */
640 valp = (u32 *)get_property(cpunode, "clock-frequency", NULL); 641 valp = get_property(cpunode, "clock-frequency", NULL);
641 if (!valp) { 642 if (!valp) {
642 printk(KERN_ERR "cpufreq: Can't find CPU frequency !\n"); 643 printk(KERN_ERR "cpufreq: Can't find CPU frequency !\n");
643 rc = -ENODEV; 644 rc = -ENODEV;
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c
index f8313bf9a9f7..13fcaf5b1796 100644
--- a/arch/powerpc/platforms/powermac/feature.c
+++ b/arch/powerpc/platforms/powermac/feature.c
@@ -1058,8 +1058,8 @@ core99_reset_cpu(struct device_node *node, long param, long value)
1058 if (np == NULL) 1058 if (np == NULL)
1059 return -ENODEV; 1059 return -ENODEV;
1060 for (np = np->child; np != NULL; np = np->sibling) { 1060 for (np = np->child; np != NULL; np = np->sibling) {
1061 u32 *num = (u32 *)get_property(np, "reg", NULL); 1061 u32 *num = get_property(np, "reg", NULL);
1062 u32 *rst = (u32 *)get_property(np, "soft-reset", NULL); 1062 u32 *rst = get_property(np, "soft-reset", NULL);
1063 if (num == NULL || rst == NULL) 1063 if (num == NULL || rst == NULL)
1064 continue; 1064 continue;
1065 if (param == *num) { 1065 if (param == *num) {
@@ -1087,7 +1087,7 @@ core99_usb_enable(struct device_node *node, long param, long value)
1087{ 1087{
1088 struct macio_chip *macio; 1088 struct macio_chip *macio;
1089 unsigned long flags; 1089 unsigned long flags;
1090 char *prop; 1090 const char *prop;
1091 int number; 1091 int number;
1092 u32 reg; 1092 u32 reg;
1093 1093
@@ -1096,7 +1096,7 @@ core99_usb_enable(struct device_node *node, long param, long value)
1096 macio->type != macio_intrepid) 1096 macio->type != macio_intrepid)
1097 return -ENODEV; 1097 return -ENODEV;
1098 1098
1099 prop = (char *)get_property(node, "AAPL,clock-id", NULL); 1099 prop = get_property(node, "AAPL,clock-id", NULL);
1100 if (!prop) 1100 if (!prop)
1101 return -ENODEV; 1101 return -ENODEV;
1102 if (strncmp(prop, "usb0u048", 8) == 0) 1102 if (strncmp(prop, "usb0u048", 8) == 0)
@@ -1507,8 +1507,8 @@ static long g5_reset_cpu(struct device_node *node, long param, long value)
1507 if (np == NULL) 1507 if (np == NULL)
1508 return -ENODEV; 1508 return -ENODEV;
1509 for (np = np->child; np != NULL; np = np->sibling) { 1509 for (np = np->child; np != NULL; np = np->sibling) {
1510 u32 *num = (u32 *)get_property(np, "reg", NULL); 1510 const u32 *num = get_property(np, "reg", NULL);
1511 u32 *rst = (u32 *)get_property(np, "soft-reset", NULL); 1511 const u32 *rst = get_property(np, "soft-reset", NULL);
1512 if (num == NULL || rst == NULL) 1512 if (num == NULL || rst == NULL)
1513 continue; 1513 continue;
1514 if (param == *num) { 1514 if (param == *num) {
@@ -2408,7 +2408,7 @@ static int __init probe_motherboard(void)
2408 */ 2408 */
2409 dt = find_devices("device-tree"); 2409 dt = find_devices("device-tree");
2410 if (dt != NULL) 2410 if (dt != NULL)
2411 model = (const char *) get_property(dt, "model", NULL); 2411 model = get_property(dt, "model", NULL);
2412 for(i=0; model && i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) { 2412 for(i=0; model && i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) {
2413 if (strcmp(model, pmac_mb_defs[i].model_string) == 0) { 2413 if (strcmp(model, pmac_mb_defs[i].model_string) == 0) {
2414 pmac_mb = pmac_mb_defs[i]; 2414 pmac_mb = pmac_mb_defs[i];
@@ -2536,7 +2536,7 @@ found:
2536 */ 2536 */
2537static void __init probe_uninorth(void) 2537static void __init probe_uninorth(void)
2538{ 2538{
2539 u32 *addrp; 2539 const u32 *addrp;
2540 phys_addr_t address; 2540 phys_addr_t address;
2541 unsigned long actrl; 2541 unsigned long actrl;
2542 2542
@@ -2555,7 +2555,7 @@ static void __init probe_uninorth(void)
2555 if (uninorth_node == NULL) 2555 if (uninorth_node == NULL)
2556 return; 2556 return;
2557 2557
2558 addrp = (u32 *)get_property(uninorth_node, "reg", NULL); 2558 addrp = get_property(uninorth_node, "reg", NULL);
2559 if (addrp == NULL) 2559 if (addrp == NULL)
2560 return; 2560 return;
2561 address = of_translate_address(uninorth_node, addrp); 2561 address = of_translate_address(uninorth_node, addrp);
@@ -2596,7 +2596,7 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ
2596 struct device_node* node; 2596 struct device_node* node;
2597 int i; 2597 int i;
2598 volatile u32 __iomem *base; 2598 volatile u32 __iomem *base;
2599 u32 *addrp, *revp; 2599 const u32 *addrp, *revp;
2600 phys_addr_t addr; 2600 phys_addr_t addr;
2601 u64 size; 2601 u64 size;
2602 2602
@@ -2639,7 +2639,7 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ
2639 return; 2639 return;
2640 } 2640 }
2641 if (type == macio_keylargo || type == macio_keylargo2) { 2641 if (type == macio_keylargo || type == macio_keylargo2) {
2642 u32 *did = (u32 *)get_property(node, "device-id", NULL); 2642 const u32 *did = get_property(node, "device-id", NULL);
2643 if (*did == 0x00000025) 2643 if (*did == 0x00000025)
2644 type = macio_pangea; 2644 type = macio_pangea;
2645 if (*did == 0x0000003e) 2645 if (*did == 0x0000003e)
@@ -2652,7 +2652,7 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ
2652 macio_chips[i].base = base; 2652 macio_chips[i].base = base;
2653 macio_chips[i].flags = MACIO_FLAG_SCCB_ON | MACIO_FLAG_SCCB_ON; 2653 macio_chips[i].flags = MACIO_FLAG_SCCB_ON | MACIO_FLAG_SCCB_ON;
2654 macio_chips[i].name = macio_names[type]; 2654 macio_chips[i].name = macio_names[type];
2655 revp = (u32 *)get_property(node, "revision-id", NULL); 2655 revp = get_property(node, "revision-id", NULL);
2656 if (revp) 2656 if (revp)
2657 macio_chips[i].rev = *revp; 2657 macio_chips[i].rev = *revp;
2658 printk(KERN_INFO "Found a %s mac-io controller, rev: %d, mapped at 0x%p\n", 2658 printk(KERN_INFO "Found a %s mac-io controller, rev: %d, mapped at 0x%p\n",
@@ -2695,15 +2695,15 @@ static void __init
2695initial_serial_shutdown(struct device_node *np) 2695initial_serial_shutdown(struct device_node *np)
2696{ 2696{
2697 int len; 2697 int len;
2698 struct slot_names_prop { 2698 const struct slot_names_prop {
2699 int count; 2699 int count;
2700 char name[1]; 2700 char name[1];
2701 } *slots; 2701 } *slots;
2702 char *conn; 2702 const char *conn;
2703 int port_type = PMAC_SCC_ASYNC; 2703 int port_type = PMAC_SCC_ASYNC;
2704 int modem = 0; 2704 int modem = 0;
2705 2705
2706 slots = (struct slot_names_prop *)get_property(np, "slot-names", &len); 2706 slots = get_property(np, "slot-names", &len);
2707 conn = get_property(np, "AAPL,connector", &len); 2707 conn = get_property(np, "AAPL,connector", &len);
2708 if (conn && (strcmp(conn, "infrared") == 0)) 2708 if (conn && (strcmp(conn, "infrared") == 0))
2709 port_type = PMAC_SCC_IRDA; 2709 port_type = PMAC_SCC_IRDA;
diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c
index 8677f50c2586..c2c7cf75dd5f 100644
--- a/arch/powerpc/platforms/powermac/low_i2c.c
+++ b/arch/powerpc/platforms/powermac/low_i2c.c
@@ -477,7 +477,8 @@ static int kw_i2c_xfer(struct pmac_i2c_bus *bus, u8 addrdir, int subsize,
477static struct pmac_i2c_host_kw *__init kw_i2c_host_init(struct device_node *np) 477static struct pmac_i2c_host_kw *__init kw_i2c_host_init(struct device_node *np)
478{ 478{
479 struct pmac_i2c_host_kw *host; 479 struct pmac_i2c_host_kw *host;
480 u32 *psteps, *prate, *addrp, steps; 480 const u32 *psteps, *prate, *addrp;
481 u32 steps;
481 482
482 host = kzalloc(sizeof(struct pmac_i2c_host_kw), GFP_KERNEL); 483 host = kzalloc(sizeof(struct pmac_i2c_host_kw), GFP_KERNEL);
483 if (host == NULL) { 484 if (host == NULL) {
@@ -490,7 +491,7 @@ static struct pmac_i2c_host_kw *__init kw_i2c_host_init(struct device_node *np)
490 * on all i2c keywest nodes so far ... we would have to fallback 491 * on all i2c keywest nodes so far ... we would have to fallback
491 * to macio parsing if that wasn't the case 492 * to macio parsing if that wasn't the case
492 */ 493 */
493 addrp = (u32 *)get_property(np, "AAPL,address", NULL); 494 addrp = get_property(np, "AAPL,address", NULL);
494 if (addrp == NULL) { 495 if (addrp == NULL) {
495 printk(KERN_ERR "low_i2c: Can't find address for %s\n", 496 printk(KERN_ERR "low_i2c: Can't find address for %s\n",
496 np->full_name); 497 np->full_name);
@@ -504,13 +505,13 @@ static struct pmac_i2c_host_kw *__init kw_i2c_host_init(struct device_node *np)
504 host->timeout_timer.function = kw_i2c_timeout; 505 host->timeout_timer.function = kw_i2c_timeout;
505 host->timeout_timer.data = (unsigned long)host; 506 host->timeout_timer.data = (unsigned long)host;
506 507
507 psteps = (u32 *)get_property(np, "AAPL,address-step", NULL); 508 psteps = get_property(np, "AAPL,address-step", NULL);
508 steps = psteps ? (*psteps) : 0x10; 509 steps = psteps ? (*psteps) : 0x10;
509 for (host->bsteps = 0; (steps & 0x01) == 0; host->bsteps++) 510 for (host->bsteps = 0; (steps & 0x01) == 0; host->bsteps++)
510 steps >>= 1; 511 steps >>= 1;
511 /* Select interface rate */ 512 /* Select interface rate */
512 host->speed = KW_I2C_MODE_25KHZ; 513 host->speed = KW_I2C_MODE_25KHZ;
513 prate = (u32 *)get_property(np, "AAPL,i2c-rate", NULL); 514 prate = get_property(np, "AAPL,i2c-rate", NULL);
514 if (prate) switch(*prate) { 515 if (prate) switch(*prate) {
515 case 100: 516 case 100:
516 host->speed = KW_I2C_MODE_100KHZ; 517 host->speed = KW_I2C_MODE_100KHZ;
@@ -618,8 +619,8 @@ static void __init kw_i2c_probe(void)
618 } else { 619 } else {
619 for (child = NULL; 620 for (child = NULL;
620 (child = of_get_next_child(np, child)) != NULL;) { 621 (child = of_get_next_child(np, child)) != NULL;) {
621 u32 *reg = 622 const u32 *reg = get_property(child,
622 (u32 *)get_property(child, "reg", NULL); 623 "reg", NULL);
623 if (reg == NULL) 624 if (reg == NULL)
624 continue; 625 continue;
625 kw_i2c_add(host, np, child, *reg); 626 kw_i2c_add(host, np, child, *reg);
@@ -881,7 +882,7 @@ static void __init smu_i2c_probe(void)
881{ 882{
882 struct device_node *controller, *busnode; 883 struct device_node *controller, *busnode;
883 struct pmac_i2c_bus *bus; 884 struct pmac_i2c_bus *bus;
884 u32 *reg; 885 const u32 *reg;
885 int sz; 886 int sz;
886 887
887 if (!smu_present()) 888 if (!smu_present())
@@ -904,7 +905,7 @@ static void __init smu_i2c_probe(void)
904 if (strcmp(busnode->type, "i2c") && 905 if (strcmp(busnode->type, "i2c") &&
905 strcmp(busnode->type, "i2c-bus")) 906 strcmp(busnode->type, "i2c-bus"))
906 continue; 907 continue;
907 reg = (u32 *)get_property(busnode, "reg", NULL); 908 reg = get_property(busnode, "reg", NULL);
908 if (reg == NULL) 909 if (reg == NULL)
909 continue; 910 continue;
910 911
@@ -948,9 +949,8 @@ struct pmac_i2c_bus *pmac_i2c_find_bus(struct device_node *node)
948 list_for_each_entry(bus, &pmac_i2c_busses, link) { 949 list_for_each_entry(bus, &pmac_i2c_busses, link) {
949 if (p == bus->busnode) { 950 if (p == bus->busnode) {
950 if (prev && bus->flags & pmac_i2c_multibus) { 951 if (prev && bus->flags & pmac_i2c_multibus) {
951 u32 *reg; 952 const u32 *reg;
952 reg = (u32 *)get_property(prev, "reg", 953 reg = get_property(prev, "reg", NULL);
953 NULL);
954 if (!reg) 954 if (!reg)
955 continue; 955 continue;
956 if (((*reg) >> 8) != bus->channel) 956 if (((*reg) >> 8) != bus->channel)
@@ -971,7 +971,7 @@ EXPORT_SYMBOL_GPL(pmac_i2c_find_bus);
971 971
972u8 pmac_i2c_get_dev_addr(struct device_node *device) 972u8 pmac_i2c_get_dev_addr(struct device_node *device)
973{ 973{
974 u32 *reg = (u32 *)get_property(device, "reg", NULL); 974 const u32 *reg = get_property(device, "reg", NULL);
975 975
976 if (reg == NULL) 976 if (reg == NULL)
977 return 0; 977 return 0;
diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c
index 205d04471161..9923adc5248e 100644
--- a/arch/powerpc/platforms/powermac/pci.c
+++ b/arch/powerpc/platforms/powermac/pci.c
@@ -66,16 +66,16 @@ struct device_node *k2_skiplist[2];
66static int __init fixup_one_level_bus_range(struct device_node *node, int higher) 66static int __init fixup_one_level_bus_range(struct device_node *node, int higher)
67{ 67{
68 for (; node != 0;node = node->sibling) { 68 for (; node != 0;node = node->sibling) {
69 int * bus_range; 69 const int * bus_range;
70 unsigned int *class_code; 70 const unsigned int *class_code;
71 int len; 71 int len;
72 72
73 /* For PCI<->PCI bridges or CardBus bridges, we go down */ 73 /* For PCI<->PCI bridges or CardBus bridges, we go down */
74 class_code = (unsigned int *) get_property(node, "class-code", NULL); 74 class_code = get_property(node, "class-code", NULL);
75 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI && 75 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
76 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) 76 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS))
77 continue; 77 continue;
78 bus_range = (int *) get_property(node, "bus-range", &len); 78 bus_range = get_property(node, "bus-range", &len);
79 if (bus_range != NULL && len > 2 * sizeof(int)) { 79 if (bus_range != NULL && len > 2 * sizeof(int)) {
80 if (bus_range[1] > higher) 80 if (bus_range[1] > higher)
81 higher = bus_range[1]; 81 higher = bus_range[1];
@@ -93,13 +93,15 @@ static int __init fixup_one_level_bus_range(struct device_node *node, int higher
93 */ 93 */
94static void __init fixup_bus_range(struct device_node *bridge) 94static void __init fixup_bus_range(struct device_node *bridge)
95{ 95{
96 int * bus_range; 96 int *bus_range, len;
97 int len; 97 struct property *prop;
98 98
99 /* Lookup the "bus-range" property for the hose */ 99 /* Lookup the "bus-range" property for the hose */
100 bus_range = (int *) get_property(bridge, "bus-range", &len); 100 prop = of_find_property(bridge, "bus-range", &len);
101 if (bus_range == NULL || len < 2 * sizeof(int)) 101 if (prop == NULL || prop->length < 2 * sizeof(int))
102 return; 102 return;
103
104 bus_range = (int *)prop->value;
103 bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]); 105 bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]);
104} 106}
105 107
@@ -237,7 +239,7 @@ static struct pci_ops macrisc_pci_ops =
237static int chaos_validate_dev(struct pci_bus *bus, int devfn, int offset) 239static int chaos_validate_dev(struct pci_bus *bus, int devfn, int offset)
238{ 240{
239 struct device_node *np; 241 struct device_node *np;
240 u32 *vendor, *device; 242 const u32 *vendor, *device;
241 243
242 if (offset >= 0x100) 244 if (offset >= 0x100)
243 return PCIBIOS_BAD_REGISTER_NUMBER; 245 return PCIBIOS_BAD_REGISTER_NUMBER;
@@ -245,8 +247,8 @@ static int chaos_validate_dev(struct pci_bus *bus, int devfn, int offset)
245 if (np == NULL) 247 if (np == NULL)
246 return PCIBIOS_DEVICE_NOT_FOUND; 248 return PCIBIOS_DEVICE_NOT_FOUND;
247 249
248 vendor = (u32 *)get_property(np, "vendor-id", NULL); 250 vendor = get_property(np, "vendor-id", NULL);
249 device = (u32 *)get_property(np, "device-id", NULL); 251 device = get_property(np, "device-id", NULL);
250 if (vendor == NULL || device == NULL) 252 if (vendor == NULL || device == NULL)
251 return PCIBIOS_DEVICE_NOT_FOUND; 253 return PCIBIOS_DEVICE_NOT_FOUND;
252 254
@@ -686,20 +688,21 @@ static void __init fixup_nec_usb2(void)
686 688
687 for (nec = NULL; (nec = of_find_node_by_name(nec, "usb")) != NULL;) { 689 for (nec = NULL; (nec = of_find_node_by_name(nec, "usb")) != NULL;) {
688 struct pci_controller *hose; 690 struct pci_controller *hose;
689 u32 data, *prop; 691 u32 data;
692 const u32 *prop;
690 u8 bus, devfn; 693 u8 bus, devfn;
691 694
692 prop = (u32 *)get_property(nec, "vendor-id", NULL); 695 prop = get_property(nec, "vendor-id", NULL);
693 if (prop == NULL) 696 if (prop == NULL)
694 continue; 697 continue;
695 if (0x1033 != *prop) 698 if (0x1033 != *prop)
696 continue; 699 continue;
697 prop = (u32 *)get_property(nec, "device-id", NULL); 700 prop = get_property(nec, "device-id", NULL);
698 if (prop == NULL) 701 if (prop == NULL)
699 continue; 702 continue;
700 if (0x0035 != *prop) 703 if (0x0035 != *prop)
701 continue; 704 continue;
702 prop = (u32 *)get_property(nec, "reg", NULL); 705 prop = get_property(nec, "reg", NULL);
703 if (prop == NULL) 706 if (prop == NULL)
704 continue; 707 continue;
705 devfn = (prop[0] >> 8) & 0xff; 708 devfn = (prop[0] >> 8) & 0xff;
@@ -898,7 +901,7 @@ static int __init add_bridge(struct device_node *dev)
898 struct pci_controller *hose; 901 struct pci_controller *hose;
899 struct resource rsrc; 902 struct resource rsrc;
900 char *disp_name; 903 char *disp_name;
901 int *bus_range; 904 const int *bus_range;
902 int primary = 1, has_address = 0; 905 int primary = 1, has_address = 0;
903 906
904 DBG("Adding PCI host bridge %s\n", dev->full_name); 907 DBG("Adding PCI host bridge %s\n", dev->full_name);
@@ -907,7 +910,7 @@ static int __init add_bridge(struct device_node *dev)
907 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0); 910 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
908 911
909 /* Get bus range if any */ 912 /* Get bus range if any */
910 bus_range = (int *) get_property(dev, "bus-range", &len); 913 bus_range = get_property(dev, "bus-range", &len);
911 if (bus_range == NULL || len < 2 * sizeof(int)) { 914 if (bus_range == NULL || len < 2 * sizeof(int)) {
912 printk(KERN_WARNING "Can't get bus-range for %s, assume" 915 printk(KERN_WARNING "Can't get bus-range for %s, assume"
913 " bus 0\n", dev->full_name); 916 " bus 0\n", dev->full_name);
diff --git a/arch/powerpc/platforms/powermac/pfunc_base.c b/arch/powerpc/platforms/powermac/pfunc_base.c
index aacfa59595d1..ee3b223ab17a 100644
--- a/arch/powerpc/platforms/powermac/pfunc_base.c
+++ b/arch/powerpc/platforms/powermac/pfunc_base.c
@@ -114,7 +114,7 @@ static void macio_gpio_init_one(struct macio_chip *macio)
114 * we just create them all 114 * we just create them all
115 */ 115 */
116 for (gp = NULL; (gp = of_get_next_child(gparent, gp)) != NULL;) { 116 for (gp = NULL; (gp = of_get_next_child(gparent, gp)) != NULL;) {
117 u32 *reg = (u32 *)get_property(gp, "reg", NULL); 117 const u32 *reg = get_property(gp, "reg", NULL);
118 unsigned long offset; 118 unsigned long offset;
119 if (reg == NULL) 119 if (reg == NULL)
120 continue; 120 continue;
diff --git a/arch/powerpc/platforms/powermac/pfunc_core.c b/arch/powerpc/platforms/powermac/pfunc_core.c
index b117adbf9571..7651f278615a 100644
--- a/arch/powerpc/platforms/powermac/pfunc_core.c
+++ b/arch/powerpc/platforms/powermac/pfunc_core.c
@@ -813,14 +813,15 @@ struct pmf_function *__pmf_find_function(struct device_node *target,
813 struct pmf_device *dev; 813 struct pmf_device *dev;
814 struct pmf_function *func, *result = NULL; 814 struct pmf_function *func, *result = NULL;
815 char fname[64]; 815 char fname[64];
816 u32 *prop, ph; 816 const u32 *prop;
817 u32 ph;
817 818
818 /* 819 /*
819 * Look for a "platform-*" function reference. If we can't find 820 * Look for a "platform-*" function reference. If we can't find
820 * one, then we fallback to a direct call attempt 821 * one, then we fallback to a direct call attempt
821 */ 822 */
822 snprintf(fname, 63, "platform-%s", name); 823 snprintf(fname, 63, "platform-%s", name);
823 prop = (u32 *)get_property(target, fname, NULL); 824 prop = get_property(target, fname, NULL);
824 if (prop == NULL) 825 if (prop == NULL)
825 goto find_it; 826 goto find_it;
826 ph = *prop; 827 ph = *prop;
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index 31a9da769fa2..824a618396ab 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -116,7 +116,7 @@ extern struct smp_ops_t core99_smp_ops;
116static void pmac_show_cpuinfo(struct seq_file *m) 116static void pmac_show_cpuinfo(struct seq_file *m)
117{ 117{
118 struct device_node *np; 118 struct device_node *np;
119 char *pp; 119 const char *pp;
120 int plen; 120 int plen;
121 int mbmodel; 121 int mbmodel;
122 unsigned int mbflags; 122 unsigned int mbflags;
@@ -134,12 +134,12 @@ static void pmac_show_cpuinfo(struct seq_file *m)
134 seq_printf(m, "machine\t\t: "); 134 seq_printf(m, "machine\t\t: ");
135 np = of_find_node_by_path("/"); 135 np = of_find_node_by_path("/");
136 if (np != NULL) { 136 if (np != NULL) {
137 pp = (char *) get_property(np, "model", NULL); 137 pp = get_property(np, "model", NULL);
138 if (pp != NULL) 138 if (pp != NULL)
139 seq_printf(m, "%s\n", pp); 139 seq_printf(m, "%s\n", pp);
140 else 140 else
141 seq_printf(m, "PowerMac\n"); 141 seq_printf(m, "PowerMac\n");
142 pp = (char *) get_property(np, "compatible", &plen); 142 pp = get_property(np, "compatible", &plen);
143 if (pp != NULL) { 143 if (pp != NULL) {
144 seq_printf(m, "motherboard\t:"); 144 seq_printf(m, "motherboard\t:");
145 while (plen > 0) { 145 while (plen > 0) {
@@ -163,10 +163,8 @@ static void pmac_show_cpuinfo(struct seq_file *m)
163 if (np == NULL) 163 if (np == NULL)
164 np = of_find_node_by_type(NULL, "cache"); 164 np = of_find_node_by_type(NULL, "cache");
165 if (np != NULL) { 165 if (np != NULL) {
166 unsigned int *ic = (unsigned int *) 166 const unsigned int *ic = get_property(np, "i-cache-size", NULL);
167 get_property(np, "i-cache-size", NULL); 167 const unsigned int *dc = get_property(np, "d-cache-size", NULL);
168 unsigned int *dc = (unsigned int *)
169 get_property(np, "d-cache-size", NULL);
170 seq_printf(m, "L2 cache\t:"); 168 seq_printf(m, "L2 cache\t:");
171 has_l2cache = 1; 169 has_l2cache = 1;
172 if (get_property(np, "cache-unified", NULL) != 0 && dc) { 170 if (get_property(np, "cache-unified", NULL) != 0 && dc) {
@@ -254,7 +252,7 @@ static void __init l2cr_init(void)
254 if (np == 0) 252 if (np == 0)
255 np = find_type_devices("cpu"); 253 np = find_type_devices("cpu");
256 if (np != 0) { 254 if (np != 0) {
257 unsigned int *l2cr = (unsigned int *) 255 const unsigned int *l2cr =
258 get_property(np, "l2cr-value", NULL); 256 get_property(np, "l2cr-value", NULL);
259 if (l2cr != 0) { 257 if (l2cr != 0) {
260 ppc_override_l2cr = 1; 258 ppc_override_l2cr = 1;
@@ -277,7 +275,7 @@ static void __init l2cr_init(void)
277static void __init pmac_setup_arch(void) 275static void __init pmac_setup_arch(void)
278{ 276{
279 struct device_node *cpu, *ic; 277 struct device_node *cpu, *ic;
280 int *fp; 278 const int *fp;
281 unsigned long pvr; 279 unsigned long pvr;
282 280
283 pvr = PVR_VER(mfspr(SPRN_PVR)); 281 pvr = PVR_VER(mfspr(SPRN_PVR));
@@ -287,7 +285,7 @@ static void __init pmac_setup_arch(void)
287 loops_per_jiffy = 50000000 / HZ; 285 loops_per_jiffy = 50000000 / HZ;
288 cpu = of_find_node_by_type(NULL, "cpu"); 286 cpu = of_find_node_by_type(NULL, "cpu");
289 if (cpu != NULL) { 287 if (cpu != NULL) {
290 fp = (int *) get_property(cpu, "clock-frequency", NULL); 288 fp = get_property(cpu, "clock-frequency", NULL);
291 if (fp != NULL) { 289 if (fp != NULL) {
292 if (pvr >= 0x30 && pvr < 0x80) 290 if (pvr >= 0x30 && pvr < 0x80)
293 /* PPC970 etc. */ 291 /* PPC970 etc. */
diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
index 827b7121ffb8..653eeb64d1e2 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -548,7 +548,7 @@ static void __init smp_core99_setup_i2c_hwsync(int ncpus)
548 struct device_node *cc = NULL; 548 struct device_node *cc = NULL;
549 struct device_node *p; 549 struct device_node *p;
550 const char *name = NULL; 550 const char *name = NULL;
551 u32 *reg; 551 const u32 *reg;
552 int ok; 552 int ok;
553 553
554 /* Look for the clock chip */ 554 /* Look for the clock chip */
@@ -562,7 +562,7 @@ static void __init smp_core99_setup_i2c_hwsync(int ncpus)
562 pmac_tb_clock_chip_host = pmac_i2c_find_bus(cc); 562 pmac_tb_clock_chip_host = pmac_i2c_find_bus(cc);
563 if (pmac_tb_clock_chip_host == NULL) 563 if (pmac_tb_clock_chip_host == NULL)
564 continue; 564 continue;
565 reg = (u32 *)get_property(cc, "reg", NULL); 565 reg = get_property(cc, "reg", NULL);
566 if (reg == NULL) 566 if (reg == NULL)
567 continue; 567 continue;
568 switch (*reg) { 568 switch (*reg) {
@@ -707,8 +707,7 @@ static void __init smp_core99_setup(int ncpus)
707 core99_tb_gpio = KL_GPIO_TB_ENABLE; /* default value */ 707 core99_tb_gpio = KL_GPIO_TB_ENABLE; /* default value */
708 cpu = of_find_node_by_type(NULL, "cpu"); 708 cpu = of_find_node_by_type(NULL, "cpu");
709 if (cpu != NULL) { 709 if (cpu != NULL) {
710 tbprop = (u32 *)get_property(cpu, "timebase-enable", 710 tbprop = get_property(cpu, "timebase-enable", NULL);
711 NULL);
712 if (tbprop) 711 if (tbprop)
713 core99_tb_gpio = *tbprop; 712 core99_tb_gpio = *tbprop;
714 of_node_put(cpu); 713 of_node_put(cpu);
diff --git a/arch/powerpc/platforms/powermac/udbg_scc.c b/arch/powerpc/platforms/powermac/udbg_scc.c
index 37e5b1eff911..ce1a235855f7 100644
--- a/arch/powerpc/platforms/powermac/udbg_scc.c
+++ b/arch/powerpc/platforms/powermac/udbg_scc.c
@@ -68,11 +68,11 @@ static unsigned char scc_inittab[] = {
68 68
69void udbg_scc_init(int force_scc) 69void udbg_scc_init(int force_scc)
70{ 70{
71 u32 *reg; 71 const u32 *reg;
72 unsigned long addr; 72 unsigned long addr;
73 struct device_node *stdout = NULL, *escc = NULL, *macio = NULL; 73 struct device_node *stdout = NULL, *escc = NULL, *macio = NULL;
74 struct device_node *ch, *ch_def = NULL, *ch_a = NULL; 74 struct device_node *ch, *ch_def = NULL, *ch_a = NULL;
75 char *path; 75 const char *path;
76 int i, x; 76 int i, x;
77 77
78 escc = of_find_node_by_name(NULL, "escc"); 78 escc = of_find_node_by_name(NULL, "escc");
@@ -81,7 +81,7 @@ void udbg_scc_init(int force_scc)
81 macio = of_get_parent(escc); 81 macio = of_get_parent(escc);
82 if (macio == NULL) 82 if (macio == NULL)
83 goto bail; 83 goto bail;
84 path = (char *)get_property(of_chosen, "linux,stdout-path", NULL); 84 path = get_property(of_chosen, "linux,stdout-path", NULL);
85 if (path != NULL) 85 if (path != NULL)
86 stdout = of_find_node_by_path(path); 86 stdout = of_find_node_by_path(path);
87 for (ch = NULL; (ch = of_get_next_child(escc, ch)) != NULL;) { 87 for (ch = NULL; (ch = of_get_next_child(escc, ch)) != NULL;) {
@@ -96,13 +96,13 @@ void udbg_scc_init(int force_scc)
96 ch = ch_def ? ch_def : ch_a; 96 ch = ch_def ? ch_def : ch_a;
97 97
98 /* Get address within mac-io ASIC */ 98 /* Get address within mac-io ASIC */
99 reg = (u32 *)get_property(escc, "reg", NULL); 99 reg = get_property(escc, "reg", NULL);
100 if (reg == NULL) 100 if (reg == NULL)
101 goto bail; 101 goto bail;
102 addr = reg[0]; 102 addr = reg[0];
103 103
104 /* Get address of mac-io PCI itself */ 104 /* Get address of mac-io PCI itself */
105 reg = (u32 *)get_property(macio, "assigned-addresses", NULL); 105 reg = get_property(macio, "assigned-addresses", NULL);
106 if (reg == NULL) 106 if (reg == NULL)
107 goto bail; 107 goto bail;
108 addr += reg[2]; 108 addr += reg[2];
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile
index e5e0ff466904..997243a91be8 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_EEH) += eeh.o eeh_cache.o eeh_driver.o eeh_event.o
12 12
13obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o 13obj-$(CONFIG_HVC_CONSOLE) += hvconsole.o
14obj-$(CONFIG_HVCS) += hvcserver.o 14obj-$(CONFIG_HVCS) += hvcserver.o
15obj-$(CONFIG_HCALL_STATS) += hvCall_inst.o
diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c
index 32eaddfa5470..84bc8f7e17ef 100644
--- a/arch/powerpc/platforms/pseries/eeh.c
+++ b/arch/powerpc/platforms/pseries/eeh.c
@@ -449,7 +449,11 @@ EXPORT_SYMBOL(eeh_check_failure);
449/* ------------------------------------------------------------- */ 449/* ------------------------------------------------------------- */
450/* The code below deals with error recovery */ 450/* The code below deals with error recovery */
451 451
452/** Return negative value if a permanent error, else return 452/**
453 * eeh_slot_availability - returns error status of slot
454 * @pdn pci device node
455 *
456 * Return negative value if a permanent error, else return
453 * a number of milliseconds to wait until the PCI slot is 457 * a number of milliseconds to wait until the PCI slot is
454 * ready to be used. 458 * ready to be used.
455 */ 459 */
@@ -474,11 +478,42 @@ eeh_slot_availability(struct pci_dn *pdn)
474 478
475 printk (KERN_ERR "EEH: Slot unavailable: rc=%d, rets=%d %d %d\n", 479 printk (KERN_ERR "EEH: Slot unavailable: rc=%d, rets=%d %d %d\n",
476 rc, rets[0], rets[1], rets[2]); 480 rc, rets[0], rets[1], rets[2]);
477 return -1; 481 return -2;
482}
483
484/**
485 * rtas_pci_enable - enable MMIO or DMA transfers for this slot
486 * @pdn pci device node
487 */
488
489int
490rtas_pci_enable(struct pci_dn *pdn, int function)
491{
492 int config_addr;
493 int rc;
494
495 /* Use PE configuration address, if present */
496 config_addr = pdn->eeh_config_addr;
497 if (pdn->eeh_pe_config_addr)
498 config_addr = pdn->eeh_pe_config_addr;
499
500 rc = rtas_call(ibm_set_eeh_option, 4, 1, NULL,
501 config_addr,
502 BUID_HI(pdn->phb->buid),
503 BUID_LO(pdn->phb->buid),
504 function);
505
506 if (rc)
507 printk(KERN_WARNING "EEH: Cannot enable function %d, err=%d dn=%s\n",
508 function, rc, pdn->node->full_name);
509
510 return rc;
478} 511}
479 512
480/** rtas_pci_slot_reset raises/lowers the pci #RST line 513/**
481 * state: 1/0 to raise/lower the #RST 514 * rtas_pci_slot_reset - raises/lowers the pci #RST line
515 * @pdn pci device node
516 * @state: 1/0 to raise/lower the #RST
482 * 517 *
483 * Clear the EEH-frozen condition on a slot. This routine 518 * Clear the EEH-frozen condition on a slot. This routine
484 * asserts the PCI #RST line if the 'state' argument is '1', 519 * asserts the PCI #RST line if the 'state' argument is '1',
@@ -511,24 +546,21 @@ rtas_pci_slot_reset(struct pci_dn *pdn, int state)
511 BUID_HI(pdn->phb->buid), 546 BUID_HI(pdn->phb->buid),
512 BUID_LO(pdn->phb->buid), 547 BUID_LO(pdn->phb->buid),
513 state); 548 state);
514 if (rc) { 549 if (rc)
515 printk (KERN_WARNING "EEH: Unable to reset the failed slot, (%d) #RST=%d dn=%s\n", 550 printk (KERN_WARNING "EEH: Unable to reset the failed slot,"
551 " (%d) #RST=%d dn=%s\n",
516 rc, state, pdn->node->full_name); 552 rc, state, pdn->node->full_name);
517 return;
518 }
519} 553}
520 554
521/** rtas_set_slot_reset -- assert the pci #RST line for 1/4 second 555/**
522 * dn -- device node to be reset. 556 * rtas_set_slot_reset -- assert the pci #RST line for 1/4 second
557 * @pdn: pci device node to be reset.
523 * 558 *
524 * Return 0 if success, else a non-zero value. 559 * Return 0 if success, else a non-zero value.
525 */ 560 */
526 561
527int 562static void __rtas_set_slot_reset(struct pci_dn *pdn)
528rtas_set_slot_reset(struct pci_dn *pdn)
529{ 563{
530 int i, rc;
531
532 rtas_pci_slot_reset (pdn, 1); 564 rtas_pci_slot_reset (pdn, 1);
533 565
534 /* The PCI bus requires that the reset be held high for at least 566 /* The PCI bus requires that the reset be held high for at least
@@ -549,17 +581,33 @@ rtas_set_slot_reset(struct pci_dn *pdn)
549 * up traffic. */ 581 * up traffic. */
550#define PCI_BUS_SETTLE_TIME_MSEC 1800 582#define PCI_BUS_SETTLE_TIME_MSEC 1800
551 msleep (PCI_BUS_SETTLE_TIME_MSEC); 583 msleep (PCI_BUS_SETTLE_TIME_MSEC);
584}
585
586int rtas_set_slot_reset(struct pci_dn *pdn)
587{
588 int i, rc;
589
590 __rtas_set_slot_reset(pdn);
552 591
553 /* Now double check with the firmware to make sure the device is 592 /* Now double check with the firmware to make sure the device is
554 * ready to be used; if not, wait for recovery. */ 593 * ready to be used; if not, wait for recovery. */
555 for (i=0; i<10; i++) { 594 for (i=0; i<10; i++) {
556 rc = eeh_slot_availability (pdn); 595 rc = eeh_slot_availability (pdn);
557 if (rc < 0)
558 printk (KERN_ERR "EEH: failed (%d) to reset slot %s\n", rc, pdn->node->full_name);
559 if (rc == 0) 596 if (rc == 0)
560 return 0; 597 return 0;
561 if (rc < 0) 598
599 if (rc == -2) {
600 printk (KERN_ERR "EEH: failed (%d) to reset slot %s\n",
601 i, pdn->node->full_name);
602 __rtas_set_slot_reset(pdn);
603 continue;
604 }
605
606 if (rc < 0) {
607 printk (KERN_ERR "EEH: unrecoverable slot failure %s\n",
608 pdn->node->full_name);
562 return -1; 609 return -1;
610 }
563 611
564 msleep (rc+100); 612 msleep (rc+100);
565 } 613 }
@@ -582,6 +630,8 @@ rtas_set_slot_reset(struct pci_dn *pdn)
582 630
583/** 631/**
584 * __restore_bars - Restore the Base Address Registers 632 * __restore_bars - Restore the Base Address Registers
633 * @pdn: pci device node
634 *
585 * Loads the PCI configuration space base address registers, 635 * Loads the PCI configuration space base address registers,
586 * the expansion ROM base address, the latency timer, and etc. 636 * the expansion ROM base address, the latency timer, and etc.
587 * from the saved values in the device node. 637 * from the saved values in the device node.
@@ -691,11 +741,11 @@ static void *early_enable_eeh(struct device_node *dn, void *data)
691{ 741{
692 struct eeh_early_enable_info *info = data; 742 struct eeh_early_enable_info *info = data;
693 int ret; 743 int ret;
694 char *status = get_property(dn, "status", NULL); 744 const char *status = get_property(dn, "status", NULL);
695 u32 *class_code = (u32 *)get_property(dn, "class-code", NULL); 745 const u32 *class_code = get_property(dn, "class-code", NULL);
696 u32 *vendor_id = (u32 *)get_property(dn, "vendor-id", NULL); 746 const u32 *vendor_id = get_property(dn, "vendor-id", NULL);
697 u32 *device_id = (u32 *)get_property(dn, "device-id", NULL); 747 const u32 *device_id = get_property(dn, "device-id", NULL);
698 u32 *regs; 748 const u32 *regs;
699 int enable; 749 int enable;
700 struct pci_dn *pdn = PCI_DN(dn); 750 struct pci_dn *pdn = PCI_DN(dn);
701 751
@@ -737,7 +787,7 @@ static void *early_enable_eeh(struct device_node *dn, void *data)
737 787
738 /* Ok... see if this device supports EEH. Some do, some don't, 788 /* Ok... see if this device supports EEH. Some do, some don't,
739 * and the only way to find out is to check each and every one. */ 789 * and the only way to find out is to check each and every one. */
740 regs = (u32 *)get_property(dn, "reg", NULL); 790 regs = get_property(dn, "reg", NULL);
741 if (regs) { 791 if (regs) {
742 /* First register entry is addr (00BBSS00) */ 792 /* First register entry is addr (00BBSS00) */
743 /* Try to enable eeh */ 793 /* Try to enable eeh */
diff --git a/arch/powerpc/platforms/pseries/eeh_cache.c b/arch/powerpc/platforms/pseries/eeh_cache.c
index c37a8497c60f..b6b462d3c604 100644
--- a/arch/powerpc/platforms/pseries/eeh_cache.c
+++ b/arch/powerpc/platforms/pseries/eeh_cache.c
@@ -157,6 +157,7 @@ pci_addr_cache_insert(struct pci_dev *dev, unsigned long alo,
157 if (!piar) 157 if (!piar)
158 return NULL; 158 return NULL;
159 159
160 pci_dev_get(dev);
160 piar->addr_lo = alo; 161 piar->addr_lo = alo;
161 piar->addr_hi = ahi; 162 piar->addr_hi = ahi;
162 piar->pcidev = dev; 163 piar->pcidev = dev;
@@ -178,7 +179,6 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev)
178 struct device_node *dn; 179 struct device_node *dn;
179 struct pci_dn *pdn; 180 struct pci_dn *pdn;
180 int i; 181 int i;
181 int inserted = 0;
182 182
183 dn = pci_device_to_OF_node(dev); 183 dn = pci_device_to_OF_node(dev);
184 if (!dn) { 184 if (!dn) {
@@ -197,9 +197,6 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev)
197 return; 197 return;
198 } 198 }
199 199
200 /* The cache holds a reference to the device... */
201 pci_dev_get(dev);
202
203 /* Walk resources on this device, poke them into the tree */ 200 /* Walk resources on this device, poke them into the tree */
204 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 201 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) {
205 unsigned long start = pci_resource_start(dev,i); 202 unsigned long start = pci_resource_start(dev,i);
@@ -212,12 +209,7 @@ static void __pci_addr_cache_insert_device(struct pci_dev *dev)
212 if (start == 0 || ~start == 0 || end == 0 || ~end == 0) 209 if (start == 0 || ~start == 0 || end == 0 || ~end == 0)
213 continue; 210 continue;
214 pci_addr_cache_insert(dev, start, end, flags); 211 pci_addr_cache_insert(dev, start, end, flags);
215 inserted = 1;
216 } 212 }
217
218 /* If there was nothing to add, the cache has no reference... */
219 if (!inserted)
220 pci_dev_put(dev);
221} 213}
222 214
223/** 215/**
@@ -240,7 +232,6 @@ void pci_addr_cache_insert_device(struct pci_dev *dev)
240static inline void __pci_addr_cache_remove_device(struct pci_dev *dev) 232static inline void __pci_addr_cache_remove_device(struct pci_dev *dev)
241{ 233{
242 struct rb_node *n; 234 struct rb_node *n;
243 int removed = 0;
244 235
245restart: 236restart:
246 n = rb_first(&pci_io_addr_cache_root.rb_root); 237 n = rb_first(&pci_io_addr_cache_root.rb_root);
@@ -250,16 +241,12 @@ restart:
250 241
251 if (piar->pcidev == dev) { 242 if (piar->pcidev == dev) {
252 rb_erase(n, &pci_io_addr_cache_root.rb_root); 243 rb_erase(n, &pci_io_addr_cache_root.rb_root);
253 removed = 1; 244 pci_dev_put(piar->pcidev);
254 kfree(piar); 245 kfree(piar);
255 goto restart; 246 goto restart;
256 } 247 }
257 n = rb_next(n); 248 n = rb_next(n);
258 } 249 }
259
260 /* The cache no longer holds its reference to this device... */
261 if (removed)
262 pci_dev_put(dev);
263} 250}
264 251
265/** 252/**
diff --git a/arch/powerpc/platforms/pseries/eeh_driver.c b/arch/powerpc/platforms/pseries/eeh_driver.c
index aaad2c0afcbf..c2bc9904f1cb 100644
--- a/arch/powerpc/platforms/pseries/eeh_driver.c
+++ b/arch/powerpc/platforms/pseries/eeh_driver.c
@@ -77,8 +77,12 @@ static int irq_in_use(unsigned int irq)
77} 77}
78 78
79/* ------------------------------------------------------- */ 79/* ------------------------------------------------------- */
80/** eeh_report_error - report an EEH error to each device, 80/**
81 * collect up and merge the device responses. 81 * eeh_report_error - report pci error to each device driver
82 *
83 * Report an EEH error to each device driver, collect up and
84 * merge the device driver responses. Cumulative response
85 * passed back in "userdata".
82 */ 86 */
83 87
84static void eeh_report_error(struct pci_dev *dev, void *userdata) 88static void eeh_report_error(struct pci_dev *dev, void *userdata)
@@ -96,24 +100,49 @@ static void eeh_report_error(struct pci_dev *dev, void *userdata)
96 PCI_DN(dn)->eeh_mode |= EEH_MODE_IRQ_DISABLED; 100 PCI_DN(dn)->eeh_mode |= EEH_MODE_IRQ_DISABLED;
97 disable_irq_nosync(dev->irq); 101 disable_irq_nosync(dev->irq);
98 } 102 }
99 if (!driver->err_handler) 103 if (!driver->err_handler ||
100 return; 104 !driver->err_handler->error_detected)
101 if (!driver->err_handler->error_detected)
102 return; 105 return;
103 106
104 rc = driver->err_handler->error_detected (dev, pci_channel_io_frozen); 107 rc = driver->err_handler->error_detected (dev, pci_channel_io_frozen);
105 if (*res == PCI_ERS_RESULT_NONE) *res = rc; 108 if (*res == PCI_ERS_RESULT_NONE) *res = rc;
106 if (*res == PCI_ERS_RESULT_NEED_RESET) return;
107 if (*res == PCI_ERS_RESULT_DISCONNECT && 109 if (*res == PCI_ERS_RESULT_DISCONNECT &&
108 rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; 110 rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
109} 111}
110 112
111/** eeh_report_reset -- tell this device that the pci slot 113/**
112 * has been reset. 114 * eeh_report_mmio_enabled - tell drivers that MMIO has been enabled
115 *
116 * Report an EEH error to each device driver, collect up and
117 * merge the device driver responses. Cumulative response
118 * passed back in "userdata".
119 */
120
121static void eeh_report_mmio_enabled(struct pci_dev *dev, void *userdata)
122{
123 enum pci_ers_result rc, *res = userdata;
124 struct pci_driver *driver = dev->driver;
125
126 // dev->error_state = pci_channel_mmio_enabled;
127
128 if (!driver ||
129 !driver->err_handler ||
130 !driver->err_handler->mmio_enabled)
131 return;
132
133 rc = driver->err_handler->mmio_enabled (dev);
134 if (*res == PCI_ERS_RESULT_NONE) *res = rc;
135 if (*res == PCI_ERS_RESULT_DISCONNECT &&
136 rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
137}
138
139/**
140 * eeh_report_reset - tell device that slot has been reset
113 */ 141 */
114 142
115static void eeh_report_reset(struct pci_dev *dev, void *userdata) 143static void eeh_report_reset(struct pci_dev *dev, void *userdata)
116{ 144{
145 enum pci_ers_result rc, *res = userdata;
117 struct pci_driver *driver = dev->driver; 146 struct pci_driver *driver = dev->driver;
118 struct device_node *dn = pci_device_to_OF_node(dev); 147 struct device_node *dn = pci_device_to_OF_node(dev);
119 148
@@ -124,14 +153,20 @@ static void eeh_report_reset(struct pci_dev *dev, void *userdata)
124 PCI_DN(dn)->eeh_mode &= ~EEH_MODE_IRQ_DISABLED; 153 PCI_DN(dn)->eeh_mode &= ~EEH_MODE_IRQ_DISABLED;
125 enable_irq(dev->irq); 154 enable_irq(dev->irq);
126 } 155 }
127 if (!driver->err_handler) 156 if (!driver->err_handler ||
128 return; 157 !driver->err_handler->slot_reset)
129 if (!driver->err_handler->slot_reset)
130 return; 158 return;
131 159
132 driver->err_handler->slot_reset(dev); 160 rc = driver->err_handler->slot_reset(dev);
161 if (*res == PCI_ERS_RESULT_NONE) *res = rc;
162 if (*res == PCI_ERS_RESULT_DISCONNECT &&
163 rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
133} 164}
134 165
166/**
167 * eeh_report_resume - tell device to resume normal operations
168 */
169
135static void eeh_report_resume(struct pci_dev *dev, void *userdata) 170static void eeh_report_resume(struct pci_dev *dev, void *userdata)
136{ 171{
137 struct pci_driver *driver = dev->driver; 172 struct pci_driver *driver = dev->driver;
@@ -148,6 +183,13 @@ static void eeh_report_resume(struct pci_dev *dev, void *userdata)
148 driver->err_handler->resume(dev); 183 driver->err_handler->resume(dev);
149} 184}
150 185
186/**
187 * eeh_report_failure - tell device driver that device is dead.
188 *
189 * This informs the device driver that the device is permanently
190 * dead, and that no further recovery attempts will be made on it.
191 */
192
151static void eeh_report_failure(struct pci_dev *dev, void *userdata) 193static void eeh_report_failure(struct pci_dev *dev, void *userdata)
152{ 194{
153 struct pci_driver *driver = dev->driver; 195 struct pci_driver *driver = dev->driver;
@@ -190,11 +232,11 @@ static void eeh_report_failure(struct pci_dev *dev, void *userdata)
190 232
191/** 233/**
192 * eeh_reset_device() -- perform actual reset of a pci slot 234 * eeh_reset_device() -- perform actual reset of a pci slot
193 * Args: bus: pointer to the pci bus structure corresponding 235 * @bus: pointer to the pci bus structure corresponding
194 * to the isolated slot. A non-null value will 236 * to the isolated slot. A non-null value will
195 * cause all devices under the bus to be removed 237 * cause all devices under the bus to be removed
196 * and then re-added. 238 * and then re-added.
197 * pe_dn: pointer to a "Partionable Endpoint" device node. 239 * @pe_dn: pointer to a "Partionable Endpoint" device node.
198 * This is the top-level structure on which pci 240 * This is the top-level structure on which pci
199 * bus resets can be performed. 241 * bus resets can be performed.
200 */ 242 */
@@ -268,14 +310,14 @@ struct pci_dn * handle_eeh_events (struct eeh_event *event)
268 310
269 if (!frozen_dn) { 311 if (!frozen_dn) {
270 312
271 location = (char *) get_property(event->dn, "ibm,loc-code", NULL); 313 location = get_property(event->dn, "ibm,loc-code", NULL);
272 location = location ? location : "unknown"; 314 location = location ? location : "unknown";
273 printk(KERN_ERR "EEH: Error: Cannot find partition endpoint " 315 printk(KERN_ERR "EEH: Error: Cannot find partition endpoint "
274 "for location=%s pci addr=%s\n", 316 "for location=%s pci addr=%s\n",
275 location, pci_name(event->dev)); 317 location, pci_name(event->dev));
276 return NULL; 318 return NULL;
277 } 319 }
278 location = (char *) get_property(frozen_dn, "ibm,loc-code", NULL); 320 location = get_property(frozen_dn, "ibm,loc-code", NULL);
279 location = location ? location : "unknown"; 321 location = location ? location : "unknown";
280 322
281 /* There are two different styles for coming up with the PE. 323 /* There are two different styles for coming up with the PE.
@@ -347,23 +389,43 @@ struct pci_dn * handle_eeh_events (struct eeh_event *event)
347 goto hard_fail; 389 goto hard_fail;
348 } 390 }
349 391
350 /* If any device called out for a reset, then reset the slot */ 392 /* If all devices reported they can proceed, then re-enable MMIO */
351 if (result == PCI_ERS_RESULT_NEED_RESET) { 393 if (result == PCI_ERS_RESULT_CAN_RECOVER) {
352 rc = eeh_reset_device(frozen_pdn, NULL); 394 rc = rtas_pci_enable(frozen_pdn, EEH_THAW_MMIO);
353 if (rc) 395
354 goto hard_fail; 396 if (rc) {
355 pci_walk_bus(frozen_bus, eeh_report_reset, NULL); 397 result = PCI_ERS_RESULT_NEED_RESET;
398 } else {
399 result = PCI_ERS_RESULT_NONE;
400 pci_walk_bus(frozen_bus, eeh_report_mmio_enabled, &result);
401 }
356 } 402 }
357 403
358 /* If all devices reported they can proceed, the re-enable PIO */ 404 /* If all devices reported they can proceed, then re-enable DMA */
359 if (result == PCI_ERS_RESULT_CAN_RECOVER) { 405 if (result == PCI_ERS_RESULT_CAN_RECOVER) {
360 /* XXX Not supported; we brute-force reset the device */ 406 rc = rtas_pci_enable(frozen_pdn, EEH_THAW_DMA);
407
408 if (rc)
409 result = PCI_ERS_RESULT_NEED_RESET;
410 }
411
412 /* If any device has a hard failure, then shut off everything. */
413 if (result == PCI_ERS_RESULT_DISCONNECT)
414 goto hard_fail;
415
416 /* If any device called out for a reset, then reset the slot */
417 if (result == PCI_ERS_RESULT_NEED_RESET) {
361 rc = eeh_reset_device(frozen_pdn, NULL); 418 rc = eeh_reset_device(frozen_pdn, NULL);
362 if (rc) 419 if (rc)
363 goto hard_fail; 420 goto hard_fail;
364 pci_walk_bus(frozen_bus, eeh_report_reset, NULL); 421 result = PCI_ERS_RESULT_NONE;
422 pci_walk_bus(frozen_bus, eeh_report_reset, &result);
365 } 423 }
366 424
425 /* All devices should claim they have recovered by now. */
426 if (result != PCI_ERS_RESULT_RECOVERED)
427 goto hard_fail;
428
367 /* Tell all device drivers that they can resume operations */ 429 /* Tell all device drivers that they can resume operations */
368 pci_walk_bus(frozen_bus, eeh_report_resume, NULL); 430 pci_walk_bus(frozen_bus, eeh_report_resume, NULL);
369 431
diff --git a/arch/powerpc/platforms/pseries/eeh_event.c b/arch/powerpc/platforms/pseries/eeh_event.c
index 45ccc687e57c..137077451316 100644
--- a/arch/powerpc/platforms/pseries/eeh_event.c
+++ b/arch/powerpc/platforms/pseries/eeh_event.c
@@ -124,11 +124,11 @@ int eeh_send_failure_event (struct device_node *dn,
124{ 124{
125 unsigned long flags; 125 unsigned long flags;
126 struct eeh_event *event; 126 struct eeh_event *event;
127 char *location; 127 const char *location;
128 128
129 if (!mem_init_done) { 129 if (!mem_init_done) {
130 printk(KERN_ERR "EEH: event during early boot not handled\n"); 130 printk(KERN_ERR "EEH: event during early boot not handled\n");
131 location = (char *) get_property(dn, "ibm,loc-code", NULL); 131 location = get_property(dn, "ibm,loc-code", NULL);
132 printk(KERN_ERR "EEH: device node = %s\n", dn->full_name); 132 printk(KERN_ERR "EEH: device node = %s\n", dn->full_name);
133 printk(KERN_ERR "EEH: PCI location = %s\n", location); 133 printk(KERN_ERR "EEH: PCI location = %s\n", location);
134 return 1; 134 return 1;
diff --git a/arch/powerpc/platforms/pseries/firmware.c b/arch/powerpc/platforms/pseries/firmware.c
index c01d8f0cbe6d..1c7b2baa5f73 100644
--- a/arch/powerpc/platforms/pseries/firmware.c
+++ b/arch/powerpc/platforms/pseries/firmware.c
@@ -68,7 +68,7 @@ firmware_features_table[FIRMWARE_MAX_FEATURES] = {
68void __init fw_feature_init(void) 68void __init fw_feature_init(void)
69{ 69{
70 struct device_node *dn; 70 struct device_node *dn;
71 char *hypertas, *s; 71 const char *hypertas, *s;
72 int len, i; 72 int len, i;
73 73
74 DBG(" -> fw_feature_init()\n"); 74 DBG(" -> fw_feature_init()\n");
diff --git a/arch/powerpc/platforms/pseries/hvCall.S b/arch/powerpc/platforms/pseries/hvCall.S
index c9ff547f9d25..c00cfed7af2c 100644
--- a/arch/powerpc/platforms/pseries/hvCall.S
+++ b/arch/powerpc/platforms/pseries/hvCall.S
@@ -1,7 +1,6 @@
1/* 1/*
2 * This file contains the generic code to perform a call to the 2 * This file contains the generic code to perform a call to the
3 * pSeries LPAR hypervisor. 3 * pSeries LPAR hypervisor.
4 * NOTE: this file will go away when we move to inline this work.
5 * 4 *
6 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
@@ -11,217 +10,153 @@
11#include <asm/hvcall.h> 10#include <asm/hvcall.h>
12#include <asm/processor.h> 11#include <asm/processor.h>
13#include <asm/ppc_asm.h> 12#include <asm/ppc_asm.h>
13#include <asm/asm-offsets.h>
14 14
15#define STK_PARM(i) (48 + ((i)-3)*8) 15#define STK_PARM(i) (48 + ((i)-3)*8)
16 16
17 .text 17#ifdef CONFIG_HCALL_STATS
18 18/*
19/* long plpar_hcall(unsigned long opcode, R3 19 * precall must preserve all registers. use unused STK_PARM()
20 unsigned long arg1, R4 20 * areas to save snapshots and opcode.
21 unsigned long arg2, R5
22 unsigned long arg3, R6
23 unsigned long arg4, R7
24 unsigned long *out1, R8
25 unsigned long *out2, R9
26 unsigned long *out3); R10
27 */ 21 */
28_GLOBAL(plpar_hcall) 22#define HCALL_INST_PRECALL \
29 HMT_MEDIUM 23 std r3,STK_PARM(r3)(r1); /* save opcode */ \
30 24 mftb r0; /* get timebase and */ \
31 mfcr r0 25 std r0,STK_PARM(r5)(r1); /* save for later */ \
32 26BEGIN_FTR_SECTION; \
33 std r8,STK_PARM(r8)(r1) /* Save out ptrs */ 27 mfspr r0,SPRN_PURR; /* get PURR and */ \
34 std r9,STK_PARM(r9)(r1) 28 std r0,STK_PARM(r6)(r1); /* save for later */ \
35 std r10,STK_PARM(r10)(r1) 29END_FTR_SECTION_IFCLR(CPU_FTR_PURR);
36 30
37 stw r0,8(r1) 31/*
38 32 * postcall is performed immediately before function return which
39 HVSC /* invoke the hypervisor */ 33 * allows liberal use of volatile registers.
40 34 */
41 lwz r0,8(r1) 35#define HCALL_INST_POSTCALL \
42 36 ld r4,STK_PARM(r3)(r1); /* validate opcode */ \
43 ld r8,STK_PARM(r8)(r1) /* Fetch r4-r6 ret args */ 37 cmpldi cr7,r4,MAX_HCALL_OPCODE; \
44 ld r9,STK_PARM(r9)(r1) 38 bgt- cr7,1f; \
45 ld r10,STK_PARM(r10)(r1) 39 \
46 std r4,0(r8) 40 /* get time and PURR snapshots after hcall */ \
47 std r5,0(r9) 41 mftb r7; /* timebase after */ \
48 std r6,0(r10) 42BEGIN_FTR_SECTION; \
49 43 mfspr r8,SPRN_PURR; /* PURR after */ \
50 mtcrf 0xff,r0 44 ld r6,STK_PARM(r6)(r1); /* PURR before */ \
51 blr /* return r3 = status */ 45 subf r6,r6,r8; /* delta */ \
46END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
47 ld r5,STK_PARM(r5)(r1); /* timebase before */ \
48 subf r5,r5,r7; /* time delta */ \
49 \
50 /* calculate address of stat structure r4 = opcode */ \
51 srdi r4,r4,2; /* index into array */ \
52 mulli r4,r4,HCALL_STAT_SIZE; \
53 LOAD_REG_ADDR(r7, per_cpu__hcall_stats); \
54 add r4,r4,r7; \
55 ld r7,PACA_DATA_OFFSET(r13); /* per cpu offset */ \
56 add r4,r4,r7; \
57 \
58 /* update stats */ \
59 ld r7,HCALL_STAT_CALLS(r4); /* count */ \
60 addi r7,r7,1; \
61 std r7,HCALL_STAT_CALLS(r4); \
62 ld r7,HCALL_STAT_TB(r4); /* timebase */ \
63 add r7,r7,r5; \
64 std r7,HCALL_STAT_TB(r4); \
65BEGIN_FTR_SECTION; \
66 ld r7,HCALL_STAT_PURR(r4); /* PURR */ \
67 add r7,r7,r6; \
68 std r7,HCALL_STAT_PURR(r4); \
69END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
701:
71#else
72#define HCALL_INST_PRECALL
73#define HCALL_INST_POSTCALL
74#endif
52 75
76 .text
53 77
54/* Simple interface with no output values (other than status) */
55_GLOBAL(plpar_hcall_norets) 78_GLOBAL(plpar_hcall_norets)
56 HMT_MEDIUM 79 HMT_MEDIUM
57 80
58 mfcr r0 81 mfcr r0
59 stw r0,8(r1) 82 stw r0,8(r1)
60 83
61 HVSC /* invoke the hypervisor */ 84 HCALL_INST_PRECALL
62
63 lwz r0,8(r1)
64 mtcrf 0xff,r0
65 blr /* return r3 = status */
66
67
68/* long plpar_hcall_8arg_2ret(unsigned long opcode, R3
69 unsigned long arg1, R4
70 unsigned long arg2, R5
71 unsigned long arg3, R6
72 unsigned long arg4, R7
73 unsigned long arg5, R8
74 unsigned long arg6, R9
75 unsigned long arg7, R10
76 unsigned long arg8, 112(R1)
77 unsigned long *out1); 120(R1)
78 */
79_GLOBAL(plpar_hcall_8arg_2ret)
80 HMT_MEDIUM
81
82 mfcr r0
83 ld r11,STK_PARM(r11)(r1) /* put arg8 in R11 */
84 stw r0,8(r1)
85 85
86 HVSC /* invoke the hypervisor */ 86 HVSC /* invoke the hypervisor */
87 87
88 HCALL_INST_POSTCALL
89
88 lwz r0,8(r1) 90 lwz r0,8(r1)
89 ld r10,STK_PARM(r12)(r1) /* Fetch r4 ret arg */
90 std r4,0(r10)
91 mtcrf 0xff,r0 91 mtcrf 0xff,r0
92 blr /* return r3 = status */ 92 blr /* return r3 = status */
93 93
94 94_GLOBAL(plpar_hcall)
95/* long plpar_hcall_4out(unsigned long opcode, R3
96 unsigned long arg1, R4
97 unsigned long arg2, R5
98 unsigned long arg3, R6
99 unsigned long arg4, R7
100 unsigned long *out1, R8
101 unsigned long *out2, R9
102 unsigned long *out3, R10
103 unsigned long *out4); 112(R1)
104 */
105_GLOBAL(plpar_hcall_4out)
106 HMT_MEDIUM 95 HMT_MEDIUM
107 96
108 mfcr r0 97 mfcr r0
109 stw r0,8(r1) 98 stw r0,8(r1)
110 99
111 std r8,STK_PARM(r8)(r1) /* Save out ptrs */ 100 HCALL_INST_PRECALL
112 std r9,STK_PARM(r9)(r1)
113 std r10,STK_PARM(r10)(r1)
114
115 HVSC /* invoke the hypervisor */
116
117 lwz r0,8(r1)
118 101
119 ld r8,STK_PARM(r8)(r1) /* Fetch r4-r7 ret args */ 102 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
120 ld r9,STK_PARM(r9)(r1)
121 ld r10,STK_PARM(r10)(r1)
122 ld r11,STK_PARM(r11)(r1)
123 std r4,0(r8)
124 std r5,0(r9)
125 std r6,0(r10)
126 std r7,0(r11)
127 103
128 mtcrf 0xff,r0 104 mr r4,r5
129 blr /* return r3 = status */ 105 mr r5,r6
130 106 mr r6,r7
131/* plpar_hcall_7arg_7ret(unsigned long opcode, R3 107 mr r7,r8
132 unsigned long arg1, R4 108 mr r8,r9
133 unsigned long arg2, R5 109 mr r9,r10
134 unsigned long arg3, R6
135 unsigned long arg4, R7
136 unsigned long arg5, R8
137 unsigned long arg6, R9
138 unsigned long arg7, R10
139 unsigned long *out1, 112(R1)
140 unsigned long *out2, 110(R1)
141 unsigned long *out3, 108(R1)
142 unsigned long *out4, 106(R1)
143 unsigned long *out5, 104(R1)
144 unsigned long *out6, 102(R1)
145 unsigned long *out7); 100(R1)
146*/
147_GLOBAL(plpar_hcall_7arg_7ret)
148 HMT_MEDIUM
149
150 mfcr r0
151 stw r0,8(r1)
152 110
153 HVSC /* invoke the hypervisor */ 111 HVSC /* invoke the hypervisor */
154 112
155 lwz r0,8(r1) 113 ld r12,STK_PARM(r4)(r1)
114 std r4, 0(r12)
115 std r5, 8(r12)
116 std r6, 16(r12)
117 std r7, 24(r12)
156 118
157 ld r11,STK_PARM(r11)(r1) /* Fetch r4 ret arg */ 119 HCALL_INST_POSTCALL
158 std r4,0(r11)
159 ld r11,STK_PARM(r12)(r1) /* Fetch r5 ret arg */
160 std r5,0(r11)
161 ld r11,STK_PARM(r13)(r1) /* Fetch r6 ret arg */
162 std r6,0(r11)
163 ld r11,STK_PARM(r14)(r1) /* Fetch r7 ret arg */
164 std r7,0(r11)
165 ld r11,STK_PARM(r15)(r1) /* Fetch r8 ret arg */
166 std r8,0(r11)
167 ld r11,STK_PARM(r16)(r1) /* Fetch r9 ret arg */
168 std r9,0(r11)
169 ld r11,STK_PARM(r17)(r1) /* Fetch r10 ret arg */
170 std r10,0(r11)
171 120
121 lwz r0,8(r1)
172 mtcrf 0xff,r0 122 mtcrf 0xff,r0
173 123
174 blr /* return r3 = status */ 124 blr /* return r3 = status */
175 125
176/* plpar_hcall_9arg_9ret(unsigned long opcode, R3 126_GLOBAL(plpar_hcall9)
177 unsigned long arg1, R4
178 unsigned long arg2, R5
179 unsigned long arg3, R6
180 unsigned long arg4, R7
181 unsigned long arg5, R8
182 unsigned long arg6, R9
183 unsigned long arg7, R10
184 unsigned long arg8, 112(R1)
185 unsigned long arg9, 110(R1)
186 unsigned long *out1, 108(R1)
187 unsigned long *out2, 106(R1)
188 unsigned long *out3, 104(R1)
189 unsigned long *out4, 102(R1)
190 unsigned long *out5, 100(R1)
191 unsigned long *out6, 98(R1)
192 unsigned long *out7); 96(R1)
193 unsigned long *out8, 94(R1)
194 unsigned long *out9, 92(R1)
195*/
196_GLOBAL(plpar_hcall_9arg_9ret)
197 HMT_MEDIUM 127 HMT_MEDIUM
198 128
199 mfcr r0 129 mfcr r0
200 stw r0,8(r1) 130 stw r0,8(r1)
201 131
202 ld r11,STK_PARM(r11)(r1) /* put arg8 in R11 */ 132 HCALL_INST_PRECALL
203 ld r12,STK_PARM(r12)(r1) /* put arg9 in R12 */ 133
134 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
135
136 mr r4,r5
137 mr r5,r6
138 mr r6,r7
139 mr r7,r8
140 mr r8,r9
141 mr r9,r10
142 ld r10,STK_PARM(r11)(r1) /* put arg7 in R10 */
143 ld r11,STK_PARM(r12)(r1) /* put arg8 in R11 */
144 ld r12,STK_PARM(r13)(r1) /* put arg9 in R12 */
204 145
205 HVSC /* invoke the hypervisor */ 146 HVSC /* invoke the hypervisor */
206 147
207 ld r0,STK_PARM(r13)(r1) /* Fetch r4 ret arg */ 148 ld r12,STK_PARM(r4)(r1)
208 stdx r4,r0,r0 149 std r4, 0(r12)
209 ld r0,STK_PARM(r14)(r1) /* Fetch r5 ret arg */ 150 std r5, 8(r12)
210 stdx r5,r0,r0 151 std r6, 16(r12)
211 ld r0,STK_PARM(r15)(r1) /* Fetch r6 ret arg */ 152 std r7, 24(r12)
212 stdx r6,r0,r0 153 std r8, 32(r12)
213 ld r0,STK_PARM(r16)(r1) /* Fetch r7 ret arg */ 154 std r9, 40(r12)
214 stdx r7,r0,r0 155 std r10,48(r12)
215 ld r0,STK_PARM(r17)(r1) /* Fetch r8 ret arg */ 156 std r11,56(r12)
216 stdx r8,r0,r0 157 std r12,64(r12)
217 ld r0,STK_PARM(r18)(r1) /* Fetch r9 ret arg */ 158
218 stdx r9,r0,r0 159 HCALL_INST_POSTCALL
219 ld r0,STK_PARM(r19)(r1) /* Fetch r10 ret arg */
220 stdx r10,r0,r0
221 ld r0,STK_PARM(r20)(r1) /* Fetch r11 ret arg */
222 stdx r11,r0,r0
223 ld r0,STK_PARM(r21)(r1) /* Fetch r12 ret arg */
224 stdx r12,r0,r0
225 160
226 lwz r0,8(r1) 161 lwz r0,8(r1)
227 mtcrf 0xff,r0 162 mtcrf 0xff,r0
diff --git a/arch/powerpc/platforms/pseries/hvCall_inst.c b/arch/powerpc/platforms/pseries/hvCall_inst.c
new file mode 100644
index 000000000000..641e6511cf06
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/hvCall_inst.c
@@ -0,0 +1,129 @@
1/*
2 * Copyright (C) 2006 Mike Kravetz IBM Corporation
3 *
4 * Hypervisor Call Instrumentation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/kernel.h>
22#include <linux/percpu.h>
23#include <linux/debugfs.h>
24#include <linux/seq_file.h>
25#include <linux/cpumask.h>
26#include <asm/hvcall.h>
27#include <asm/firmware.h>
28#include <asm/cputable.h>
29
30DEFINE_PER_CPU(struct hcall_stats[HCALL_STAT_ARRAY_SIZE], hcall_stats);
31
32/*
33 * Routines for displaying the statistics in debugfs
34 */
35static void *hc_start(struct seq_file *m, loff_t *pos)
36{
37 if ((int)*pos < HCALL_STAT_ARRAY_SIZE)
38 return (void *)(unsigned long)(*pos + 1);
39
40 return NULL;
41}
42
43static void *hc_next(struct seq_file *m, void *p, loff_t * pos)
44{
45 ++*pos;
46
47 return hc_start(m, pos);
48}
49
50static void hc_stop(struct seq_file *m, void *p)
51{
52}
53
54static int hc_show(struct seq_file *m, void *p)
55{
56 unsigned long h_num = (unsigned long)p;
57 struct hcall_stats *hs = (struct hcall_stats *)m->private;
58
59 if (hs[h_num].num_calls) {
60 if (!cpu_has_feature(CPU_FTR_PURR))
61 seq_printf(m, "%lu %lu %lu %lu\n", h_num<<2,
62 hs[h_num].num_calls,
63 hs[h_num].tb_total,
64 hs[h_num].purr_total);
65 else
66 seq_printf(m, "%lu %lu %lu\n", h_num<<2,
67 hs[h_num].num_calls,
68 hs[h_num].tb_total);
69 }
70
71 return 0;
72}
73
74static struct seq_operations hcall_inst_seq_ops = {
75 .start = hc_start,
76 .next = hc_next,
77 .stop = hc_stop,
78 .show = hc_show
79};
80
81static int hcall_inst_seq_open(struct inode *inode, struct file *file)
82{
83 int rc;
84 struct seq_file *seq;
85
86 rc = seq_open(file, &hcall_inst_seq_ops);
87 seq = file->private_data;
88 seq->private = file->f_dentry->d_inode->u.generic_ip;
89
90 return rc;
91}
92
93static struct file_operations hcall_inst_seq_fops = {
94 .open = hcall_inst_seq_open,
95 .read = seq_read,
96 .llseek = seq_lseek,
97 .release = seq_release,
98};
99
100#define HCALL_ROOT_DIR "hcall_inst"
101#define CPU_NAME_BUF_SIZE 32
102
103static int __init hcall_inst_init(void)
104{
105 struct dentry *hcall_root;
106 struct dentry *hcall_file;
107 char cpu_name_buf[CPU_NAME_BUF_SIZE];
108 int cpu;
109
110 if (!firmware_has_feature(FW_FEATURE_LPAR))
111 return 0;
112
113 hcall_root = debugfs_create_dir(HCALL_ROOT_DIR, NULL);
114 if (!hcall_root)
115 return -ENOMEM;
116
117 for_each_possible_cpu(cpu) {
118 snprintf(cpu_name_buf, CPU_NAME_BUF_SIZE, "cpu%d", cpu);
119 hcall_file = debugfs_create_file(cpu_name_buf, S_IRUGO,
120 hcall_root,
121 per_cpu(hcall_stats, cpu),
122 &hcall_inst_seq_fops);
123 if (!hcall_file)
124 return -ENOMEM;
125 }
126
127 return 0;
128}
129__initcall(hcall_inst_init);
diff --git a/arch/powerpc/platforms/pseries/hvconsole.c b/arch/powerpc/platforms/pseries/hvconsole.c
index a72a987f1d4d..3f6a89b09816 100644
--- a/arch/powerpc/platforms/pseries/hvconsole.c
+++ b/arch/powerpc/platforms/pseries/hvconsole.c
@@ -27,6 +27,7 @@
27#include <linux/module.h> 27#include <linux/module.h>
28#include <asm/hvcall.h> 28#include <asm/hvcall.h>
29#include <asm/hvconsole.h> 29#include <asm/hvconsole.h>
30#include "plpar_wrappers.h"
30 31
31/** 32/**
32 * hvc_get_chars - retrieve characters from firmware for denoted vterm adatper 33 * hvc_get_chars - retrieve characters from firmware for denoted vterm adatper
@@ -40,9 +41,9 @@ int hvc_get_chars(uint32_t vtermno, char *buf, int count)
40{ 41{
41 unsigned long got; 42 unsigned long got;
42 43
43 if (plpar_hcall(H_GET_TERM_CHAR, vtermno, 0, 0, 0, &got, 44 if (plpar_get_term_char(vtermno, &got, buf) == H_SUCCESS)
44 (unsigned long *)buf, (unsigned long *)buf+1) == H_SUCCESS)
45 return got; 45 return got;
46
46 return 0; 47 return 0;
47} 48}
48 49
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index d67af2c65754..bbf2e34dc358 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -267,13 +267,12 @@ static void iommu_table_setparms(struct pci_controller *phb,
267 struct iommu_table *tbl) 267 struct iommu_table *tbl)
268{ 268{
269 struct device_node *node; 269 struct device_node *node;
270 unsigned long *basep; 270 const unsigned long *basep, *sizep;
271 unsigned int *sizep;
272 271
273 node = (struct device_node *)phb->arch_data; 272 node = (struct device_node *)phb->arch_data;
274 273
275 basep = (unsigned long *)get_property(node, "linux,tce-base", NULL); 274 basep = get_property(node, "linux,tce-base", NULL);
276 sizep = (unsigned int *)get_property(node, "linux,tce-size", NULL); 275 sizep = get_property(node, "linux,tce-size", NULL);
277 if (basep == NULL || sizep == NULL) { 276 if (basep == NULL || sizep == NULL) {
278 printk(KERN_ERR "PCI_DMA: iommu_table_setparms: %s has " 277 printk(KERN_ERR "PCI_DMA: iommu_table_setparms: %s has "
279 "missing tce entries !\n", dn->full_name); 278 "missing tce entries !\n", dn->full_name);
@@ -315,7 +314,7 @@ static void iommu_table_setparms(struct pci_controller *phb,
315static void iommu_table_setparms_lpar(struct pci_controller *phb, 314static void iommu_table_setparms_lpar(struct pci_controller *phb,
316 struct device_node *dn, 315 struct device_node *dn,
317 struct iommu_table *tbl, 316 struct iommu_table *tbl,
318 unsigned char *dma_window) 317 const void *dma_window)
319{ 318{
320 unsigned long offset, size; 319 unsigned long offset, size;
321 320
@@ -415,7 +414,7 @@ static void iommu_bus_setup_pSeriesLP(struct pci_bus *bus)
415 struct iommu_table *tbl; 414 struct iommu_table *tbl;
416 struct device_node *dn, *pdn; 415 struct device_node *dn, *pdn;
417 struct pci_dn *ppci; 416 struct pci_dn *ppci;
418 unsigned char *dma_window = NULL; 417 const void *dma_window = NULL;
419 418
420 DBG("iommu_bus_setup_pSeriesLP, bus %p, bus->self %p\n", bus, bus->self); 419 DBG("iommu_bus_setup_pSeriesLP, bus %p, bus->self %p\n", bus, bus->self);
421 420
@@ -519,7 +518,7 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev)
519{ 518{
520 struct device_node *pdn, *dn; 519 struct device_node *pdn, *dn;
521 struct iommu_table *tbl; 520 struct iommu_table *tbl;
522 unsigned char *dma_window = NULL; 521 const void *dma_window = NULL;
523 struct pci_dn *pci; 522 struct pci_dn *pci;
524 523
525 DBG("iommu_dev_setup_pSeriesLP, dev %p (%s)\n", dev, pci_name(dev)); 524 DBG("iommu_dev_setup_pSeriesLP, dev %p (%s)\n", dev, pci_name(dev));
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 3aeb40699042..1820a0b0a8c6 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -48,13 +48,11 @@
48#define DBG_LOW(fmt...) do { } while(0) 48#define DBG_LOW(fmt...) do { } while(0)
49#endif 49#endif
50 50
51/* in pSeries_hvCall.S */ 51/* in hvCall.S */
52EXPORT_SYMBOL(plpar_hcall); 52EXPORT_SYMBOL(plpar_hcall);
53EXPORT_SYMBOL(plpar_hcall_4out); 53EXPORT_SYMBOL(plpar_hcall9);
54EXPORT_SYMBOL(plpar_hcall_norets); 54EXPORT_SYMBOL(plpar_hcall_norets);
55EXPORT_SYMBOL(plpar_hcall_8arg_2ret); 55
56EXPORT_SYMBOL(plpar_hcall_7arg_7ret);
57EXPORT_SYMBOL(plpar_hcall_9arg_9ret);
58extern void pSeries_find_serial_port(void); 56extern void pSeries_find_serial_port(void);
59 57
60 58
@@ -204,20 +202,20 @@ void __init udbg_init_debug_lpar(void)
204void __init find_udbg_vterm(void) 202void __init find_udbg_vterm(void)
205{ 203{
206 struct device_node *stdout_node; 204 struct device_node *stdout_node;
207 u32 *termno; 205 const u32 *termno;
208 char *name; 206 const char *name;
209 int add_console; 207 int add_console;
210 208
211 /* find the boot console from /chosen/stdout */ 209 /* find the boot console from /chosen/stdout */
212 if (!of_chosen) 210 if (!of_chosen)
213 return; 211 return;
214 name = (char *)get_property(of_chosen, "linux,stdout-path", NULL); 212 name = get_property(of_chosen, "linux,stdout-path", NULL);
215 if (name == NULL) 213 if (name == NULL)
216 return; 214 return;
217 stdout_node = of_find_node_by_path(name); 215 stdout_node = of_find_node_by_path(name);
218 if (!stdout_node) 216 if (!stdout_node)
219 return; 217 return;
220 name = (char *)get_property(stdout_node, "name", NULL); 218 name = get_property(stdout_node, "name", NULL);
221 if (!name) { 219 if (!name) {
222 printk(KERN_WARNING "stdout node missing 'name' property!\n"); 220 printk(KERN_WARNING "stdout node missing 'name' property!\n");
223 goto out; 221 goto out;
@@ -228,7 +226,7 @@ void __init find_udbg_vterm(void)
228 /* Check if it's a virtual terminal */ 226 /* Check if it's a virtual terminal */
229 if (strncmp(name, "vty", 3) != 0) 227 if (strncmp(name, "vty", 3) != 0)
230 goto out; 228 goto out;
231 termno = (u32 *)get_property(stdout_node, "reg", NULL); 229 termno = get_property(stdout_node, "reg", NULL);
232 if (termno == NULL) 230 if (termno == NULL)
233 goto out; 231 goto out;
234 vtermno = termno[0]; 232 vtermno = termno[0];
@@ -254,18 +252,34 @@ out:
254void vpa_init(int cpu) 252void vpa_init(int cpu)
255{ 253{
256 int hwcpu = get_hard_smp_processor_id(cpu); 254 int hwcpu = get_hard_smp_processor_id(cpu);
257 unsigned long vpa = __pa(&lppaca[cpu]); 255 unsigned long addr;
258 long ret; 256 long ret;
259 257
260 if (cpu_has_feature(CPU_FTR_ALTIVEC)) 258 if (cpu_has_feature(CPU_FTR_ALTIVEC))
261 lppaca[cpu].vmxregs_in_use = 1; 259 lppaca[cpu].vmxregs_in_use = 1;
262 260
263 ret = register_vpa(hwcpu, vpa); 261 addr = __pa(&lppaca[cpu]);
262 ret = register_vpa(hwcpu, addr);
264 263
265 if (ret) 264 if (ret) {
266 printk(KERN_ERR "WARNING: vpa_init: VPA registration for " 265 printk(KERN_ERR "WARNING: vpa_init: VPA registration for "
267 "cpu %d (hw %d) of area %lx returns %ld\n", 266 "cpu %d (hw %d) of area %lx returns %ld\n",
268 cpu, hwcpu, vpa, ret); 267 cpu, hwcpu, addr, ret);
268 return;
269 }
270 /*
271 * PAPR says this feature is SLB-Buffer but firmware never
272 * reports that. All SPLPAR support SLB shadow buffer.
273 */
274 addr = __pa(&slb_shadow[cpu]);
275 if (firmware_has_feature(FW_FEATURE_SPLPAR)) {
276 ret = register_slb_shadow(hwcpu, addr);
277 if (ret)
278 printk(KERN_ERR
279 "WARNING: vpa_init: SLB shadow buffer "
280 "registration for cpu %d (hw %d) of area %lx "
281 "returns %ld\n", cpu, hwcpu, addr, ret);
282 }
269} 283}
270 284
271long pSeries_lpar_hpte_insert(unsigned long hpte_group, 285long pSeries_lpar_hpte_insert(unsigned long hpte_group,
@@ -277,7 +291,6 @@ long pSeries_lpar_hpte_insert(unsigned long hpte_group,
277 unsigned long flags; 291 unsigned long flags;
278 unsigned long slot; 292 unsigned long slot;
279 unsigned long hpte_v, hpte_r; 293 unsigned long hpte_v, hpte_r;
280 unsigned long dummy0, dummy1;
281 294
282 if (!(vflags & HPTE_V_BOLTED)) 295 if (!(vflags & HPTE_V_BOLTED))
283 DBG_LOW("hpte_insert(group=%lx, va=%016lx, pa=%016lx, " 296 DBG_LOW("hpte_insert(group=%lx, va=%016lx, pa=%016lx, "
@@ -302,8 +315,7 @@ long pSeries_lpar_hpte_insert(unsigned long hpte_group,
302 if (rflags & (_PAGE_GUARDED|_PAGE_NO_CACHE)) 315 if (rflags & (_PAGE_GUARDED|_PAGE_NO_CACHE))
303 hpte_r &= ~_PAGE_COHERENT; 316 hpte_r &= ~_PAGE_COHERENT;
304 317
305 lpar_rc = plpar_hcall(H_ENTER, flags, hpte_group, hpte_v, 318 lpar_rc = plpar_pte_enter(flags, hpte_group, hpte_v, hpte_r, &slot);
306 hpte_r, &slot, &dummy0, &dummy1);
307 if (unlikely(lpar_rc == H_PTEG_FULL)) { 319 if (unlikely(lpar_rc == H_PTEG_FULL)) {
308 if (!(vflags & HPTE_V_BOLTED)) 320 if (!(vflags & HPTE_V_BOLTED))
309 DBG_LOW(" full\n"); 321 DBG_LOW(" full\n");
diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c
index 18abfb1f4e24..64163cecdf93 100644
--- a/arch/powerpc/platforms/pseries/nvram.c
+++ b/arch/powerpc/platforms/pseries/nvram.c
@@ -123,13 +123,14 @@ static ssize_t pSeries_nvram_get_size(void)
123int __init pSeries_nvram_init(void) 123int __init pSeries_nvram_init(void)
124{ 124{
125 struct device_node *nvram; 125 struct device_node *nvram;
126 unsigned int *nbytes_p, proplen; 126 const unsigned int *nbytes_p;
127 unsigned int proplen;
127 128
128 nvram = of_find_node_by_type(NULL, "nvram"); 129 nvram = of_find_node_by_type(NULL, "nvram");
129 if (nvram == NULL) 130 if (nvram == NULL)
130 return -ENODEV; 131 return -ENODEV;
131 132
132 nbytes_p = (unsigned int *)get_property(nvram, "#bytes", &proplen); 133 nbytes_p = get_property(nvram, "#bytes", &proplen);
133 if (nbytes_p == NULL || proplen != sizeof(unsigned int)) 134 if (nbytes_p == NULL || proplen != sizeof(unsigned int))
134 return -EIO; 135 return -EIO;
135 136
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index e97e67f5e079..410a6bcc4ca0 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -60,7 +60,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_name_device);
60static void __devinit check_s7a(void) 60static void __devinit check_s7a(void)
61{ 61{
62 struct device_node *root; 62 struct device_node *root;
63 char *model; 63 const char *model;
64 64
65 s7a_workaround = 0; 65 s7a_workaround = 0;
66 root = of_find_node_by_path("/"); 66 root = of_find_node_by_path("/");
diff --git a/arch/powerpc/platforms/pseries/plpar_wrappers.h b/arch/powerpc/platforms/pseries/plpar_wrappers.h
index 3bd1b3e06003..3eb7b294d92f 100644
--- a/arch/powerpc/platforms/pseries/plpar_wrappers.h
+++ b/arch/powerpc/platforms/pseries/plpar_wrappers.h
@@ -5,20 +5,17 @@
5 5
6static inline long poll_pending(void) 6static inline long poll_pending(void)
7{ 7{
8 unsigned long dummy; 8 return plpar_hcall_norets(H_POLL_PENDING);
9 return plpar_hcall(H_POLL_PENDING, 0, 0, 0, 0, &dummy, &dummy, &dummy);
10} 9}
11 10
12static inline long prod_processor(void) 11static inline long prod_processor(void)
13{ 12{
14 plpar_hcall_norets(H_PROD); 13 return plpar_hcall_norets(H_PROD);
15 return 0;
16} 14}
17 15
18static inline long cede_processor(void) 16static inline long cede_processor(void)
19{ 17{
20 plpar_hcall_norets(H_CEDE); 18 return plpar_hcall_norets(H_CEDE);
21 return 0;
22} 19}
23 20
24static inline long vpa_call(unsigned long flags, unsigned long cpu, 21static inline long vpa_call(unsigned long flags, unsigned long cpu,
@@ -40,23 +37,59 @@ static inline long register_vpa(unsigned long cpu, unsigned long vpa)
40 return vpa_call(0x1, cpu, vpa); 37 return vpa_call(0x1, cpu, vpa);
41} 38}
42 39
40static inline long unregister_slb_shadow(unsigned long cpu, unsigned long vpa)
41{
42 return vpa_call(0x7, cpu, vpa);
43}
44
45static inline long register_slb_shadow(unsigned long cpu, unsigned long vpa)
46{
47 return vpa_call(0x3, cpu, vpa);
48}
49
43extern void vpa_init(int cpu); 50extern void vpa_init(int cpu);
44 51
52static inline long plpar_pte_enter(unsigned long flags,
53 unsigned long hpte_group, unsigned long hpte_v,
54 unsigned long hpte_r, unsigned long *slot)
55{
56 long rc;
57 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
58
59 rc = plpar_hcall(H_ENTER, retbuf, flags, hpte_group, hpte_v, hpte_r);
60
61 *slot = retbuf[0];
62
63 return rc;
64}
65
45static inline long plpar_pte_remove(unsigned long flags, unsigned long ptex, 66static inline long plpar_pte_remove(unsigned long flags, unsigned long ptex,
46 unsigned long avpn, unsigned long *old_pteh_ret, 67 unsigned long avpn, unsigned long *old_pteh_ret,
47 unsigned long *old_ptel_ret) 68 unsigned long *old_ptel_ret)
48{ 69{
49 unsigned long dummy; 70 long rc;
50 return plpar_hcall(H_REMOVE, flags, ptex, avpn, 0, old_pteh_ret, 71 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
51 old_ptel_ret, &dummy); 72
73 rc = plpar_hcall(H_REMOVE, retbuf, flags, ptex, avpn);
74
75 *old_pteh_ret = retbuf[0];
76 *old_ptel_ret = retbuf[1];
77
78 return rc;
52} 79}
53 80
54static inline long plpar_pte_read(unsigned long flags, unsigned long ptex, 81static inline long plpar_pte_read(unsigned long flags, unsigned long ptex,
55 unsigned long *old_pteh_ret, unsigned long *old_ptel_ret) 82 unsigned long *old_pteh_ret, unsigned long *old_ptel_ret)
56{ 83{
57 unsigned long dummy; 84 long rc;
58 return plpar_hcall(H_READ, flags, ptex, 0, 0, old_pteh_ret, 85 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
59 old_ptel_ret, &dummy); 86
87 rc = plpar_hcall(H_READ, retbuf, flags, ptex);
88
89 *old_pteh_ret = retbuf[0];
90 *old_ptel_ret = retbuf[1];
91
92 return rc;
60} 93}
61 94
62static inline long plpar_pte_protect(unsigned long flags, unsigned long ptex, 95static inline long plpar_pte_protect(unsigned long flags, unsigned long ptex,
@@ -68,9 +101,14 @@ static inline long plpar_pte_protect(unsigned long flags, unsigned long ptex,
68static inline long plpar_tce_get(unsigned long liobn, unsigned long ioba, 101static inline long plpar_tce_get(unsigned long liobn, unsigned long ioba,
69 unsigned long *tce_ret) 102 unsigned long *tce_ret)
70{ 103{
71 unsigned long dummy; 104 long rc;
72 return plpar_hcall(H_GET_TCE, liobn, ioba, 0, 0, tce_ret, &dummy, 105 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
73 &dummy); 106
107 rc = plpar_hcall(H_GET_TCE, retbuf, liobn, ioba);
108
109 *tce_ret = retbuf[0];
110
111 return rc;
74} 112}
75 113
76static inline long plpar_tce_put(unsigned long liobn, unsigned long ioba, 114static inline long plpar_tce_put(unsigned long liobn, unsigned long ioba,
@@ -94,9 +132,17 @@ static inline long plpar_tce_stuff(unsigned long liobn, unsigned long ioba,
94static inline long plpar_get_term_char(unsigned long termno, 132static inline long plpar_get_term_char(unsigned long termno,
95 unsigned long *len_ret, char *buf_ret) 133 unsigned long *len_ret, char *buf_ret)
96{ 134{
135 long rc;
136 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
97 unsigned long *lbuf = (unsigned long *)buf_ret; /* TODO: alignment? */ 137 unsigned long *lbuf = (unsigned long *)buf_ret; /* TODO: alignment? */
98 return plpar_hcall(H_GET_TERM_CHAR, termno, 0, 0, 0, len_ret, 138
99 lbuf + 0, lbuf + 1); 139 rc = plpar_hcall(H_GET_TERM_CHAR, retbuf, termno);
140
141 *len_ret = retbuf[0];
142 lbuf[0] = retbuf[1];
143 lbuf[1] = retbuf[2];
144
145 return rc;
100} 146}
101 147
102static inline long plpar_put_term_char(unsigned long termno, unsigned long len, 148static inline long plpar_put_term_char(unsigned long termno, unsigned long len,
@@ -107,4 +153,31 @@ static inline long plpar_put_term_char(unsigned long termno, unsigned long len,
107 lbuf[1]); 153 lbuf[1]);
108} 154}
109 155
156static inline long plpar_eoi(unsigned long xirr)
157{
158 return plpar_hcall_norets(H_EOI, xirr);
159}
160
161static inline long plpar_cppr(unsigned long cppr)
162{
163 return plpar_hcall_norets(H_CPPR, cppr);
164}
165
166static inline long plpar_ipi(unsigned long servernum, unsigned long mfrr)
167{
168 return plpar_hcall_norets(H_IPI, servernum, mfrr);
169}
170
171static inline long plpar_xirr(unsigned long *xirr_ret)
172{
173 long rc;
174 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
175
176 rc = plpar_hcall(H_XIRR, retbuf);
177
178 *xirr_ret = retbuf[0];
179
180 return rc;
181}
182
110#endif /* _PSERIES_PLPAR_WRAPPERS_H */ 183#endif /* _PSERIES_PLPAR_WRAPPERS_H */
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index c7ffde1a614e..903115d67fdc 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -79,7 +79,7 @@ static void request_ras_irqs(struct device_node *np,
79{ 79{
80 int i, index, count = 0; 80 int i, index, count = 0;
81 struct of_irq oirq; 81 struct of_irq oirq;
82 u32 *opicprop; 82 const u32 *opicprop;
83 unsigned int opicplen; 83 unsigned int opicplen;
84 unsigned int virqs[16]; 84 unsigned int virqs[16];
85 85
@@ -87,7 +87,7 @@ static void request_ras_irqs(struct device_node *np,
87 * map those interrupts using the default interrupt host and default 87 * map those interrupts using the default interrupt host and default
88 * trigger 88 * trigger
89 */ 89 */
90 opicprop = (u32 *)get_property(np, "open-pic-interrupt", &opicplen); 90 opicprop = get_property(np, "open-pic-interrupt", &opicplen);
91 if (opicprop) { 91 if (opicprop) {
92 opicplen /= sizeof(u32); 92 opicplen /= sizeof(u32);
93 for (i = 0; i < opicplen; i++) { 93 for (i = 0; i < opicplen; i++) {
diff --git a/arch/powerpc/platforms/pseries/rtasd.c b/arch/powerpc/platforms/pseries/rtasd.c
index 2e4e04042d85..8ca2612221d6 100644
--- a/arch/powerpc/platforms/pseries/rtasd.c
+++ b/arch/powerpc/platforms/pseries/rtasd.c
@@ -359,11 +359,11 @@ static int enable_surveillance(int timeout)
359static int get_eventscan_parms(void) 359static int get_eventscan_parms(void)
360{ 360{
361 struct device_node *node; 361 struct device_node *node;
362 int *ip; 362 const int *ip;
363 363
364 node = of_find_node_by_path("/rtas"); 364 node = of_find_node_by_path("/rtas");
365 365
366 ip = (int *)get_property(node, "rtas-event-scan-rate", NULL); 366 ip = get_property(node, "rtas-event-scan-rate", NULL);
367 if (ip == NULL) { 367 if (ip == NULL) {
368 printk(KERN_ERR "rtasd: no rtas-event-scan-rate\n"); 368 printk(KERN_ERR "rtasd: no rtas-event-scan-rate\n");
369 of_node_put(node); 369 of_node_put(node);
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 31867a701fcb..a6398fbe530d 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -133,9 +133,9 @@ void pseries_8259_cascade(unsigned int irq, struct irq_desc *desc,
133static void __init pseries_mpic_init_IRQ(void) 133static void __init pseries_mpic_init_IRQ(void)
134{ 134{
135 struct device_node *np, *old, *cascade = NULL; 135 struct device_node *np, *old, *cascade = NULL;
136 unsigned int *addrp; 136 const unsigned int *addrp;
137 unsigned long intack = 0; 137 unsigned long intack = 0;
138 unsigned int *opprop; 138 const unsigned int *opprop;
139 unsigned long openpic_addr = 0; 139 unsigned long openpic_addr = 0;
140 unsigned int cascade_irq; 140 unsigned int cascade_irq;
141 int naddr, n, i, opplen; 141 int naddr, n, i, opplen;
@@ -143,7 +143,7 @@ static void __init pseries_mpic_init_IRQ(void)
143 143
144 np = of_find_node_by_path("/"); 144 np = of_find_node_by_path("/");
145 naddr = prom_n_addr_cells(np); 145 naddr = prom_n_addr_cells(np);
146 opprop = (unsigned int *) get_property(np, "platform-open-pic", &opplen); 146 opprop = get_property(np, "platform-open-pic", &opplen);
147 if (opprop != 0) { 147 if (opprop != 0) {
148 openpic_addr = of_read_number(opprop, naddr); 148 openpic_addr = of_read_number(opprop, naddr);
149 printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr); 149 printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr);
@@ -192,7 +192,7 @@ static void __init pseries_mpic_init_IRQ(void)
192 break; 192 break;
193 if (strcmp(np->name, "pci") != 0) 193 if (strcmp(np->name, "pci") != 0)
194 continue; 194 continue;
195 addrp = (u32 *)get_property(np, "8259-interrupt-acknowledge", 195 addrp = get_property(np, "8259-interrupt-acknowledge",
196 NULL); 196 NULL);
197 if (addrp == NULL) 197 if (addrp == NULL)
198 continue; 198 continue;
@@ -223,23 +223,37 @@ static void pseries_lpar_enable_pmcs(void)
223} 223}
224 224
225#ifdef CONFIG_KEXEC 225#ifdef CONFIG_KEXEC
226static void pseries_kexec_cpu_down_mpic(int crash_shutdown, int secondary) 226static void pseries_kexec_cpu_down(int crash_shutdown, int secondary)
227{
228 mpic_teardown_this_cpu(secondary);
229}
230
231static void pseries_kexec_cpu_down_xics(int crash_shutdown, int secondary)
232{ 227{
233 /* Don't risk a hypervisor call if we're crashing */ 228 /* Don't risk a hypervisor call if we're crashing */
234 if (firmware_has_feature(FW_FEATURE_SPLPAR) && !crash_shutdown) { 229 if (firmware_has_feature(FW_FEATURE_SPLPAR) && !crash_shutdown) {
235 unsigned long vpa = __pa(get_lppaca()); 230 unsigned long addr;
236 231
237 if (unregister_vpa(hard_smp_processor_id(), vpa)) { 232 addr = __pa(get_slb_shadow());
233 if (unregister_slb_shadow(hard_smp_processor_id(), addr))
234 printk("SLB shadow buffer deregistration of "
235 "cpu %u (hw_cpu_id %d) failed\n",
236 smp_processor_id(),
237 hard_smp_processor_id());
238
239 addr = __pa(get_lppaca());
240 if (unregister_vpa(hard_smp_processor_id(), addr)) {
238 printk("VPA deregistration of cpu %u (hw_cpu_id %d) " 241 printk("VPA deregistration of cpu %u (hw_cpu_id %d) "
239 "failed\n", smp_processor_id(), 242 "failed\n", smp_processor_id(),
240 hard_smp_processor_id()); 243 hard_smp_processor_id());
241 } 244 }
242 } 245 }
246}
247
248static void pseries_kexec_cpu_down_mpic(int crash_shutdown, int secondary)
249{
250 pseries_kexec_cpu_down(crash_shutdown, secondary);
251 mpic_teardown_this_cpu(secondary);
252}
253
254static void pseries_kexec_cpu_down_xics(int crash_shutdown, int secondary)
255{
256 pseries_kexec_cpu_down(crash_shutdown, secondary);
243 xics_teardown_cpu(secondary); 257 xics_teardown_cpu(secondary);
244} 258}
245#endif /* CONFIG_KEXEC */ 259#endif /* CONFIG_KEXEC */
@@ -247,11 +261,11 @@ static void pseries_kexec_cpu_down_xics(int crash_shutdown, int secondary)
247static void __init pseries_discover_pic(void) 261static void __init pseries_discover_pic(void)
248{ 262{
249 struct device_node *np; 263 struct device_node *np;
250 char *typep; 264 const char *typep;
251 265
252 for (np = NULL; (np = of_find_node_by_name(np, 266 for (np = NULL; (np = of_find_node_by_name(np,
253 "interrupt-controller"));) { 267 "interrupt-controller"));) {
254 typep = (char *)get_property(np, "compatible", NULL); 268 typep = get_property(np, "compatible", NULL);
255 if (strstr(typep, "open-pic")) { 269 if (strstr(typep, "open-pic")) {
256 pSeries_mpic_node = of_node_get(np); 270 pSeries_mpic_node = of_node_get(np);
257 ppc_md.init_IRQ = pseries_mpic_init_IRQ; 271 ppc_md.init_IRQ = pseries_mpic_init_IRQ;
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index ac61098ff401..c6624b8a0e77 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -62,7 +62,7 @@
62 */ 62 */
63static cpumask_t of_spin_map; 63static cpumask_t of_spin_map;
64 64
65extern void pSeries_secondary_smp_init(unsigned long); 65extern void generic_secondary_smp_init(unsigned long);
66 66
67#ifdef CONFIG_HOTPLUG_CPU 67#ifdef CONFIG_HOTPLUG_CPU
68 68
@@ -145,9 +145,9 @@ static int pSeries_add_processor(struct device_node *np)
145 unsigned int cpu; 145 unsigned int cpu;
146 cpumask_t candidate_map, tmp = CPU_MASK_NONE; 146 cpumask_t candidate_map, tmp = CPU_MASK_NONE;
147 int err = -ENOSPC, len, nthreads, i; 147 int err = -ENOSPC, len, nthreads, i;
148 u32 *intserv; 148 const u32 *intserv;
149 149
150 intserv = (u32 *)get_property(np, "ibm,ppc-interrupt-server#s", &len); 150 intserv = get_property(np, "ibm,ppc-interrupt-server#s", &len);
151 if (!intserv) 151 if (!intserv)
152 return 0; 152 return 0;
153 153
@@ -205,9 +205,9 @@ static void pSeries_remove_processor(struct device_node *np)
205{ 205{
206 unsigned int cpu; 206 unsigned int cpu;
207 int len, nthreads, i; 207 int len, nthreads, i;
208 u32 *intserv; 208 const u32 *intserv;
209 209
210 intserv = (u32 *)get_property(np, "ibm,ppc-interrupt-server#s", &len); 210 intserv = get_property(np, "ibm,ppc-interrupt-server#s", &len);
211 if (!intserv) 211 if (!intserv)
212 return; 212 return;
213 213
@@ -270,7 +270,7 @@ static inline int __devinit smp_startup_cpu(unsigned int lcpu)
270{ 270{
271 int status; 271 int status;
272 unsigned long start_here = __pa((u32)*((unsigned long *) 272 unsigned long start_here = __pa((u32)*((unsigned long *)
273 pSeries_secondary_smp_init)); 273 generic_secondary_smp_init));
274 unsigned int pcpu; 274 unsigned int pcpu;
275 int start_cpu; 275 int start_cpu;
276 276
diff --git a/arch/powerpc/platforms/pseries/xics.c b/arch/powerpc/platforms/pseries/xics.c
index e98863025721..253972e5479f 100644
--- a/arch/powerpc/platforms/pseries/xics.c
+++ b/arch/powerpc/platforms/pseries/xics.c
@@ -34,6 +34,7 @@
34#include <asm/i8259.h> 34#include <asm/i8259.h>
35 35
36#include "xics.h" 36#include "xics.h"
37#include "plpar_wrappers.h"
37 38
38#define XICS_IPI 2 39#define XICS_IPI 2
39#define XICS_IRQ_SPURIOUS 0 40#define XICS_IRQ_SPURIOUS 0
@@ -110,27 +111,6 @@ static inline void direct_qirr_info(int n_cpu, u8 value)
110/* LPAR low level accessors */ 111/* LPAR low level accessors */
111 112
112 113
113static inline long plpar_eoi(unsigned long xirr)
114{
115 return plpar_hcall_norets(H_EOI, xirr);
116}
117
118static inline long plpar_cppr(unsigned long cppr)
119{
120 return plpar_hcall_norets(H_CPPR, cppr);
121}
122
123static inline long plpar_ipi(unsigned long servernum, unsigned long mfrr)
124{
125 return plpar_hcall_norets(H_IPI, servernum, mfrr);
126}
127
128static inline long plpar_xirr(unsigned long *xirr_ret)
129{
130 unsigned long dummy;
131 return plpar_hcall(H_XIRR, 0, 0, 0, 0, xirr_ret, &dummy, &dummy);
132}
133
134static inline unsigned int lpar_xirr_info_get(int n_cpu) 114static inline unsigned int lpar_xirr_info_get(int n_cpu)
135{ 115{
136 unsigned long lpar_rc; 116 unsigned long lpar_rc;
@@ -590,14 +570,14 @@ static void __init xics_init_one_node(struct device_node *np,
590 unsigned int *indx) 570 unsigned int *indx)
591{ 571{
592 unsigned int ilen; 572 unsigned int ilen;
593 u32 *ireg; 573 const u32 *ireg;
594 574
595 /* This code does the theorically broken assumption that the interrupt 575 /* This code does the theorically broken assumption that the interrupt
596 * server numbers are the same as the hard CPU numbers. 576 * server numbers are the same as the hard CPU numbers.
597 * This happens to be the case so far but we are playing with fire... 577 * This happens to be the case so far but we are playing with fire...
598 * should be fixed one of these days. -BenH. 578 * should be fixed one of these days. -BenH.
599 */ 579 */
600 ireg = (u32 *)get_property(np, "ibm,interrupt-server-ranges", NULL); 580 ireg = get_property(np, "ibm,interrupt-server-ranges", NULL);
601 581
602 /* Do that ever happen ? we'll know soon enough... but even good'old 582 /* Do that ever happen ? we'll know soon enough... but even good'old
603 * f80 does have that property .. 583 * f80 does have that property ..
@@ -609,7 +589,7 @@ static void __init xics_init_one_node(struct device_node *np,
609 */ 589 */
610 *indx = *ireg; 590 *indx = *ireg;
611 } 591 }
612 ireg = (u32 *)get_property(np, "reg", &ilen); 592 ireg = get_property(np, "reg", &ilen);
613 if (!ireg) 593 if (!ireg)
614 panic("xics_init_IRQ: can't find interrupt reg property"); 594 panic("xics_init_IRQ: can't find interrupt reg property");
615 595
@@ -635,7 +615,7 @@ static void __init xics_setup_8259_cascade(void)
635{ 615{
636 struct device_node *np, *old, *found = NULL; 616 struct device_node *np, *old, *found = NULL;
637 int cascade, naddr; 617 int cascade, naddr;
638 u32 *addrp; 618 const u32 *addrp;
639 unsigned long intack = 0; 619 unsigned long intack = 0;
640 620
641 for_each_node_by_type(np, "interrupt-controller") 621 for_each_node_by_type(np, "interrupt-controller")
@@ -661,7 +641,7 @@ static void __init xics_setup_8259_cascade(void)
661 break; 641 break;
662 if (strcmp(np->name, "pci") != 0) 642 if (strcmp(np->name, "pci") != 0)
663 continue; 643 continue;
664 addrp = (u32 *)get_property(np, "8259-interrupt-acknowledge", NULL); 644 addrp = get_property(np, "8259-interrupt-acknowledge", NULL);
665 if (addrp == NULL) 645 if (addrp == NULL)
666 continue; 646 continue;
667 naddr = prom_n_addr_cells(np); 647 naddr = prom_n_addr_cells(np);
@@ -680,7 +660,8 @@ void __init xics_init_IRQ(void)
680{ 660{
681 int i; 661 int i;
682 struct device_node *np; 662 struct device_node *np;
683 u32 *ireg, ilen, indx = 0; 663 u32 ilen, indx = 0;
664 const u32 *ireg;
684 int found = 0; 665 int found = 0;
685 666
686 ppc64_boot_msg(0x20, "XICS Init"); 667 ppc64_boot_msg(0x20, "XICS Init");
@@ -705,18 +686,17 @@ void __init xics_init_IRQ(void)
705 for (np = of_find_node_by_type(NULL, "cpu"); 686 for (np = of_find_node_by_type(NULL, "cpu");
706 np; 687 np;
707 np = of_find_node_by_type(np, "cpu")) { 688 np = of_find_node_by_type(np, "cpu")) {
708 ireg = (u32 *)get_property(np, "reg", &ilen); 689 ireg = get_property(np, "reg", &ilen);
709 if (ireg && ireg[0] == get_hard_smp_processor_id(boot_cpuid)) { 690 if (ireg && ireg[0] == get_hard_smp_processor_id(boot_cpuid)) {
710 ireg = (u32 *)get_property(np, 691 ireg = get_property(np,
711 "ibm,ppc-interrupt-gserver#s", 692 "ibm,ppc-interrupt-gserver#s", &ilen);
712 &ilen);
713 i = ilen / sizeof(int); 693 i = ilen / sizeof(int);
714 if (ireg && i > 0) { 694 if (ireg && i > 0) {
715 default_server = ireg[0]; 695 default_server = ireg[0];
716 /* take last element */ 696 /* take last element */
717 default_distrib_server = ireg[i-1]; 697 default_distrib_server = ireg[i-1];
718 } 698 }
719 ireg = (u32 *)get_property(np, 699 ireg = get_property(np,
720 "ibm,interrupt-server#-size", NULL); 700 "ibm,interrupt-server#-size", NULL);
721 if (ireg) 701 if (ireg)
722 interrupt_server_size = *ireg; 702 interrupt_server_size = *ireg;
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index ef10bcf2d943..92ba378b7990 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -41,7 +41,7 @@ phys_addr_t get_immrbase(void)
41 soc = of_find_node_by_type(NULL, "soc"); 41 soc = of_find_node_by_type(NULL, "soc");
42 if (soc) { 42 if (soc) {
43 unsigned int size; 43 unsigned int size;
44 void *prop = get_property(soc, "reg", &size); 44 const void *prop = get_property(soc, "reg", &size);
45 immrbase = of_translate_address(soc, prop); 45 immrbase = of_translate_address(soc, prop);
46 of_node_put(soc); 46 of_node_put(soc);
47 }; 47 };
@@ -85,7 +85,7 @@ static int __init gfar_mdio_of_init(void)
85 mdio_data.irq[k] = -1; 85 mdio_data.irq[k] = -1;
86 86
87 while ((child = of_get_next_child(np, child)) != NULL) { 87 while ((child = of_get_next_child(np, child)) != NULL) {
88 u32 *id = get_property(child, "reg", NULL); 88 const u32 *id = get_property(child, "reg", NULL);
89 mdio_data.irq[*id] = irq_of_parse_and_map(child, 0); 89 mdio_data.irq[*id] = irq_of_parse_and_map(child, 0);
90 } 90 }
91 91
@@ -124,10 +124,10 @@ static int __init gfar_of_init(void)
124 struct resource r[4]; 124 struct resource r[4];
125 struct device_node *phy, *mdio; 125 struct device_node *phy, *mdio;
126 struct gianfar_platform_data gfar_data; 126 struct gianfar_platform_data gfar_data;
127 unsigned int *id; 127 const unsigned int *id;
128 char *model; 128 const char *model;
129 void *mac_addr; 129 const void *mac_addr;
130 phandle *ph; 130 const phandle *ph;
131 int n_res = 1; 131 int n_res = 1;
132 132
133 memset(r, 0, sizeof(r)); 133 memset(r, 0, sizeof(r));
@@ -193,7 +193,7 @@ static int __init gfar_of_init(void)
193 FSL_GIANFAR_DEV_HAS_VLAN | 193 FSL_GIANFAR_DEV_HAS_VLAN |
194 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH; 194 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH;
195 195
196 ph = (phandle *) get_property(np, "phy-handle", NULL); 196 ph = get_property(np, "phy-handle", NULL);
197 phy = of_find_node_by_phandle(*ph); 197 phy = of_find_node_by_phandle(*ph);
198 198
199 if (phy == NULL) { 199 if (phy == NULL) {
@@ -203,7 +203,7 @@ static int __init gfar_of_init(void)
203 203
204 mdio = of_get_parent(phy); 204 mdio = of_get_parent(phy);
205 205
206 id = (u32 *) get_property(phy, "reg", NULL); 206 id = get_property(phy, "reg", NULL);
207 ret = of_address_to_resource(mdio, 0, &res); 207 ret = of_address_to_resource(mdio, 0, &res);
208 if (ret) { 208 if (ret) {
209 of_node_put(phy); 209 of_node_put(phy);
@@ -247,7 +247,7 @@ static int __init fsl_i2c_of_init(void)
247 i++) { 247 i++) {
248 struct resource r[2]; 248 struct resource r[2];
249 struct fsl_i2c_platform_data i2c_data; 249 struct fsl_i2c_platform_data i2c_data;
250 unsigned char *flags = NULL; 250 const unsigned char *flags = NULL;
251 251
252 memset(&r, 0, sizeof(r)); 252 memset(&r, 0, sizeof(r));
253 memset(&i2c_data, 0, sizeof(i2c_data)); 253 memset(&i2c_data, 0, sizeof(i2c_data));
@@ -298,7 +298,7 @@ static int __init mpc83xx_wdt_init(void)
298 struct resource r; 298 struct resource r;
299 struct device_node *soc, *np; 299 struct device_node *soc, *np;
300 struct platform_device *dev; 300 struct platform_device *dev;
301 unsigned int *freq; 301 const unsigned int *freq;
302 int ret; 302 int ret;
303 303
304 np = of_find_compatible_node(NULL, "watchdog", "mpc83xx_wdt"); 304 np = of_find_compatible_node(NULL, "watchdog", "mpc83xx_wdt");
@@ -315,7 +315,7 @@ static int __init mpc83xx_wdt_init(void)
315 goto nosoc; 315 goto nosoc;
316 } 316 }
317 317
318 freq = (unsigned int *)get_property(soc, "bus-frequency", NULL); 318 freq = get_property(soc, "bus-frequency", NULL);
319 if (!freq) { 319 if (!freq) {
320 ret = -ENODEV; 320 ret = -ENODEV;
321 goto err; 321 goto err;
@@ -355,7 +355,7 @@ nodev:
355arch_initcall(mpc83xx_wdt_init); 355arch_initcall(mpc83xx_wdt_init);
356#endif 356#endif
357 357
358static enum fsl_usb2_phy_modes determine_usb_phy(char * phy_type) 358static enum fsl_usb2_phy_modes determine_usb_phy(const char *phy_type)
359{ 359{
360 if (!phy_type) 360 if (!phy_type)
361 return FSL_USB2_PHY_NONE; 361 return FSL_USB2_PHY_NONE;
@@ -383,7 +383,7 @@ static int __init fsl_usb_of_init(void)
383 i++) { 383 i++) {
384 struct resource r[2]; 384 struct resource r[2];
385 struct fsl_usb2_platform_data usb_data; 385 struct fsl_usb2_platform_data usb_data;
386 unsigned char *prop = NULL; 386 const unsigned char *prop = NULL;
387 387
388 memset(&r, 0, sizeof(r)); 388 memset(&r, 0, sizeof(r));
389 memset(&usb_data, 0, sizeof(usb_data)); 389 memset(&usb_data, 0, sizeof(usb_data));
@@ -431,7 +431,7 @@ static int __init fsl_usb_of_init(void)
431 i++) { 431 i++) {
432 struct resource r[2]; 432 struct resource r[2];
433 struct fsl_usb2_platform_data usb_data; 433 struct fsl_usb2_platform_data usb_data;
434 unsigned char *prop = NULL; 434 const unsigned char *prop = NULL;
435 435
436 memset(&r, 0, sizeof(r)); 436 memset(&r, 0, sizeof(r));
437 memset(&usb_data, 0, sizeof(usb_data)); 437 memset(&usb_data, 0, sizeof(usb_data));
diff --git a/arch/powerpc/sysdev/fsl_soc.h b/arch/powerpc/sysdev/fsl_soc.h
index c433d3f39edd..5a3dd480d2fd 100644
--- a/arch/powerpc/sysdev/fsl_soc.h
+++ b/arch/powerpc/sysdev/fsl_soc.h
@@ -2,6 +2,8 @@
2#define __PPC_FSL_SOC_H 2#define __PPC_FSL_SOC_H
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5#include <asm/mmu.h>
6
5extern phys_addr_t get_immrbase(void); 7extern phys_addr_t get_immrbase(void);
6 8
7#endif 9#endif
diff --git a/arch/powerpc/sysdev/i8259.c b/arch/powerpc/sysdev/i8259.c
index 9855820b9548..26a6a3becd66 100644
--- a/arch/powerpc/sysdev/i8259.c
+++ b/arch/powerpc/sysdev/i8259.c
@@ -224,7 +224,7 @@ static struct irq_host_ops i8259_host_ops = {
224 .xlate = i8259_host_xlate, 224 .xlate = i8259_host_xlate,
225}; 225};
226 226
227/**** 227/**
228 * i8259_init - Initialize the legacy controller 228 * i8259_init - Initialize the legacy controller
229 * @node: device node of the legacy PIC (can be NULL, but then, it will match 229 * @node: device node of the legacy PIC (can be NULL, but then, it will match
230 * all interrupts, so beware) 230 * all interrupts, so beware)
diff --git a/arch/powerpc/sysdev/ipic.c b/arch/powerpc/sysdev/ipic.c
index 70e707785d49..0251b7c68d0e 100644
--- a/arch/powerpc/sysdev/ipic.c
+++ b/arch/powerpc/sysdev/ipic.c
@@ -210,7 +210,7 @@ static struct ipic_info ipic_info[] = {
210 .prio_mask = 4, 210 .prio_mask = 4,
211 }, 211 },
212 [64] = { 212 [64] = {
213 .pend = IPIC_SIPNR_H, 213 .pend = IPIC_SIPNR_L,
214 .mask = IPIC_SIMSR_L, 214 .mask = IPIC_SIMSR_L,
215 .prio = IPIC_SMPRR_A, 215 .prio = IPIC_SMPRR_A,
216 .force = IPIC_SIFCR_L, 216 .force = IPIC_SIFCR_L,
@@ -218,7 +218,7 @@ static struct ipic_info ipic_info[] = {
218 .prio_mask = 0, 218 .prio_mask = 0,
219 }, 219 },
220 [65] = { 220 [65] = {
221 .pend = IPIC_SIPNR_H, 221 .pend = IPIC_SIPNR_L,
222 .mask = IPIC_SIMSR_L, 222 .mask = IPIC_SIMSR_L,
223 .prio = IPIC_SMPRR_A, 223 .prio = IPIC_SMPRR_A,
224 .force = IPIC_SIFCR_L, 224 .force = IPIC_SIFCR_L,
@@ -226,7 +226,7 @@ static struct ipic_info ipic_info[] = {
226 .prio_mask = 1, 226 .prio_mask = 1,
227 }, 227 },
228 [66] = { 228 [66] = {
229 .pend = IPIC_SIPNR_H, 229 .pend = IPIC_SIPNR_L,
230 .mask = IPIC_SIMSR_L, 230 .mask = IPIC_SIMSR_L,
231 .prio = IPIC_SMPRR_A, 231 .prio = IPIC_SMPRR_A,
232 .force = IPIC_SIFCR_L, 232 .force = IPIC_SIFCR_L,
@@ -234,7 +234,7 @@ static struct ipic_info ipic_info[] = {
234 .prio_mask = 2, 234 .prio_mask = 2,
235 }, 235 },
236 [67] = { 236 [67] = {
237 .pend = IPIC_SIPNR_H, 237 .pend = IPIC_SIPNR_L,
238 .mask = IPIC_SIMSR_L, 238 .mask = IPIC_SIMSR_L,
239 .prio = IPIC_SMPRR_A, 239 .prio = IPIC_SMPRR_A,
240 .force = IPIC_SIFCR_L, 240 .force = IPIC_SIFCR_L,
@@ -242,7 +242,7 @@ static struct ipic_info ipic_info[] = {
242 .prio_mask = 3, 242 .prio_mask = 3,
243 }, 243 },
244 [68] = { 244 [68] = {
245 .pend = IPIC_SIPNR_H, 245 .pend = IPIC_SIPNR_L,
246 .mask = IPIC_SIMSR_L, 246 .mask = IPIC_SIMSR_L,
247 .prio = IPIC_SMPRR_B, 247 .prio = IPIC_SMPRR_B,
248 .force = IPIC_SIFCR_L, 248 .force = IPIC_SIFCR_L,
@@ -250,7 +250,7 @@ static struct ipic_info ipic_info[] = {
250 .prio_mask = 0, 250 .prio_mask = 0,
251 }, 251 },
252 [69] = { 252 [69] = {
253 .pend = IPIC_SIPNR_H, 253 .pend = IPIC_SIPNR_L,
254 .mask = IPIC_SIMSR_L, 254 .mask = IPIC_SIMSR_L,
255 .prio = IPIC_SMPRR_B, 255 .prio = IPIC_SMPRR_B,
256 .force = IPIC_SIFCR_L, 256 .force = IPIC_SIFCR_L,
@@ -258,7 +258,7 @@ static struct ipic_info ipic_info[] = {
258 .prio_mask = 1, 258 .prio_mask = 1,
259 }, 259 },
260 [70] = { 260 [70] = {
261 .pend = IPIC_SIPNR_H, 261 .pend = IPIC_SIPNR_L,
262 .mask = IPIC_SIMSR_L, 262 .mask = IPIC_SIMSR_L,
263 .prio = IPIC_SMPRR_B, 263 .prio = IPIC_SMPRR_B,
264 .force = IPIC_SIFCR_L, 264 .force = IPIC_SIFCR_L,
@@ -266,7 +266,7 @@ static struct ipic_info ipic_info[] = {
266 .prio_mask = 2, 266 .prio_mask = 2,
267 }, 267 },
268 [71] = { 268 [71] = {
269 .pend = IPIC_SIPNR_H, 269 .pend = IPIC_SIPNR_L,
270 .mask = IPIC_SIMSR_L, 270 .mask = IPIC_SIMSR_L,
271 .prio = IPIC_SMPRR_B, 271 .prio = IPIC_SMPRR_B,
272 .force = IPIC_SIFCR_L, 272 .force = IPIC_SIFCR_L,
@@ -274,91 +274,91 @@ static struct ipic_info ipic_info[] = {
274 .prio_mask = 3, 274 .prio_mask = 3,
275 }, 275 },
276 [72] = { 276 [72] = {
277 .pend = IPIC_SIPNR_H, 277 .pend = IPIC_SIPNR_L,
278 .mask = IPIC_SIMSR_L, 278 .mask = IPIC_SIMSR_L,
279 .prio = 0, 279 .prio = 0,
280 .force = IPIC_SIFCR_L, 280 .force = IPIC_SIFCR_L,
281 .bit = 8, 281 .bit = 8,
282 }, 282 },
283 [73] = { 283 [73] = {
284 .pend = IPIC_SIPNR_H, 284 .pend = IPIC_SIPNR_L,
285 .mask = IPIC_SIMSR_L, 285 .mask = IPIC_SIMSR_L,
286 .prio = 0, 286 .prio = 0,
287 .force = IPIC_SIFCR_L, 287 .force = IPIC_SIFCR_L,
288 .bit = 9, 288 .bit = 9,
289 }, 289 },
290 [74] = { 290 [74] = {
291 .pend = IPIC_SIPNR_H, 291 .pend = IPIC_SIPNR_L,
292 .mask = IPIC_SIMSR_L, 292 .mask = IPIC_SIMSR_L,
293 .prio = 0, 293 .prio = 0,
294 .force = IPIC_SIFCR_L, 294 .force = IPIC_SIFCR_L,
295 .bit = 10, 295 .bit = 10,
296 }, 296 },
297 [75] = { 297 [75] = {
298 .pend = IPIC_SIPNR_H, 298 .pend = IPIC_SIPNR_L,
299 .mask = IPIC_SIMSR_L, 299 .mask = IPIC_SIMSR_L,
300 .prio = 0, 300 .prio = 0,
301 .force = IPIC_SIFCR_L, 301 .force = IPIC_SIFCR_L,
302 .bit = 11, 302 .bit = 11,
303 }, 303 },
304 [76] = { 304 [76] = {
305 .pend = IPIC_SIPNR_H, 305 .pend = IPIC_SIPNR_L,
306 .mask = IPIC_SIMSR_L, 306 .mask = IPIC_SIMSR_L,
307 .prio = 0, 307 .prio = 0,
308 .force = IPIC_SIFCR_L, 308 .force = IPIC_SIFCR_L,
309 .bit = 12, 309 .bit = 12,
310 }, 310 },
311 [77] = { 311 [77] = {
312 .pend = IPIC_SIPNR_H, 312 .pend = IPIC_SIPNR_L,
313 .mask = IPIC_SIMSR_L, 313 .mask = IPIC_SIMSR_L,
314 .prio = 0, 314 .prio = 0,
315 .force = IPIC_SIFCR_L, 315 .force = IPIC_SIFCR_L,
316 .bit = 13, 316 .bit = 13,
317 }, 317 },
318 [78] = { 318 [78] = {
319 .pend = IPIC_SIPNR_H, 319 .pend = IPIC_SIPNR_L,
320 .mask = IPIC_SIMSR_L, 320 .mask = IPIC_SIMSR_L,
321 .prio = 0, 321 .prio = 0,
322 .force = IPIC_SIFCR_L, 322 .force = IPIC_SIFCR_L,
323 .bit = 14, 323 .bit = 14,
324 }, 324 },
325 [79] = { 325 [79] = {
326 .pend = IPIC_SIPNR_H, 326 .pend = IPIC_SIPNR_L,
327 .mask = IPIC_SIMSR_L, 327 .mask = IPIC_SIMSR_L,
328 .prio = 0, 328 .prio = 0,
329 .force = IPIC_SIFCR_L, 329 .force = IPIC_SIFCR_L,
330 .bit = 15, 330 .bit = 15,
331 }, 331 },
332 [80] = { 332 [80] = {
333 .pend = IPIC_SIPNR_H, 333 .pend = IPIC_SIPNR_L,
334 .mask = IPIC_SIMSR_L, 334 .mask = IPIC_SIMSR_L,
335 .prio = 0, 335 .prio = 0,
336 .force = IPIC_SIFCR_L, 336 .force = IPIC_SIFCR_L,
337 .bit = 16, 337 .bit = 16,
338 }, 338 },
339 [84] = { 339 [84] = {
340 .pend = IPIC_SIPNR_H, 340 .pend = IPIC_SIPNR_L,
341 .mask = IPIC_SIMSR_L, 341 .mask = IPIC_SIMSR_L,
342 .prio = 0, 342 .prio = 0,
343 .force = IPIC_SIFCR_L, 343 .force = IPIC_SIFCR_L,
344 .bit = 20, 344 .bit = 20,
345 }, 345 },
346 [85] = { 346 [85] = {
347 .pend = IPIC_SIPNR_H, 347 .pend = IPIC_SIPNR_L,
348 .mask = IPIC_SIMSR_L, 348 .mask = IPIC_SIMSR_L,
349 .prio = 0, 349 .prio = 0,
350 .force = IPIC_SIFCR_L, 350 .force = IPIC_SIFCR_L,
351 .bit = 21, 351 .bit = 21,
352 }, 352 },
353 [90] = { 353 [90] = {
354 .pend = IPIC_SIPNR_H, 354 .pend = IPIC_SIPNR_L,
355 .mask = IPIC_SIMSR_L, 355 .mask = IPIC_SIMSR_L,
356 .prio = 0, 356 .prio = 0,
357 .force = IPIC_SIFCR_L, 357 .force = IPIC_SIFCR_L,
358 .bit = 26, 358 .bit = 26,
359 }, 359 },
360 [91] = { 360 [91] = {
361 .pend = IPIC_SIPNR_H, 361 .pend = IPIC_SIPNR_L,
362 .mask = IPIC_SIMSR_L, 362 .mask = IPIC_SIMSR_L,
363 .prio = 0, 363 .prio = 0,
364 .force = IPIC_SIFCR_L, 364 .force = IPIC_SIFCR_L,
diff --git a/arch/powerpc/sysdev/mmio_nvram.c b/arch/powerpc/sysdev/mmio_nvram.c
index 615350d46b52..ff23f5a4d4b9 100644
--- a/arch/powerpc/sysdev/mmio_nvram.c
+++ b/arch/powerpc/sysdev/mmio_nvram.c
@@ -80,7 +80,7 @@ static ssize_t mmio_nvram_get_size(void)
80int __init mmio_nvram_init(void) 80int __init mmio_nvram_init(void)
81{ 81{
82 struct device_node *nvram_node; 82 struct device_node *nvram_node;
83 unsigned long *buffer; 83 const unsigned long *buffer;
84 int proplen; 84 int proplen;
85 unsigned long nvram_addr; 85 unsigned long nvram_addr;
86 int ret; 86 int ret;
@@ -91,7 +91,7 @@ int __init mmio_nvram_init(void)
91 goto out; 91 goto out;
92 92
93 ret = -EIO; 93 ret = -EIO;
94 buffer = (unsigned long *)get_property(nvram_node, "reg", &proplen); 94 buffer = get_property(nvram_node, "reg", &proplen);
95 if (proplen != 2*sizeof(unsigned long)) 95 if (proplen != 2*sizeof(unsigned long))
96 goto out; 96 goto out;
97 97
diff --git a/arch/powerpc/sysdev/tsi108_pci.c b/arch/powerpc/sysdev/tsi108_pci.c
index 2ab06ed3ae73..c28f69bef8e2 100644
--- a/arch/powerpc/sysdev/tsi108_pci.c
+++ b/arch/powerpc/sysdev/tsi108_pci.c
@@ -194,7 +194,7 @@ int __init tsi108_setup_pci(struct device_node *dev)
194 int len; 194 int len;
195 struct pci_controller *hose; 195 struct pci_controller *hose;
196 struct resource rsrc; 196 struct resource rsrc;
197 int *bus_range; 197 const int *bus_range;
198 int primary = 0, has_address = 0; 198 int primary = 0, has_address = 0;
199 199
200 /* PCI Config mapping */ 200 /* PCI Config mapping */
@@ -207,7 +207,7 @@ int __init tsi108_setup_pci(struct device_node *dev)
207 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0); 207 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
208 208
209 /* Get bus range if any */ 209 /* Get bus range if any */
210 bus_range = (int *)get_property(dev, "bus-range", &len); 210 bus_range = get_property(dev, "bus-range", &len);
211 if (bus_range == NULL || len < 2 * sizeof(int)) { 211 if (bus_range == NULL || len < 2 * sizeof(int)) {
212 printk(KERN_WARNING "Can't get bus-range for %s, assume" 212 printk(KERN_WARNING "Can't get bus-range for %s, assume"
213 " bus 0\n", dev->full_name); 213 " bus 0\n", dev->full_name);
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 179b10ced8c7..8adad1444a51 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -137,10 +137,14 @@ static void bootcmds(void);
137static void proccall(void); 137static void proccall(void);
138void dump_segments(void); 138void dump_segments(void);
139static void symbol_lookup(void); 139static void symbol_lookup(void);
140static void xmon_show_stack(unsigned long sp, unsigned long lr,
141 unsigned long pc);
140static void xmon_print_symbol(unsigned long address, const char *mid, 142static void xmon_print_symbol(unsigned long address, const char *mid,
141 const char *after); 143 const char *after);
142static const char *getvecname(unsigned long vec); 144static const char *getvecname(unsigned long vec);
143 145
146int xmon_no_auto_backtrace;
147
144extern int print_insn_powerpc(unsigned long, unsigned long, int); 148extern int print_insn_powerpc(unsigned long, unsigned long, int);
145 149
146extern void xmon_enter(void); 150extern void xmon_enter(void);
@@ -736,6 +740,12 @@ cmds(struct pt_regs *excp)
736 740
737 last_cmd = NULL; 741 last_cmd = NULL;
738 xmon_regs = excp; 742 xmon_regs = excp;
743
744 if (!xmon_no_auto_backtrace) {
745 xmon_no_auto_backtrace = 1;
746 xmon_show_stack(excp->gpr[1], excp->link, excp->nip);
747 }
748
739 for(;;) { 749 for(;;) {
740#ifdef CONFIG_SMP 750#ifdef CONFIG_SMP
741 printf("%x:", smp_processor_id()); 751 printf("%x:", smp_processor_id());
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index a04cdf01596b..8fa10cf661a8 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -1204,7 +1204,7 @@ config PCI_DOMAINS
1204 default PCI 1204 default PCI
1205 1205
1206config MPC83xx_PCI2 1206config MPC83xx_PCI2
1207 bool " Supprt for 2nd PCI host controller" 1207 bool "Support for 2nd PCI host controller"
1208 depends on PCI && MPC834x 1208 depends on PCI && MPC834x
1209 default y if MPC834x_SYS 1209 default y if MPC834x_SYS
1210 1210
@@ -1223,12 +1223,12 @@ config PCI_8260
1223 default y 1223 default y
1224 1224
1225config 8260_PCI9 1225config 8260_PCI9
1226 bool " Enable workaround for MPC826x erratum PCI 9" 1226 bool "Enable workaround for MPC826x erratum PCI 9"
1227 depends on PCI_8260 && !ADS8272 1227 depends on PCI_8260 && !ADS8272
1228 default y 1228 default y
1229 1229
1230choice 1230choice
1231 prompt " IDMA channel for PCI 9 workaround" 1231 prompt "IDMA channel for PCI 9 workaround"
1232 depends on 8260_PCI9 1232 depends on 8260_PCI9
1233 1233
1234config 8260_PCI9_IDMA1 1234config 8260_PCI9_IDMA1
diff --git a/arch/ppc/kernel/misc.S b/arch/ppc/kernel/misc.S
index 2fa0075f2b5f..50b4bbd06804 100644
--- a/arch/ppc/kernel/misc.S
+++ b/arch/ppc/kernel/misc.S
@@ -768,91 +768,6 @@ _GLOBAL(_outsb)
768 bdnz 00b 768 bdnz 00b
769 blr 769 blr
770 770
771_GLOBAL(_insw)
772 cmpwi 0,r5,0
773 mtctr r5
774 subi r4,r4,2
775 blelr-
77600: lhbrx r5,0,r3
77701: eieio
77802: sthu r5,2(r4)
779 ISYNC_8xx
780 .section .fixup,"ax"
78103: blr
782 .text
783 .section __ex_table, "a"
784 .align 2
785 .long 00b, 03b
786 .long 01b, 03b
787 .long 02b, 03b
788 .text
789 bdnz 00b
790 blr
791
792_GLOBAL(_outsw)
793 cmpwi 0,r5,0
794 mtctr r5
795 subi r4,r4,2
796 blelr-
79700: lhzu r5,2(r4)
79801: eieio
79902: sthbrx r5,0,r3
800 ISYNC_8xx
801 .section .fixup,"ax"
80203: blr
803 .text
804 .section __ex_table, "a"
805 .align 2
806 .long 00b, 03b
807 .long 01b, 03b
808 .long 02b, 03b
809 .text
810 bdnz 00b
811 blr
812
813_GLOBAL(_insl)
814 cmpwi 0,r5,0
815 mtctr r5
816 subi r4,r4,4
817 blelr-
81800: lwbrx r5,0,r3
81901: eieio
82002: stwu r5,4(r4)
821 ISYNC_8xx
822 .section .fixup,"ax"
82303: blr
824 .text
825 .section __ex_table, "a"
826 .align 2
827 .long 00b, 03b
828 .long 01b, 03b
829 .long 02b, 03b
830 .text
831 bdnz 00b
832 blr
833
834_GLOBAL(_outsl)
835 cmpwi 0,r5,0
836 mtctr r5
837 subi r4,r4,4
838 blelr-
83900: lwzu r5,4(r4)
84001: stwbrx r5,0,r3
84102: eieio
842 ISYNC_8xx
843 .section .fixup,"ax"
84403: blr
845 .text
846 .section __ex_table, "a"
847 .align 2
848 .long 00b, 03b
849 .long 01b, 03b
850 .long 02b, 03b
851 .text
852 bdnz 00b
853 blr
854
855_GLOBAL(__ide_mm_insw)
856_GLOBAL(_insw_ns) 771_GLOBAL(_insw_ns)
857 cmpwi 0,r5,0 772 cmpwi 0,r5,0
858 mtctr r5 773 mtctr r5
@@ -874,7 +789,6 @@ _GLOBAL(_insw_ns)
874 bdnz 00b 789 bdnz 00b
875 blr 790 blr
876 791
877_GLOBAL(__ide_mm_outsw)
878_GLOBAL(_outsw_ns) 792_GLOBAL(_outsw_ns)
879 cmpwi 0,r5,0 793 cmpwi 0,r5,0
880 mtctr r5 794 mtctr r5
@@ -896,7 +810,6 @@ _GLOBAL(_outsw_ns)
896 bdnz 00b 810 bdnz 00b
897 blr 811 blr
898 812
899_GLOBAL(__ide_mm_insl)
900_GLOBAL(_insl_ns) 813_GLOBAL(_insl_ns)
901 cmpwi 0,r5,0 814 cmpwi 0,r5,0
902 mtctr r5 815 mtctr r5
@@ -918,7 +831,6 @@ _GLOBAL(_insl_ns)
918 bdnz 00b 831 bdnz 00b
919 blr 832 blr
920 833
921_GLOBAL(__ide_mm_outsl)
922_GLOBAL(_outsl_ns) 834_GLOBAL(_outsl_ns)
923 cmpwi 0,r5,0 835 cmpwi 0,r5,0
924 mtctr r5 836 mtctr r5
diff --git a/arch/ppc/kernel/ppc_ksyms.c b/arch/ppc/kernel/ppc_ksyms.c
index d1735401384c..c8b65ca8a350 100644
--- a/arch/ppc/kernel/ppc_ksyms.c
+++ b/arch/ppc/kernel/ppc_ksyms.c
@@ -115,17 +115,8 @@ EXPORT_SYMBOL(outw);
115EXPORT_SYMBOL(outl); 115EXPORT_SYMBOL(outl);
116EXPORT_SYMBOL(outsl);*/ 116EXPORT_SYMBOL(outsl);*/
117 117
118EXPORT_SYMBOL(__ide_mm_insl);
119EXPORT_SYMBOL(__ide_mm_outsw);
120EXPORT_SYMBOL(__ide_mm_insw);
121EXPORT_SYMBOL(__ide_mm_outsl);
122
123EXPORT_SYMBOL(_insb); 118EXPORT_SYMBOL(_insb);
124EXPORT_SYMBOL(_outsb); 119EXPORT_SYMBOL(_outsb);
125EXPORT_SYMBOL(_insw);
126EXPORT_SYMBOL(_outsw);
127EXPORT_SYMBOL(_insl);
128EXPORT_SYMBOL(_outsl);
129EXPORT_SYMBOL(_insw_ns); 120EXPORT_SYMBOL(_insw_ns);
130EXPORT_SYMBOL(_outsw_ns); 121EXPORT_SYMBOL(_outsw_ns);
131EXPORT_SYMBOL(_insl_ns); 122EXPORT_SYMBOL(_insl_ns);
diff --git a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
index a74f46d9826f..5458ac5da7c3 100644
--- a/arch/ppc/kernel/setup.c
+++ b/arch/ppc/kernel/setup.c
@@ -127,11 +127,8 @@ void machine_restart(char *cmd)
127 ppc_md.restart(cmd); 127 ppc_md.restart(cmd);
128} 128}
129 129
130void machine_power_off(void) 130static void ppc_generic_power_off(void)
131{ 131{
132#ifdef CONFIG_NVRAM
133 nvram_sync();
134#endif
135 ppc_md.power_off(); 132 ppc_md.power_off();
136} 133}
137 134
@@ -143,7 +140,17 @@ void machine_halt(void)
143 ppc_md.halt(); 140 ppc_md.halt();
144} 141}
145 142
146void (*pm_power_off)(void) = machine_power_off; 143void (*pm_power_off)(void) = ppc_generic_power_off;
144
145void machine_power_off(void)
146{
147#ifdef CONFIG_NVRAM
148 nvram_sync();
149#endif
150 if (pm_power_off)
151 pm_power_off();
152 ppc_generic_power_off();
153}
147 154
148#ifdef CONFIG_TAU 155#ifdef CONFIG_TAU
149extern u32 cpu_temp(unsigned long cpu); 156extern u32 cpu_temp(unsigned long cpu);
diff --git a/arch/ppc/platforms/85xx/sbc8560.h b/arch/ppc/platforms/85xx/sbc8560.h
index c7d61cf3a449..e5e156f60100 100644
--- a/arch/ppc/platforms/85xx/sbc8560.h
+++ b/arch/ppc/platforms/85xx/sbc8560.h
@@ -14,6 +14,7 @@
14#define __MACH_SBC8560_H__ 14#define __MACH_SBC8560_H__
15 15
16#include <platforms/85xx/sbc85xx.h> 16#include <platforms/85xx/sbc85xx.h>
17#include <asm/irq.h>
17 18
18#define CPM_MAP_ADDR (CCSRBAR + MPC85xx_CPM_OFFSET) 19#define CPM_MAP_ADDR (CCSRBAR + MPC85xx_CPM_OFFSET)
19 20
diff --git a/arch/ppc/platforms/85xx/sbc85xx.h b/arch/ppc/platforms/85xx/sbc85xx.h
index 21ea7a55639b..51df4dc04e22 100644
--- a/arch/ppc/platforms/85xx/sbc85xx.h
+++ b/arch/ppc/platforms/85xx/sbc85xx.h
@@ -49,4 +49,22 @@ extern void sbc8560_init_IRQ(void) __init;
49 49
50#define MPC85XX_PCI1_IO_SIZE 0x01000000 50#define MPC85XX_PCI1_IO_SIZE 0x01000000
51 51
52/* FCC1 Clock Source Configuration. These can be
53 * redefined in the board specific file.
54 * Can only choose from CLK9-12 */
55#define F1_RXCLK 12
56#define F1_TXCLK 11
57
58/* FCC2 Clock Source Configuration. These can be
59 * redefined in the board specific file.
60 * Can only choose from CLK13-16 */
61#define F2_RXCLK 13
62#define F2_TXCLK 14
63
64/* FCC3 Clock Source Configuration. These can be
65 * redefined in the board specific file.
66 * Can only choose from CLK13-16 */
67#define F3_RXCLK 15
68#define F3_TXCLK 16
69
52#endif /* __PLATFORMS_85XX_SBC85XX_H__ */ 70#endif /* __PLATFORMS_85XX_SBC85XX_H__ */
diff --git a/arch/ppc/syslib/m8260_pci_erratum9.c b/arch/ppc/syslib/m8260_pci_erratum9.c
index 974581ea4849..5475709ce07b 100644
--- a/arch/ppc/syslib/m8260_pci_erratum9.c
+++ b/arch/ppc/syslib/m8260_pci_erratum9.c
@@ -339,20 +339,6 @@ void insl(unsigned port, void *buf, int nl)
339 idma_pci9_read((u8 *)buf, (u8 *)addr, nl*sizeof(u32), sizeof(u32), 0); 339 idma_pci9_read((u8 *)buf, (u8 *)addr, nl*sizeof(u32), sizeof(u32), 0);
340} 340}
341 341
342void insw_ns(unsigned port, void *buf, int ns)
343{
344 u8 *addr = (u8 *)(port + _IO_BASE);
345
346 idma_pci9_read((u8 *)buf, (u8 *)addr, ns*sizeof(u16), sizeof(u16), 0);
347}
348
349void insl_ns(unsigned port, void *buf, int nl)
350{
351 u8 *addr = (u8 *)(port + _IO_BASE);
352
353 idma_pci9_read((u8 *)buf, (u8 *)addr, nl*sizeof(u32), sizeof(u32), 0);
354}
355
356void *memcpy_fromio(void *dest, unsigned long src, size_t count) 342void *memcpy_fromio(void *dest, unsigned long src, size_t count)
357{ 343{
358 unsigned long pa = iopa((unsigned long) src); 344 unsigned long pa = iopa((unsigned long) src);
@@ -373,8 +359,6 @@ EXPORT_SYMBOL(inl);
373EXPORT_SYMBOL(insb); 359EXPORT_SYMBOL(insb);
374EXPORT_SYMBOL(insw); 360EXPORT_SYMBOL(insw);
375EXPORT_SYMBOL(insl); 361EXPORT_SYMBOL(insl);
376EXPORT_SYMBOL(insw_ns);
377EXPORT_SYMBOL(insl_ns);
378EXPORT_SYMBOL(memcpy_fromio); 362EXPORT_SYMBOL(memcpy_fromio);
379 363
380#endif /* ifdef CONFIG_8260_PCI9 */ 364#endif /* ifdef CONFIG_8260_PCI9 */
diff --git a/arch/ppc/xmon/start.c b/arch/ppc/xmon/start.c
index f7e92986952a..d74a883e5bde 100644
--- a/arch/ppc/xmon/start.c
+++ b/arch/ppc/xmon/start.c
@@ -15,6 +15,7 @@
15#include <asm/processor.h> 15#include <asm/processor.h>
16#include <asm/delay.h> 16#include <asm/delay.h>
17#include <asm/btext.h> 17#include <asm/btext.h>
18#include <asm/ibm4xx.h>
18 19
19static volatile unsigned char *sccc, *sccd; 20static volatile unsigned char *sccc, *sccd;
20unsigned int TXRDY, RXRDY, DLAB; 21unsigned int TXRDY, RXRDY, DLAB;
@@ -57,23 +58,30 @@ static struct sysrq_key_op sysrq_xmon_op =
57void 58void
58xmon_map_scc(void) 59xmon_map_scc(void)
59{ 60{
60#ifdef CONFIG_PPC_PREP 61#if defined(CONFIG_GEMINI)
61 volatile unsigned char *base;
62
63#elif defined(CONFIG_GEMINI)
64 /* should already be mapped by the kernel boot */ 62 /* should already be mapped by the kernel boot */
65 sccc = (volatile unsigned char *) 0xffeffb0d;
66 sccd = (volatile unsigned char *) 0xffeffb08; 63 sccd = (volatile unsigned char *) 0xffeffb08;
67 TXRDY = 0x20;
68 RXRDY = 1;
69 DLAB = 0x80;
70#elif defined(CONFIG_405GP) 64#elif defined(CONFIG_405GP)
71 sccc = (volatile unsigned char *)0xef600305;
72 sccd = (volatile unsigned char *)0xef600300; 65 sccd = (volatile unsigned char *)0xef600300;
66#elif defined(CONFIG_440EP)
67 sccd = (volatile unsigned char *) ioremap(PPC440EP_UART0_ADDR, 8);
68#elif defined(CONFIG_440SP)
69 sccd = (volatile unsigned char *) ioremap64(PPC440SP_UART0_ADDR, 8);
70#elif defined(CONFIG_440SPE)
71 sccd = (volatile unsigned char *) ioremap64(PPC440SPE_UART0_ADDR, 8);
72#elif defined(CONFIG_44x)
73 /* This is the default for 44x platforms. Any boards that have a
74 different UART address need to be put in cases before this or the
75 port will be mapped incorrectly */
76 sccd = (volatile unsigned char *) ioremap64(PPC440GP_UART0_ADDR, 8);
77#endif /* platform */
78
79#ifndef CONFIG_PPC_PREP
80 sccc = sccd + 5;
73 TXRDY = 0x20; 81 TXRDY = 0x20;
74 RXRDY = 1; 82 RXRDY = 1;
75 DLAB = 0x80; 83 DLAB = 0x80;
76#endif /* platform */ 84#endif
77 85
78 register_sysrq_key('x', &sysrq_xmon_op); 86 register_sysrq_key('x', &sysrq_xmon_op);
79} 87}
diff --git a/arch/ppc/xmon/xmon.c b/arch/ppc/xmon/xmon.c
index 37d234f93394..b1a91744fd2d 100644
--- a/arch/ppc/xmon/xmon.c
+++ b/arch/ppc/xmon/xmon.c
@@ -153,6 +153,12 @@ static int xmon_trace[NR_CPUS];
153#define SSTEP 1 /* stepping because of 's' command */ 153#define SSTEP 1 /* stepping because of 's' command */
154#define BRSTEP 2 /* stepping over breakpoint */ 154#define BRSTEP 2 /* stepping over breakpoint */
155 155
156#ifdef CONFIG_4xx
157#define MSR_SSTEP_ENABLE 0x200
158#else
159#define MSR_SSTEP_ENABLE 0x400
160#endif
161
156static struct pt_regs *xmon_regs[NR_CPUS]; 162static struct pt_regs *xmon_regs[NR_CPUS];
157 163
158extern inline void sync(void) 164extern inline void sync(void)
@@ -211,6 +217,14 @@ static void get_tb(unsigned *p)
211 p[1] = lo; 217 p[1] = lo;
212} 218}
213 219
220static inline void xmon_enable_sstep(struct pt_regs *regs)
221{
222 regs->msr |= MSR_SSTEP_ENABLE;
223#ifdef CONFIG_4xx
224 mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM);
225#endif
226}
227
214int xmon(struct pt_regs *excp) 228int xmon(struct pt_regs *excp)
215{ 229{
216 struct pt_regs regs; 230 struct pt_regs regs;
@@ -254,10 +268,10 @@ int xmon(struct pt_regs *excp)
254 cmd = cmds(excp); 268 cmd = cmds(excp);
255 if (cmd == 's') { 269 if (cmd == 's') {
256 xmon_trace[smp_processor_id()] = SSTEP; 270 xmon_trace[smp_processor_id()] = SSTEP;
257 excp->msr |= 0x400; 271 xmon_enable_sstep(excp);
258 } else if (at_breakpoint(excp->nip)) { 272 } else if (at_breakpoint(excp->nip)) {
259 xmon_trace[smp_processor_id()] = BRSTEP; 273 xmon_trace[smp_processor_id()] = BRSTEP;
260 excp->msr |= 0x400; 274 xmon_enable_sstep(excp);
261 } else { 275 } else {
262 xmon_trace[smp_processor_id()] = 0; 276 xmon_trace[smp_processor_id()] = 0;
263 insert_bpts(); 277 insert_bpts();
@@ -298,7 +312,7 @@ xmon_bpt(struct pt_regs *regs)
298 remove_bpts(); 312 remove_bpts();
299 excprint(regs); 313 excprint(regs);
300 xmon_trace[smp_processor_id()] = BRSTEP; 314 xmon_trace[smp_processor_id()] = BRSTEP;
301 regs->msr |= 0x400; 315 xmon_enable_sstep(regs);
302 } else { 316 } else {
303 xmon(regs); 317 xmon(regs);
304 } 318 }
@@ -385,7 +399,7 @@ insert_bpts(void)
385 } 399 }
386 store_inst((void *) bp->address); 400 store_inst((void *) bp->address);
387 } 401 }
388#if !defined(CONFIG_8xx) 402#if ! (defined(CONFIG_8xx) || defined(CONFIG_4xx))
389 if (dabr.enabled) 403 if (dabr.enabled)
390 set_dabr(dabr.address); 404 set_dabr(dabr.address);
391 if (iabr.enabled) 405 if (iabr.enabled)
@@ -400,7 +414,7 @@ remove_bpts(void)
400 struct bpt *bp; 414 struct bpt *bp;
401 unsigned instr; 415 unsigned instr;
402 416
403#if !defined(CONFIG_8xx) 417#if ! (defined(CONFIG_8xx) || defined(CONFIG_4xx))
404 set_dabr(0); 418 set_dabr(0);
405 set_iabr(0); 419 set_iabr(0);
406#endif 420#endif
@@ -677,7 +691,7 @@ bpt_cmds(void)
677 691
678 cmd = inchar(); 692 cmd = inchar();
679 switch (cmd) { 693 switch (cmd) {
680#if !defined(CONFIG_8xx) 694#if ! (defined(CONFIG_8xx) || defined(CONFIG_4xx))
681 case 'd': 695 case 'd':
682 mode = 7; 696 mode = 7;
683 cmd = inchar(); 697 cmd = inchar();
@@ -792,7 +806,7 @@ backtrace(struct pt_regs *excp)
792 for (; sp != 0; sp = stack[0]) { 806 for (; sp != 0; sp = stack[0]) {
793 if (mread(sp, stack, sizeof(stack)) != sizeof(stack)) 807 if (mread(sp, stack, sizeof(stack)) != sizeof(stack))
794 break; 808 break;
795 printf("[%.8lx] ", stack); 809 printf("[%.8lx] ", stack[0]);
796 xmon_print_symbol(stack[1], " ", "\n"); 810 xmon_print_symbol(stack[1], " ", "\n");
797 if (stack[1] == (unsigned) &ret_from_except 811 if (stack[1] == (unsigned) &ret_from_except
798 || stack[1] == (unsigned) &ret_from_except_full 812 || stack[1] == (unsigned) &ret_from_except_full
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index c40e487d9f5c..52ea94b891f5 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -495,6 +495,21 @@ config LEGACY_PTY_COUNT
495 When not in use, each legacy PTY occupies 12 bytes on 32-bit 495 When not in use, each legacy PTY occupies 12 bytes on 32-bit
496 architectures and 24 bytes on 64-bit architectures. 496 architectures and 24 bytes on 64-bit architectures.
497 497
498config BRIQ_PANEL
499 tristate 'Total Impact briQ front panel driver'
500 depends on PPC_CHRP
501 ---help---
502 The briQ is a small footprint CHRP computer with a frontpanel VFD, a
503 tristate led and two switches. It is the size of a CDROM drive.
504
505 If you have such one and want anything showing on the VFD then you
506 must answer Y here.
507
508 To compile this driver as a module, choose M here: the
509 module will be called briq_panel.
510
511 It's safe to say N here.
512
498config PRINTER 513config PRINTER
499 tristate "Parallel printer support" 514 tristate "Parallel printer support"
500 depends on PARPORT 515 depends on PARPORT
@@ -596,6 +611,13 @@ config HVC_CONSOLE
596 console. This driver allows each pSeries partition to have a console 611 console. This driver allows each pSeries partition to have a console
597 which is accessed via the HMC. 612 which is accessed via the HMC.
598 613
614config HVC_ISERIES
615 bool "iSeries Hypervisor Virtual Console support"
616 depends on PPC_ISERIES && !VIOCONS
617 select HVC_DRIVER
618 help
619 iSeries machines support a hypervisor virtual console.
620
599config HVC_RTAS 621config HVC_RTAS
600 bool "IBM RTAS Console support" 622 bool "IBM RTAS Console support"
601 depends on PPC_RTAS 623 depends on PPC_RTAS
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 6e0f4469d8bb..8c6dfc621520 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -42,6 +42,7 @@ obj-$(CONFIG_AMIGA_BUILTIN_SERIAL) += amiserial.o
42obj-$(CONFIG_SX) += sx.o generic_serial.o 42obj-$(CONFIG_SX) += sx.o generic_serial.o
43obj-$(CONFIG_RIO) += rio/ generic_serial.o 43obj-$(CONFIG_RIO) += rio/ generic_serial.o
44obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o 44obj-$(CONFIG_HVC_CONSOLE) += hvc_vio.o hvsi.o
45obj-$(CONFIG_HVC_ISERIES) += hvc_iseries.o
45obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o 46obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o
46obj-$(CONFIG_HVC_DRIVER) += hvc_console.o 47obj-$(CONFIG_HVC_DRIVER) += hvc_console.o
47obj-$(CONFIG_RAW_DRIVER) += raw.o 48obj-$(CONFIG_RAW_DRIVER) += raw.o
@@ -51,6 +52,7 @@ obj-$(CONFIG_VIOCONS) += viocons.o
51obj-$(CONFIG_VIOTAPE) += viotape.o 52obj-$(CONFIG_VIOTAPE) += viotape.o
52obj-$(CONFIG_HVCS) += hvcs.o 53obj-$(CONFIG_HVCS) += hvcs.o
53obj-$(CONFIG_SGI_MBCS) += mbcs.o 54obj-$(CONFIG_SGI_MBCS) += mbcs.o
55obj-$(CONFIG_BRIQ_PANEL) += briq_panel.o
54 56
55obj-$(CONFIG_PRINTER) += lp.o 57obj-$(CONFIG_PRINTER) += lp.o
56obj-$(CONFIG_TIPAR) += tipar.o 58obj-$(CONFIG_TIPAR) += tipar.o
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index 1de1b12043bf..91b71e750ee1 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -601,8 +601,8 @@ static int __devinit agp_uninorth_probe(struct pci_dev *pdev,
601 uninorth_node = of_find_node_by_name(NULL, "u3"); 601 uninorth_node = of_find_node_by_name(NULL, "u3");
602 } 602 }
603 if (uninorth_node) { 603 if (uninorth_node) {
604 int *revprop = (int *) 604 const int *revprop = get_property(uninorth_node,
605 get_property(uninorth_node, "device-rev", NULL); 605 "device-rev", NULL);
606 if (revprop != NULL) 606 if (revprop != NULL)
607 uninorth_rev = *revprop & 0x3f; 607 uninorth_rev = *revprop & 0x3f;
608 of_node_put(uninorth_node); 608 of_node_put(uninorth_node);
diff --git a/drivers/char/briq_panel.c b/drivers/char/briq_panel.c
new file mode 100644
index 000000000000..a0e5eac5f33a
--- /dev/null
+++ b/drivers/char/briq_panel.c
@@ -0,0 +1,268 @@
1/*
2 * Drivers for the Total Impact PPC based computer "BRIQ"
3 * by Dr. Karsten Jeppesen
4 *
5 */
6
7#include <linux/module.h>
8
9#include <linux/types.h>
10#include <linux/errno.h>
11#include <linux/sched.h>
12#include <linux/tty.h>
13#include <linux/timer.h>
14#include <linux/config.h>
15#include <linux/kernel.h>
16#include <linux/wait.h>
17#include <linux/string.h>
18#include <linux/slab.h>
19#include <linux/ioport.h>
20#include <linux/delay.h>
21#include <linux/miscdevice.h>
22#include <linux/fs.h>
23#include <linux/mm.h>
24#include <linux/init.h>
25
26#include <asm/uaccess.h>
27#include <asm/io.h>
28#include <asm/prom.h>
29
30#define BRIQ_PANEL_MINOR 156
31#define BRIQ_PANEL_VFD_IOPORT 0x0390
32#define BRIQ_PANEL_LED_IOPORT 0x0398
33#define BRIQ_PANEL_VER "1.1 (04/20/2002)"
34#define BRIQ_PANEL_MSG0 "Loading Linux"
35
36static int vfd_is_open;
37static unsigned char vfd[40];
38static int vfd_cursor;
39static unsigned char ledpb, led;
40
41static void update_vfd(void)
42{
43 int i;
44
45 /* cursor home */
46 outb(0x02, BRIQ_PANEL_VFD_IOPORT);
47 for (i=0; i<20; i++)
48 outb(vfd[i], BRIQ_PANEL_VFD_IOPORT + 1);
49
50 /* cursor to next line */
51 outb(0xc0, BRIQ_PANEL_VFD_IOPORT);
52 for (i=20; i<40; i++)
53 outb(vfd[i], BRIQ_PANEL_VFD_IOPORT + 1);
54
55}
56
57static void set_led(char state)
58{
59 if (state == 'R')
60 led = 0x01;
61 else if (state == 'G')
62 led = 0x02;
63 else if (state == 'Y')
64 led = 0x03;
65 else if (state == 'X')
66 led = 0x00;
67 outb(led, BRIQ_PANEL_LED_IOPORT);
68}
69
70static int briq_panel_open(struct inode *ino, struct file *filep)
71{
72 /* enforce single access */
73 if (vfd_is_open)
74 return -EBUSY;
75 vfd_is_open = 1;
76
77 return 0;
78}
79
80static int briq_panel_release(struct inode *ino, struct file *filep)
81{
82 if (!vfd_is_open)
83 return -ENODEV;
84
85 vfd_is_open = 0;
86
87 return 0;
88}
89
90static ssize_t briq_panel_read(struct file *file, char *buf, size_t count,
91 loff_t *ppos)
92{
93 unsigned short c;
94 unsigned char cp;
95
96#if 0 /* Can't seek (pread) on this device */
97 if (ppos != &file->f_pos)
98 return -ESPIPE;
99#endif
100
101 if (!vfd_is_open)
102 return -ENODEV;
103
104 c = (inb(BRIQ_PANEL_LED_IOPORT) & 0x000c) | (ledpb & 0x0003);
105 set_led(' ');
106 /* upper button released */
107 if ((!(ledpb & 0x0004)) && (c & 0x0004)) {
108 cp = ' ';
109 ledpb = c;
110 if (copy_to_user(buf, &cp, 1))
111 return -EFAULT;
112 return 1;
113 }
114 /* lower button released */
115 else if ((!(ledpb & 0x0008)) && (c & 0x0008)) {
116 cp = '\r';
117 ledpb = c;
118 if (copy_to_user(buf, &cp, 1))
119 return -EFAULT;
120 return 1;
121 } else {
122 ledpb = c;
123 return 0;
124 }
125}
126
127static void scroll_vfd( void )
128{
129 int i;
130
131 for (i=0; i<20; i++) {
132 vfd[i] = vfd[i+20];
133 vfd[i+20] = ' ';
134 }
135 vfd_cursor = 20;
136}
137
138static ssize_t briq_panel_write(struct file *file, const char *buf, size_t len,
139 loff_t *ppos)
140{
141 size_t indx = len;
142 int i, esc = 0;
143
144#if 0 /* Can't seek (pwrite) on this device */
145 if (ppos != &file->f_pos)
146 return -ESPIPE;
147#endif
148
149 if (!vfd_is_open)
150 return -EBUSY;
151
152 for (;;) {
153 if (!indx)
154 break;
155 if (esc) {
156 set_led(*buf);
157 esc = 0;
158 } else if (*buf == 27) {
159 esc = 1;
160 } else if (*buf == 12) {
161 /* do a form feed */
162 for (i=0; i<40; i++)
163 vfd[i] = ' ';
164 vfd_cursor = 0;
165 } else if (*buf == 10) {
166 if (vfd_cursor < 20)
167 vfd_cursor = 20;
168 else if (vfd_cursor < 40)
169 vfd_cursor = 40;
170 else if (vfd_cursor < 60)
171 vfd_cursor = 60;
172 if (vfd_cursor > 59)
173 scroll_vfd();
174 } else {
175 /* just a character */
176 if (vfd_cursor > 39)
177 scroll_vfd();
178 vfd[vfd_cursor++] = *buf;
179 }
180 indx--;
181 buf++;
182 }
183 update_vfd();
184
185 return len;
186}
187
188static struct file_operations briq_panel_fops = {
189 .owner = THIS_MODULE,
190 .read = briq_panel_read,
191 .write = briq_panel_write,
192 .open = briq_panel_open,
193 .release = briq_panel_release,
194};
195
196static struct miscdevice briq_panel_miscdev = {
197 BRIQ_PANEL_MINOR,
198 "briq_panel",
199 &briq_panel_fops
200};
201
202static int __init briq_panel_init(void)
203{
204 struct device_node *root = find_path_device("/");
205 char *machine;
206 int i;
207
208 machine = get_property(root, "model", NULL);
209 if (!machine || strncmp(machine, "TotalImpact,BRIQ-1", 18) != 0)
210 return -ENODEV;
211
212 printk(KERN_INFO
213 "briq_panel: v%s Dr. Karsten Jeppesen (kj@totalimpact.com)\n",
214 BRIQ_PANEL_VER);
215
216 if (!request_region(BRIQ_PANEL_VFD_IOPORT, 4, "BRIQ Front Panel"))
217 return -EBUSY;
218
219 if (!request_region(BRIQ_PANEL_LED_IOPORT, 2, "BRIQ Front Panel")) {
220 release_region(BRIQ_PANEL_VFD_IOPORT, 4);
221 return -EBUSY;
222 }
223 ledpb = inb(BRIQ_PANEL_LED_IOPORT) & 0x000c;
224
225 if (misc_register(&briq_panel_miscdev) < 0) {
226 release_region(BRIQ_PANEL_VFD_IOPORT, 4);
227 release_region(BRIQ_PANEL_LED_IOPORT, 2);
228 return -EBUSY;
229 }
230
231 outb(0x38, BRIQ_PANEL_VFD_IOPORT); /* Function set */
232 outb(0x01, BRIQ_PANEL_VFD_IOPORT); /* Clear display */
233 outb(0x0c, BRIQ_PANEL_VFD_IOPORT); /* Display on */
234 outb(0x06, BRIQ_PANEL_VFD_IOPORT); /* Entry normal */
235 for (i=0; i<40; i++)
236 vfd[i]=' ';
237#ifndef MODULE
238 vfd[0] = 'L';
239 vfd[1] = 'o';
240 vfd[2] = 'a';
241 vfd[3] = 'd';
242 vfd[4] = 'i';
243 vfd[5] = 'n';
244 vfd[6] = 'g';
245 vfd[7] = ' ';
246 vfd[8] = '.';
247 vfd[9] = '.';
248 vfd[10] = '.';
249#endif /* !MODULE */
250
251 update_vfd();
252
253 return 0;
254}
255
256static void __exit briq_panel_exit(void)
257{
258 misc_deregister(&briq_panel_miscdev);
259 release_region(BRIQ_PANEL_VFD_IOPORT, 4);
260 release_region(BRIQ_PANEL_LED_IOPORT, 2);
261}
262
263module_init(briq_panel_init);
264module_exit(briq_panel_exit);
265
266MODULE_LICENSE("GPL");
267MODULE_AUTHOR("Karsten Jeppesen <karsten@jeppesens.com>");
268MODULE_DESCRIPTION("Driver for the Total Impact briQ front panel");
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index 613d67f1c7f0..a76d2c40dd5e 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -80,7 +80,8 @@ struct hvc_struct {
80 struct tty_struct *tty; 80 struct tty_struct *tty;
81 unsigned int count; 81 unsigned int count;
82 int do_wakeup; 82 int do_wakeup;
83 char outbuf[N_OUTBUF] __ALIGNED__; 83 char *outbuf;
84 int outbuf_size;
84 int n_outbuf; 85 int n_outbuf;
85 uint32_t vtermno; 86 uint32_t vtermno;
86 struct hv_ops *ops; 87 struct hv_ops *ops;
@@ -319,10 +320,8 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
319 struct kobject *kobjp; 320 struct kobject *kobjp;
320 321
321 /* Auto increments kobject reference if found. */ 322 /* Auto increments kobject reference if found. */
322 if (!(hp = hvc_get_by_index(tty->index))) { 323 if (!(hp = hvc_get_by_index(tty->index)))
323 printk(KERN_WARNING "hvc_console: tty open failed, no vty associated with tty.\n");
324 return -ENODEV; 324 return -ENODEV;
325 }
326 325
327 spin_lock_irqsave(&hp->lock, flags); 326 spin_lock_irqsave(&hp->lock, flags);
328 /* Check and then increment for fast path open. */ 327 /* Check and then increment for fast path open. */
@@ -505,7 +504,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
505 if (hp->n_outbuf > 0) 504 if (hp->n_outbuf > 0)
506 hvc_push(hp); 505 hvc_push(hp);
507 506
508 while (count > 0 && (rsize = N_OUTBUF - hp->n_outbuf) > 0) { 507 while (count > 0 && (rsize = hp->outbuf_size - hp->n_outbuf) > 0) {
509 if (rsize > count) 508 if (rsize > count)
510 rsize = count; 509 rsize = count;
511 memcpy(hp->outbuf + hp->n_outbuf, buf, rsize); 510 memcpy(hp->outbuf + hp->n_outbuf, buf, rsize);
@@ -538,7 +537,7 @@ static int hvc_write_room(struct tty_struct *tty)
538 if (!hp) 537 if (!hp)
539 return -1; 538 return -1;
540 539
541 return N_OUTBUF - hp->n_outbuf; 540 return hp->outbuf_size - hp->n_outbuf;
542} 541}
543 542
544static int hvc_chars_in_buffer(struct tty_struct *tty) 543static int hvc_chars_in_buffer(struct tty_struct *tty)
@@ -729,12 +728,13 @@ static struct kobj_type hvc_kobj_type = {
729}; 728};
730 729
731struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq, 730struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq,
732 struct hv_ops *ops) 731 struct hv_ops *ops, int outbuf_size)
733{ 732{
734 struct hvc_struct *hp; 733 struct hvc_struct *hp;
735 int i; 734 int i;
736 735
737 hp = kmalloc(sizeof(*hp), GFP_KERNEL); 736 hp = kmalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size,
737 GFP_KERNEL);
738 if (!hp) 738 if (!hp)
739 return ERR_PTR(-ENOMEM); 739 return ERR_PTR(-ENOMEM);
740 740
@@ -743,6 +743,8 @@ struct hvc_struct __devinit *hvc_alloc(uint32_t vtermno, int irq,
743 hp->vtermno = vtermno; 743 hp->vtermno = vtermno;
744 hp->irq = irq; 744 hp->irq = irq;
745 hp->ops = ops; 745 hp->ops = ops;
746 hp->outbuf_size = outbuf_size;
747 hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))];
746 748
747 kobject_init(&hp->kobj); 749 kobject_init(&hp->kobj);
748 hp->kobj.ktype = &hvc_kobj_type; 750 hp->kobj.ktype = &hvc_kobj_type;
diff --git a/drivers/char/hvc_console.h b/drivers/char/hvc_console.h
index 96b7401319c1..8c59818050e6 100644
--- a/drivers/char/hvc_console.h
+++ b/drivers/char/hvc_console.h
@@ -56,7 +56,7 @@ extern int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops);
56 56
57/* register a vterm for hvc tty operation (module_init or hotplug add) */ 57/* register a vterm for hvc tty operation (module_init or hotplug add) */
58extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int irq, 58extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int irq,
59 struct hv_ops *ops); 59 struct hv_ops *ops, int outbuf_size);
60/* remove a vterm from hvc tty operation (modele_exit or hotplug remove) */ 60/* remove a vterm from hvc tty operation (modele_exit or hotplug remove) */
61extern int __devexit hvc_remove(struct hvc_struct *hp); 61extern int __devexit hvc_remove(struct hvc_struct *hp);
62 62
diff --git a/drivers/char/hvc_iseries.c b/drivers/char/hvc_iseries.c
new file mode 100644
index 000000000000..4747729459c7
--- /dev/null
+++ b/drivers/char/hvc_iseries.c
@@ -0,0 +1,594 @@
1/*
2 * iSeries vio driver interface to hvc_console.c
3 *
4 * This code is based heavily on hvc_vio.c and viocons.c
5 *
6 * Copyright (C) 2006 Stephen Rothwell, IBM Corporation
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22#include <stdarg.h>
23#include <linux/types.h>
24#include <linux/init.h>
25#include <linux/kernel.h>
26#include <linux/spinlock.h>
27#include <linux/console.h>
28
29#include <asm/hvconsole.h>
30#include <asm/vio.h>
31#include <asm/prom.h>
32#include <asm/iseries/vio.h>
33#include <asm/iseries/hv_call.h>
34#include <asm/iseries/hv_lp_config.h>
35#include <asm/iseries/hv_lp_event.h>
36
37#include "hvc_console.h"
38
39#define VTTY_PORTS 10
40
41static DEFINE_SPINLOCK(consolelock);
42static DEFINE_SPINLOCK(consoleloglock);
43
44static const char hvc_driver_name[] = "hvc_console";
45
46#define IN_BUF_SIZE 200
47
48/*
49 * Our port information.
50 */
51static struct port_info {
52 HvLpIndex lp;
53 u64 seq; /* sequence number of last HV send */
54 u64 ack; /* last ack from HV */
55 struct hvc_struct *hp;
56 int in_start;
57 int in_end;
58 unsigned char in_buf[IN_BUF_SIZE];
59} port_info[VTTY_PORTS] = {
60 [ 0 ... VTTY_PORTS - 1 ] = {
61 .lp = HvLpIndexInvalid
62 }
63};
64
65#define viochar_is_console(pi) ((pi) == &port_info[0])
66
67static struct vio_device_id hvc_driver_table[] __devinitdata = {
68 {"serial", "IBM,iSeries-vty"},
69 { "", "" }
70};
71MODULE_DEVICE_TABLE(vio, hvc_driver_table);
72
73static void hvlog(char *fmt, ...)
74{
75 int i;
76 unsigned long flags;
77 va_list args;
78 static char buf[256];
79
80 spin_lock_irqsave(&consoleloglock, flags);
81 va_start(args, fmt);
82 i = vscnprintf(buf, sizeof(buf) - 1, fmt, args);
83 va_end(args);
84 buf[i++] = '\r';
85 HvCall_writeLogBuffer(buf, i);
86 spin_unlock_irqrestore(&consoleloglock, flags);
87}
88
89/*
90 * Initialize the common fields in a charLpEvent
91 */
92static void init_data_event(struct viocharlpevent *viochar, HvLpIndex lp)
93{
94 struct HvLpEvent *hev = &viochar->event;
95
96 memset(viochar, 0, sizeof(struct viocharlpevent));
97
98 hev->flags = HV_LP_EVENT_VALID | HV_LP_EVENT_DEFERRED_ACK |
99 HV_LP_EVENT_INT;
100 hev->xType = HvLpEvent_Type_VirtualIo;
101 hev->xSubtype = viomajorsubtype_chario | viochardata;
102 hev->xSourceLp = HvLpConfig_getLpIndex();
103 hev->xTargetLp = lp;
104 hev->xSizeMinus1 = sizeof(struct viocharlpevent);
105 hev->xSourceInstanceId = viopath_sourceinst(lp);
106 hev->xTargetInstanceId = viopath_targetinst(lp);
107}
108
109static int get_chars(uint32_t vtermno, char *buf, int count)
110{
111 struct port_info *pi;
112 int n = 0;
113 unsigned long flags;
114
115 if (vtermno >= VTTY_PORTS)
116 return -EINVAL;
117 if (count == 0)
118 return 0;
119
120 pi = &port_info[vtermno];
121 spin_lock_irqsave(&consolelock, flags);
122
123 if (pi->in_end == 0)
124 goto done;
125
126 n = pi->in_end - pi->in_start;
127 if (n > count)
128 n = count;
129 memcpy(buf, &pi->in_buf[pi->in_start], n);
130 pi->in_start += n;
131 if (pi->in_start == pi->in_end) {
132 pi->in_start = 0;
133 pi->in_end = 0;
134 }
135done:
136 spin_unlock_irqrestore(&consolelock, flags);
137 return n;
138}
139
140static int put_chars(uint32_t vtermno, const char *buf, int count)
141{
142 struct viocharlpevent *viochar;
143 struct port_info *pi;
144 HvLpEvent_Rc hvrc;
145 unsigned long flags;
146 int sent = 0;
147
148 if (vtermno >= VTTY_PORTS)
149 return -EINVAL;
150
151 pi = &port_info[vtermno];
152
153 spin_lock_irqsave(&consolelock, flags);
154
155 if (viochar_is_console(pi) && !viopath_isactive(pi->lp)) {
156 spin_lock_irqsave(&consoleloglock, flags);
157 HvCall_writeLogBuffer(buf, count);
158 spin_unlock_irqrestore(&consoleloglock, flags);
159 sent = count;
160 goto done;
161 }
162
163 viochar = vio_get_event_buffer(viomajorsubtype_chario);
164 if (viochar == NULL) {
165 hvlog("\n\rviocons: Can't get viochar buffer.");
166 goto done;
167 }
168
169 while ((count > 0) && ((pi->seq - pi->ack) < VIOCHAR_WINDOW)) {
170 int len;
171
172 len = (count > VIOCHAR_MAX_DATA) ? VIOCHAR_MAX_DATA : count;
173
174 if (viochar_is_console(pi)) {
175 spin_lock_irqsave(&consoleloglock, flags);
176 HvCall_writeLogBuffer(buf, len);
177 spin_unlock_irqrestore(&consoleloglock, flags);
178 }
179
180 init_data_event(viochar, pi->lp);
181
182 viochar->len = len;
183 viochar->event.xCorrelationToken = pi->seq++;
184 viochar->event.xSizeMinus1 =
185 offsetof(struct viocharlpevent, data) + len;
186
187 memcpy(viochar->data, buf, len);
188
189 hvrc = HvCallEvent_signalLpEvent(&viochar->event);
190 if (hvrc)
191 hvlog("\n\rerror sending event! return code %d\n\r",
192 (int)hvrc);
193 sent += len;
194 count -= len;
195 buf += len;
196 }
197
198 vio_free_event_buffer(viomajorsubtype_chario, viochar);
199done:
200 spin_unlock_irqrestore(&consolelock, flags);
201 return sent;
202}
203
204static struct hv_ops hvc_get_put_ops = {
205 .get_chars = get_chars,
206 .put_chars = put_chars,
207};
208
209static int __devinit hvc_vio_probe(struct vio_dev *vdev,
210 const struct vio_device_id *id)
211{
212 struct hvc_struct *hp;
213 struct port_info *pi;
214
215 /* probed with invalid parameters. */
216 if (!vdev || !id)
217 return -EPERM;
218
219 if (vdev->unit_address >= VTTY_PORTS)
220 return -ENODEV;
221
222 pi = &port_info[vdev->unit_address];
223
224 hp = hvc_alloc(vdev->unit_address, vdev->irq, &hvc_get_put_ops,
225 VIOCHAR_MAX_DATA);
226 if (IS_ERR(hp))
227 return PTR_ERR(hp);
228 pi->hp = hp;
229 dev_set_drvdata(&vdev->dev, pi);
230
231 return 0;
232}
233
234static int __devexit hvc_vio_remove(struct vio_dev *vdev)
235{
236 struct port_info *pi = dev_get_drvdata(&vdev->dev);
237 struct hvc_struct *hp = pi->hp;
238
239 return hvc_remove(hp);
240}
241
242static struct vio_driver hvc_vio_driver = {
243 .id_table = hvc_driver_table,
244 .probe = hvc_vio_probe,
245 .remove = hvc_vio_remove,
246 .driver = {
247 .name = hvc_driver_name,
248 .owner = THIS_MODULE,
249 }
250};
251
252static void hvc_open_event(struct HvLpEvent *event)
253{
254 unsigned long flags;
255 struct viocharlpevent *cevent = (struct viocharlpevent *)event;
256 u8 port = cevent->virtual_device;
257 struct port_info *pi;
258 int reject = 0;
259
260 if (hvlpevent_is_ack(event)) {
261 if (port >= VTTY_PORTS)
262 return;
263
264 spin_lock_irqsave(&consolelock, flags);
265
266 pi = &port_info[port];
267 if (event->xRc == HvLpEvent_Rc_Good) {
268 pi->seq = pi->ack = 0;
269 /*
270 * This line allows connections from the primary
271 * partition but once one is connected from the
272 * primary partition nothing short of a reboot
273 * of linux will allow access from the hosting
274 * partition again without a required iSeries fix.
275 */
276 pi->lp = event->xTargetLp;
277 }
278
279 spin_unlock_irqrestore(&consolelock, flags);
280 if (event->xRc != HvLpEvent_Rc_Good)
281 printk(KERN_WARNING
282 "hvc: handle_open_event: event->xRc == (%d).\n",
283 event->xRc);
284
285 if (event->xCorrelationToken != 0) {
286 atomic_t *aptr= (atomic_t *)event->xCorrelationToken;
287 atomic_set(aptr, 1);
288 } else
289 printk(KERN_WARNING
290 "hvc: weird...got open ack without atomic\n");
291 return;
292 }
293
294 /* This had better require an ack, otherwise complain */
295 if (!hvlpevent_need_ack(event)) {
296 printk(KERN_WARNING "hvc: viocharopen without ack bit!\n");
297 return;
298 }
299
300 spin_lock_irqsave(&consolelock, flags);
301
302 /* Make sure this is a good virtual tty */
303 if (port >= VTTY_PORTS) {
304 event->xRc = HvLpEvent_Rc_SubtypeError;
305 cevent->subtype_result_code = viorc_openRejected;
306 /*
307 * Flag state here since we can't printk while holding
308 * the consolelock spinlock.
309 */
310 reject = 1;
311 } else {
312 pi = &port_info[port];
313 if ((pi->lp != HvLpIndexInvalid) &&
314 (pi->lp != event->xSourceLp)) {
315 /*
316 * If this is tty is already connected to a different
317 * partition, fail.
318 */
319 event->xRc = HvLpEvent_Rc_SubtypeError;
320 cevent->subtype_result_code = viorc_openRejected;
321 reject = 2;
322 } else {
323 pi->lp = event->xSourceLp;
324 event->xRc = HvLpEvent_Rc_Good;
325 cevent->subtype_result_code = viorc_good;
326 pi->seq = pi->ack = 0;
327 }
328 }
329
330 spin_unlock_irqrestore(&consolelock, flags);
331
332 if (reject == 1)
333 printk(KERN_WARNING "hvc: open rejected: bad virtual tty.\n");
334 else if (reject == 2)
335 printk(KERN_WARNING "hvc: open rejected: console in exclusive "
336 "use by another partition.\n");
337
338 /* Return the acknowledgement */
339 HvCallEvent_ackLpEvent(event);
340}
341
342/*
343 * Handle a close charLpEvent. This should ONLY be an Interrupt because the
344 * virtual console should never actually issue a close event to the hypervisor
345 * because the virtual console never goes away. A close event coming from the
346 * hypervisor simply means that there are no client consoles connected to the
347 * virtual console.
348 */
349static void hvc_close_event(struct HvLpEvent *event)
350{
351 unsigned long flags;
352 struct viocharlpevent *cevent = (struct viocharlpevent *)event;
353 u8 port = cevent->virtual_device;
354
355 if (!hvlpevent_is_int(event)) {
356 printk(KERN_WARNING
357 "hvc: got unexpected close acknowlegement\n");
358 return;
359 }
360
361 if (port >= VTTY_PORTS) {
362 printk(KERN_WARNING
363 "hvc: close message from invalid virtual device.\n");
364 return;
365 }
366
367 /* For closes, just mark the console partition invalid */
368 spin_lock_irqsave(&consolelock, flags);
369
370 if (port_info[port].lp == event->xSourceLp)
371 port_info[port].lp = HvLpIndexInvalid;
372
373 spin_unlock_irqrestore(&consolelock, flags);
374}
375
376static void hvc_data_event(struct HvLpEvent *event)
377{
378 unsigned long flags;
379 struct viocharlpevent *cevent = (struct viocharlpevent *)event;
380 struct port_info *pi;
381 int n;
382 u8 port = cevent->virtual_device;
383
384 if (port >= VTTY_PORTS) {
385 printk(KERN_WARNING "hvc: data on invalid virtual device %d\n",
386 port);
387 return;
388 }
389 if (cevent->len == 0)
390 return;
391
392 /*
393 * Change 05/01/2003 - Ryan Arnold: If a partition other than
394 * the current exclusive partition tries to send us data
395 * events then just drop them on the floor because we don't
396 * want his stinking data. He isn't authorized to receive
397 * data because he wasn't the first one to get the console,
398 * therefore he shouldn't be allowed to send data either.
399 * This will work without an iSeries fix.
400 */
401 pi = &port_info[port];
402 if (pi->lp != event->xSourceLp)
403 return;
404
405 spin_lock_irqsave(&consolelock, flags);
406
407 n = IN_BUF_SIZE - pi->in_end;
408 if (n > cevent->len)
409 n = cevent->len;
410 if (n > 0) {
411 memcpy(&pi->in_buf[pi->in_end], cevent->data, n);
412 pi->in_end += n;
413 }
414 spin_unlock_irqrestore(&consolelock, flags);
415 if (n == 0)
416 printk(KERN_WARNING "hvc: input buffer overflow\n");
417}
418
419static void hvc_ack_event(struct HvLpEvent *event)
420{
421 struct viocharlpevent *cevent = (struct viocharlpevent *)event;
422 unsigned long flags;
423 u8 port = cevent->virtual_device;
424
425 if (port >= VTTY_PORTS) {
426 printk(KERN_WARNING "hvc: data on invalid virtual device\n");
427 return;
428 }
429
430 spin_lock_irqsave(&consolelock, flags);
431 port_info[port].ack = event->xCorrelationToken;
432 spin_unlock_irqrestore(&consolelock, flags);
433}
434
435static void hvc_config_event(struct HvLpEvent *event)
436{
437 struct viocharlpevent *cevent = (struct viocharlpevent *)event;
438
439 if (cevent->data[0] == 0x01)
440 printk(KERN_INFO "hvc: window resized to %d: %d: %d: %d\n",
441 cevent->data[1], cevent->data[2],
442 cevent->data[3], cevent->data[4]);
443 else
444 printk(KERN_WARNING "hvc: unknown config event\n");
445}
446
447static void hvc_handle_event(struct HvLpEvent *event)
448{
449 int charminor;
450
451 if (event == NULL)
452 return;
453
454 charminor = event->xSubtype & VIOMINOR_SUBTYPE_MASK;
455 switch (charminor) {
456 case viocharopen:
457 hvc_open_event(event);
458 break;
459 case viocharclose:
460 hvc_close_event(event);
461 break;
462 case viochardata:
463 hvc_data_event(event);
464 break;
465 case viocharack:
466 hvc_ack_event(event);
467 break;
468 case viocharconfig:
469 hvc_config_event(event);
470 break;
471 default:
472 if (hvlpevent_is_int(event) && hvlpevent_need_ack(event)) {
473 event->xRc = HvLpEvent_Rc_InvalidSubtype;
474 HvCallEvent_ackLpEvent(event);
475 }
476 }
477}
478
479static int send_open(HvLpIndex remoteLp, void *sem)
480{
481 return HvCallEvent_signalLpEventFast(remoteLp,
482 HvLpEvent_Type_VirtualIo,
483 viomajorsubtype_chario | viocharopen,
484 HvLpEvent_AckInd_DoAck, HvLpEvent_AckType_ImmediateAck,
485 viopath_sourceinst(remoteLp),
486 viopath_targetinst(remoteLp),
487 (u64)(unsigned long)sem, VIOVERSION << 16,
488 0, 0, 0, 0);
489}
490
491static int hvc_vio_init(void)
492{
493 atomic_t wait_flag;
494 int rc;
495
496 /* +2 for fudge */
497 rc = viopath_open(HvLpConfig_getPrimaryLpIndex(),
498 viomajorsubtype_chario, VIOCHAR_WINDOW + 2);
499 if (rc)
500 printk(KERN_WARNING "hvc: error opening to primary %d\n", rc);
501
502 if (viopath_hostLp == HvLpIndexInvalid)
503 vio_set_hostlp();
504
505 /*
506 * And if the primary is not the same as the hosting LP, open to the
507 * hosting lp
508 */
509 if ((viopath_hostLp != HvLpIndexInvalid) &&
510 (viopath_hostLp != HvLpConfig_getPrimaryLpIndex())) {
511 printk(KERN_INFO "hvc: open path to hosting (%d)\n",
512 viopath_hostLp);
513 rc = viopath_open(viopath_hostLp, viomajorsubtype_chario,
514 VIOCHAR_WINDOW + 2); /* +2 for fudge */
515 if (rc)
516 printk(KERN_WARNING
517 "error opening to partition %d: %d\n",
518 viopath_hostLp, rc);
519 }
520
521 if (vio_setHandler(viomajorsubtype_chario, hvc_handle_event) < 0)
522 printk(KERN_WARNING
523 "hvc: error seting handler for console events!\n");
524
525 /*
526 * First, try to open the console to the hosting lp.
527 * Wait on a semaphore for the response.
528 */
529 atomic_set(&wait_flag, 0);
530 if ((viopath_isactive(viopath_hostLp)) &&
531 (send_open(viopath_hostLp, &wait_flag) == 0)) {
532 printk(KERN_INFO "hvc: hosting partition %d\n", viopath_hostLp);
533 while (atomic_read(&wait_flag) == 0)
534 mb();
535 atomic_set(&wait_flag, 0);
536 }
537
538 /*
539 * If we don't have an active console, try the primary
540 */
541 if ((!viopath_isactive(port_info[0].lp)) &&
542 (viopath_isactive(HvLpConfig_getPrimaryLpIndex())) &&
543 (send_open(HvLpConfig_getPrimaryLpIndex(), &wait_flag) == 0)) {
544 printk(KERN_INFO "hvc: opening console to primary partition\n");
545 while (atomic_read(&wait_flag) == 0)
546 mb();
547 }
548
549 /* Register as a vio device to receive callbacks */
550 rc = vio_register_driver(&hvc_vio_driver);
551
552 return rc;
553}
554module_init(hvc_vio_init); /* after drivers/char/hvc_console.c */
555
556static void hvc_vio_exit(void)
557{
558 vio_unregister_driver(&hvc_vio_driver);
559}
560module_exit(hvc_vio_exit);
561
562/* the device tree order defines our numbering */
563static int hvc_find_vtys(void)
564{
565 struct device_node *vty;
566 int num_found = 0;
567
568 for (vty = of_find_node_by_name(NULL, "vty"); vty != NULL;
569 vty = of_find_node_by_name(vty, "vty")) {
570 uint32_t *vtermno;
571
572 /* We have statically defined space for only a certain number
573 * of console adapters.
574 */
575 if ((num_found >= MAX_NR_HVC_CONSOLES) ||
576 (num_found >= VTTY_PORTS))
577 break;
578
579 vtermno = (uint32_t *)get_property(vty, "reg", NULL);
580 if (!vtermno)
581 continue;
582
583 if (!device_is_compatible(vty, "IBM,iSeries-vty"))
584 continue;
585
586 if (num_found == 0)
587 add_preferred_console("hvc", 0, NULL);
588 hvc_instantiate(*vtermno, num_found, &hvc_get_put_ops);
589 ++num_found;
590 }
591
592 return num_found;
593}
594console_initcall(hvc_find_vtys);
diff --git a/drivers/char/hvc_rtas.c b/drivers/char/hvc_rtas.c
index 57106e02fd2e..4b97eaf18602 100644
--- a/drivers/char/hvc_rtas.c
+++ b/drivers/char/hvc_rtas.c
@@ -94,7 +94,7 @@ static int hvc_rtas_init(void)
94 94
95 /* Allocate an hvc_struct for the console device we instantiated 95 /* Allocate an hvc_struct for the console device we instantiated
96 * earlier. Save off hp so that we can return it on exit */ 96 * earlier. Save off hp so that we can return it on exit */
97 hp = hvc_alloc(hvc_rtas_cookie, NO_IRQ, &hvc_rtas_get_put_ops); 97 hp = hvc_alloc(hvc_rtas_cookie, NO_IRQ, &hvc_rtas_get_put_ops, 16);
98 if (IS_ERR(hp)) 98 if (IS_ERR(hp))
99 return PTR_ERR(hp); 99 return PTR_ERR(hp);
100 100
diff --git a/drivers/char/hvc_vio.c b/drivers/char/hvc_vio.c
index 9add81ceb440..cc95941148fb 100644
--- a/drivers/char/hvc_vio.c
+++ b/drivers/char/hvc_vio.c
@@ -90,7 +90,8 @@ static int __devinit hvc_vio_probe(struct vio_dev *vdev,
90 if (!vdev || !id) 90 if (!vdev || !id)
91 return -EPERM; 91 return -EPERM;
92 92
93 hp = hvc_alloc(vdev->unit_address, vdev->irq, &hvc_get_put_ops); 93 hp = hvc_alloc(vdev->unit_address, vdev->irq, &hvc_get_put_ops,
94 MAX_VIO_PUT_CHARS);
94 if (IS_ERR(hp)) 95 if (IS_ERR(hp))
95 return PTR_ERR(hp); 96 return PTR_ERR(hp);
96 dev_set_drvdata(&vdev->dev, hp); 97 dev_set_drvdata(&vdev->dev, hp);
@@ -140,7 +141,7 @@ static int hvc_find_vtys(void)
140 141
141 for (vty = of_find_node_by_name(NULL, "vty"); vty != NULL; 142 for (vty = of_find_node_by_name(NULL, "vty"); vty != NULL;
142 vty = of_find_node_by_name(vty, "vty")) { 143 vty = of_find_node_by_name(vty, "vty")) {
143 uint32_t *vtermno; 144 const uint32_t *vtermno;
144 145
145 /* We have statically defined space for only a certain number 146 /* We have statically defined space for only a certain number
146 * of console adapters. 147 * of console adapters.
@@ -148,7 +149,7 @@ static int hvc_find_vtys(void)
148 if (num_found >= MAX_NR_HVC_CONSOLES) 149 if (num_found >= MAX_NR_HVC_CONSOLES)
149 break; 150 break;
150 151
151 vtermno = (uint32_t *)get_property(vty, "reg", NULL); 152 vtermno = get_property(vty, "reg", NULL);
152 if (!vtermno) 153 if (!vtermno)
153 continue; 154 continue;
154 155
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c
index 017f755632a3..a89a95fb5e40 100644
--- a/drivers/char/hvsi.c
+++ b/drivers/char/hvsi.c
@@ -1274,11 +1274,10 @@ static int __init hvsi_console_init(void)
1274 vty != NULL; 1274 vty != NULL;
1275 vty = of_find_compatible_node(vty, "serial", "hvterm-protocol")) { 1275 vty = of_find_compatible_node(vty, "serial", "hvterm-protocol")) {
1276 struct hvsi_struct *hp; 1276 struct hvsi_struct *hp;
1277 uint32_t *vtermno; 1277 const uint32_t *vtermno, *irq;
1278 uint32_t *irq;
1279 1278
1280 vtermno = (uint32_t *)get_property(vty, "reg", NULL); 1279 vtermno = get_property(vty, "reg", NULL);
1281 irq = (uint32_t *)get_property(vty, "interrupts", NULL); 1280 irq = get_property(vty, "interrupts", NULL);
1282 if (!vtermno || !irq) 1281 if (!vtermno || !irq)
1283 continue; 1282 continue;
1284 1283
diff --git a/drivers/char/tpm/tpm_atmel.h b/drivers/char/tpm/tpm_atmel.h
index 2e68eeb8a2cd..aefd683c60b7 100644
--- a/drivers/char/tpm/tpm_atmel.h
+++ b/drivers/char/tpm/tpm_atmel.h
@@ -37,7 +37,7 @@ static void __iomem * atmel_get_base_addr(unsigned long *base, int *region_size)
37{ 37{
38 struct device_node *dn; 38 struct device_node *dn;
39 unsigned long address, size; 39 unsigned long address, size;
40 unsigned int *reg; 40 const unsigned int *reg;
41 int reglen; 41 int reglen;
42 int naddrc; 42 int naddrc;
43 int nsizec; 43 int nsizec;
@@ -52,7 +52,7 @@ static void __iomem * atmel_get_base_addr(unsigned long *base, int *region_size)
52 return NULL; 52 return NULL;
53 } 53 }
54 54
55 reg = (unsigned int *) get_property(dn, "reg", &reglen); 55 reg = get_property(dn, "reg", &reglen);
56 naddrc = prom_n_addr_cells(dn); 56 naddrc = prom_n_addr_cells(dn);
57 nsizec = prom_n_size_cells(dn); 57 nsizec = prom_n_size_cells(dn);
58 58
diff --git a/drivers/char/viocons.c b/drivers/char/viocons.c
index 766f7864c6c6..f3efeaf2826e 100644
--- a/drivers/char/viocons.c
+++ b/drivers/char/viocons.c
@@ -43,7 +43,6 @@
43#include <linux/sysrq.h> 43#include <linux/sysrq.h>
44 44
45#include <asm/iseries/vio.h> 45#include <asm/iseries/vio.h>
46
47#include <asm/iseries/hv_lp_event.h> 46#include <asm/iseries/hv_lp_event.h>
48#include <asm/iseries/hv_call_event.h> 47#include <asm/iseries/hv_call_event.h>
49#include <asm/iseries/hv_lp_config.h> 48#include <asm/iseries/hv_lp_config.h>
@@ -67,35 +66,6 @@ static int vio_sysrq_pressed;
67extern int sysrq_enabled; 66extern int sysrq_enabled;
68#endif 67#endif
69 68
70/*
71 * The structure of the events that flow between us and OS/400. You can't
72 * mess with this unless the OS/400 side changes too
73 */
74struct viocharlpevent {
75 struct HvLpEvent event;
76 u32 reserved;
77 u16 version;
78 u16 subtype_result_code;
79 u8 virtual_device;
80 u8 len;
81 u8 data[VIOCHAR_MAX_DATA];
82};
83
84#define VIOCHAR_WINDOW 10
85#define VIOCHAR_HIGHWATERMARK 3
86
87enum viocharsubtype {
88 viocharopen = 0x0001,
89 viocharclose = 0x0002,
90 viochardata = 0x0003,
91 viocharack = 0x0004,
92 viocharconfig = 0x0005
93};
94
95enum viochar_rc {
96 viochar_rc_ebusy = 1
97};
98
99#define VIOCHAR_NUM_BUF 16 69#define VIOCHAR_NUM_BUF 16
100 70
101/* 71/*
@@ -1183,6 +1153,7 @@ static int __init viocons_init(void)
1183 port_info[i].magic = VIOTTY_MAGIC; 1153 port_info[i].magic = VIOTTY_MAGIC;
1184 } 1154 }
1185 HvCall_setLogBufferFormatAndCodepage(HvCall_LogBuffer_ASCII, 437); 1155 HvCall_setLogBufferFormatAndCodepage(HvCall_LogBuffer_ASCII, 437);
1156 add_preferred_console("viocons", 0, NULL);
1186 register_console(&viocons_early); 1157 register_console(&viocons_early);
1187 return 0; 1158 return 0;
1188} 1159}
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c
index b72b2049aaae..73c78bf75d7f 100644
--- a/drivers/char/viotape.c
+++ b/drivers/char/viotape.c
@@ -940,7 +940,6 @@ static void vioHandleTapeEvent(struct HvLpEvent *event)
940 940
941static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id) 941static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id)
942{ 942{
943 char tapename[32];
944 int i = vdev->unit_address; 943 int i = vdev->unit_address;
945 int j; 944 int j;
946 945
@@ -956,10 +955,9 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id)
956 "iseries!vt%d", i); 955 "iseries!vt%d", i);
957 class_device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), 956 class_device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80),
958 NULL, "iseries!nvt%d", i); 957 NULL, "iseries!nvt%d", i);
959 sprintf(tapename, "iseries/vt%d", i); 958 printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries "
960 printk(VIOTAPE_KERN_INFO "tape %s is iSeries "
961 "resource %10.10s type %4.4s, model %3.3s\n", 959 "resource %10.10s type %4.4s, model %3.3s\n",
962 tapename, viotape_unitinfo[i].rsrcname, 960 i, viotape_unitinfo[i].rsrcname,
963 viotape_unitinfo[i].type, viotape_unitinfo[i].model); 961 viotape_unitinfo[i].type, viotape_unitinfo[i].model);
964 return 0; 962 return 0;
965} 963}
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c
index 53bb43593863..d658d9107955 100644
--- a/drivers/i2c/busses/i2c-powermac.c
+++ b/drivers/i2c/busses/i2c-powermac.c
@@ -207,7 +207,8 @@ static int i2c_powermac_probe(struct device *dev)
207 struct pmac_i2c_bus *bus = dev->platform_data; 207 struct pmac_i2c_bus *bus = dev->platform_data;
208 struct device_node *parent = NULL; 208 struct device_node *parent = NULL;
209 struct i2c_adapter *adapter; 209 struct i2c_adapter *adapter;
210 char name[32], *basename; 210 char name[32];
211 const char *basename;
211 int rc; 212 int rc;
212 213
213 if (bus == NULL) 214 if (bus == NULL)
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index ebf961f1718d..996c694341bc 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1154,7 +1154,7 @@ static int
1154pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) 1154pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
1155{ 1155{
1156 struct device_node *np = pmif->node; 1156 struct device_node *np = pmif->node;
1157 int *bidp; 1157 const int *bidp;
1158 1158
1159 pmif->cable_80 = 0; 1159 pmif->cable_80 = 0;
1160 pmif->broken_dma = pmif->broken_dma_warn = 0; 1160 pmif->broken_dma = pmif->broken_dma_warn = 0;
@@ -1176,14 +1176,14 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
1176 pmif->broken_dma = 1; 1176 pmif->broken_dma = 1;
1177 } 1177 }
1178 1178
1179 bidp = (int *)get_property(np, "AAPL,bus-id", NULL); 1179 bidp = get_property(np, "AAPL,bus-id", NULL);
1180 pmif->aapl_bus_id = bidp ? *bidp : 0; 1180 pmif->aapl_bus_id = bidp ? *bidp : 0;
1181 1181
1182 /* Get cable type from device-tree */ 1182 /* Get cable type from device-tree */
1183 if (pmif->kind == controller_kl_ata4 || pmif->kind == controller_un_ata6 1183 if (pmif->kind == controller_kl_ata4 || pmif->kind == controller_un_ata6
1184 || pmif->kind == controller_k2_ata6 1184 || pmif->kind == controller_k2_ata6
1185 || pmif->kind == controller_sh_ata6) { 1185 || pmif->kind == controller_sh_ata6) {
1186 char* cable = get_property(np, "cable-type", NULL); 1186 const char* cable = get_property(np, "cable-type", NULL);
1187 if (cable && !strncmp(cable, "80-", 3)) 1187 if (cable && !strncmp(cable, "80-", 3))
1188 pmif->cable_80 = 1; 1188 pmif->cable_80 = 1;
1189 } 1189 }
@@ -1326,7 +1326,7 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1326 if (macio_irq_count(mdev) == 0) { 1326 if (macio_irq_count(mdev) == 0) {
1327 printk(KERN_WARNING "ide%d: no intrs for device %s, using 13\n", 1327 printk(KERN_WARNING "ide%d: no intrs for device %s, using 13\n",
1328 i, mdev->ofdev.node->full_name); 1328 i, mdev->ofdev.node->full_name);
1329 irq = 13; 1329 irq = irq_create_mapping(NULL, 13);
1330 } else 1330 } else
1331 irq = macio_irq(mdev, 0); 1331 irq = macio_irq(mdev, 0);
1332 1332
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index 82657bc86d19..d56216067549 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -139,7 +139,9 @@ static int macio_uevent(struct device *dev, char **envp, int num_envp,
139{ 139{
140 struct macio_dev * macio_dev; 140 struct macio_dev * macio_dev;
141 struct of_device * of; 141 struct of_device * of;
142 char *scratch, *compat, *compat2; 142 char *scratch;
143 const char *compat, *compat2;
144
143 int i = 0; 145 int i = 0;
144 int length, cplen, cplen2, seen = 0; 146 int length, cplen, cplen2, seen = 0;
145 147
@@ -173,7 +175,7 @@ static int macio_uevent(struct device *dev, char **envp, int num_envp,
173 * it's not really legal to split it out with commas. We split it 175 * it's not really legal to split it out with commas. We split it
174 * up using a number of environment variables instead. */ 176 * up using a number of environment variables instead. */
175 177
176 compat = (char *) get_property(of->node, "compatible", &cplen); 178 compat = get_property(of->node, "compatible", &cplen);
177 compat2 = compat; 179 compat2 = compat;
178 cplen2= cplen; 180 cplen2= cplen;
179 while (compat && cplen > 0) { 181 while (compat && cplen > 0) {
@@ -454,7 +456,7 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip,
454 struct resource *parent_res) 456 struct resource *parent_res)
455{ 457{
456 struct macio_dev *dev; 458 struct macio_dev *dev;
457 u32 *reg; 459 const u32 *reg;
458 460
459 if (np == NULL) 461 if (np == NULL)
460 return NULL; 462 return NULL;
@@ -489,7 +491,7 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip,
489#endif 491#endif
490 MAX_NODE_NAME_SIZE, np->name); 492 MAX_NODE_NAME_SIZE, np->name);
491 } else { 493 } else {
492 reg = (u32 *)get_property(np, "reg", NULL); 494 reg = get_property(np, "reg", NULL);
493 sprintf(dev->ofdev.dev.bus_id, "%1d.%08x:%.*s", 495 sprintf(dev->ofdev.dev.bus_id, "%1d.%08x:%.*s",
494 chip->lbus.index, 496 chip->lbus.index,
495 reg ? *reg : 0, MAX_NODE_NAME_SIZE, np->name); 497 reg ? *reg : 0, MAX_NODE_NAME_SIZE, np->name);
diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c
index cae24a13526a..8566bdfdd4b8 100644
--- a/drivers/macintosh/macio_sysfs.c
+++ b/drivers/macintosh/macio_sysfs.c
@@ -16,12 +16,12 @@ static ssize_t
16compatible_show (struct device *dev, struct device_attribute *attr, char *buf) 16compatible_show (struct device *dev, struct device_attribute *attr, char *buf)
17{ 17{
18 struct of_device *of; 18 struct of_device *of;
19 char *compat; 19 const char *compat;
20 int cplen; 20 int cplen;
21 int length = 0; 21 int length = 0;
22 22
23 of = &to_macio_device (dev)->ofdev; 23 of = &to_macio_device (dev)->ofdev;
24 compat = (char *) get_property(of->node, "compatible", &cplen); 24 compat = get_property(of->node, "compatible", &cplen);
25 if (!compat) { 25 if (!compat) {
26 *buf = '\0'; 26 *buf = '\0';
27 return 0; 27 return 0;
@@ -42,12 +42,12 @@ static ssize_t modalias_show (struct device *dev, struct device_attribute *attr,
42 char *buf) 42 char *buf)
43{ 43{
44 struct of_device *of; 44 struct of_device *of;
45 char *compat; 45 const char *compat;
46 int cplen; 46 int cplen;
47 int length; 47 int length;
48 48
49 of = &to_macio_device (dev)->ofdev; 49 of = &to_macio_device (dev)->ofdev;
50 compat = (char *) get_property (of->node, "compatible", &cplen); 50 compat = get_property(of->node, "compatible", &cplen);
51 if (!compat) compat = "", cplen = 1; 51 if (!compat) compat = "", cplen = 1;
52 length = sprintf (buf, "of:N%sT%s", of->node->name, of->node->type); 52 length = sprintf (buf, "of:N%sT%s", of->node->name, of->node->type);
53 buf += length; 53 buf += length;
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index 00ef46898147..090e40fc5013 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -454,7 +454,7 @@ EXPORT_SYMBOL(smu_present);
454int __init smu_init (void) 454int __init smu_init (void)
455{ 455{
456 struct device_node *np; 456 struct device_node *np;
457 u32 *data; 457 const u32 *data;
458 458
459 np = of_find_node_by_type(NULL, "smu"); 459 np = of_find_node_by_type(NULL, "smu");
460 if (np == NULL) 460 if (np == NULL)
@@ -490,7 +490,7 @@ int __init smu_init (void)
490 printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n"); 490 printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n");
491 goto fail; 491 goto fail;
492 } 492 }
493 data = (u32 *)get_property(smu->db_node, "reg", NULL); 493 data = get_property(smu->db_node, "reg", NULL);
494 if (data == NULL) { 494 if (data == NULL) {
495 of_node_put(smu->db_node); 495 of_node_put(smu->db_node);
496 smu->db_node = NULL; 496 smu->db_node = NULL;
@@ -511,7 +511,7 @@ int __init smu_init (void)
511 smu->msg_node = of_find_node_by_name(NULL, "smu-interrupt"); 511 smu->msg_node = of_find_node_by_name(NULL, "smu-interrupt");
512 if (smu->msg_node == NULL) 512 if (smu->msg_node == NULL)
513 break; 513 break;
514 data = (u32 *)get_property(smu->msg_node, "reg", NULL); 514 data = get_property(smu->msg_node, "reg", NULL);
515 if (data == NULL) { 515 if (data == NULL) {
516 of_node_put(smu->msg_node); 516 of_node_put(smu->msg_node);
517 smu->msg_node = NULL; 517 smu->msg_node = NULL;
@@ -982,11 +982,11 @@ static struct smu_sdbp_header *smu_create_sdb_partition(int id)
982/* Note: Only allowed to return error code in pointers (using ERR_PTR) 982/* Note: Only allowed to return error code in pointers (using ERR_PTR)
983 * when interruptible is 1 983 * when interruptible is 1
984 */ 984 */
985struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size, 985const struct smu_sdbp_header *__smu_get_sdb_partition(int id,
986 int interruptible) 986 unsigned int *size, int interruptible)
987{ 987{
988 char pname[32]; 988 char pname[32];
989 struct smu_sdbp_header *part; 989 const struct smu_sdbp_header *part;
990 990
991 if (!smu) 991 if (!smu)
992 return NULL; 992 return NULL;
@@ -1003,8 +1003,7 @@ struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size,
1003 } else 1003 } else
1004 mutex_lock(&smu_part_access); 1004 mutex_lock(&smu_part_access);
1005 1005
1006 part = (struct smu_sdbp_header *)get_property(smu->of_node, 1006 part = get_property(smu->of_node, pname, size);
1007 pname, size);
1008 if (part == NULL) { 1007 if (part == NULL) {
1009 DPRINTK("trying to extract from SMU ...\n"); 1008 DPRINTK("trying to extract from SMU ...\n");
1010 part = smu_create_sdb_partition(id); 1009 part = smu_create_sdb_partition(id);
@@ -1015,7 +1014,7 @@ struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size,
1015 return part; 1014 return part;
1016} 1015}
1017 1016
1018struct smu_sdbp_header *smu_get_sdb_partition(int id, unsigned int *size) 1017const struct smu_sdbp_header *smu_get_sdb_partition(int id, unsigned int *size)
1019{ 1018{
1020 return __smu_get_sdb_partition(id, size, 0); 1019 return __smu_get_sdb_partition(id, size, 0);
1021} 1020}
@@ -1094,7 +1093,7 @@ static ssize_t smu_write(struct file *file, const char __user *buf,
1094 pp->mode = smu_file_events; 1093 pp->mode = smu_file_events;
1095 return 0; 1094 return 0;
1096 } else if (hdr.cmdtype == SMU_CMDTYPE_GET_PARTITION) { 1095 } else if (hdr.cmdtype == SMU_CMDTYPE_GET_PARTITION) {
1097 struct smu_sdbp_header *part; 1096 const struct smu_sdbp_header *part;
1098 part = __smu_get_sdb_partition(hdr.cmd, NULL, 1); 1097 part = __smu_get_sdb_partition(hdr.cmd, NULL, 1);
1099 if (part == NULL) 1098 if (part == NULL)
1100 return -EINVAL; 1099 return -EINVAL;
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index 7f86478bdd36..a0f30d0853ea 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -47,7 +47,7 @@ static u8 FAN_SPD_SET[2] = {0x30, 0x31};
47 47
48static u8 default_limits_local[3] = {70, 50, 70}; /* local, sensor1, sensor2 */ 48static u8 default_limits_local[3] = {70, 50, 70}; /* local, sensor1, sensor2 */
49static u8 default_limits_chip[3] = {80, 65, 80}; /* local, sensor1, sensor2 */ 49static u8 default_limits_chip[3] = {80, 65, 80}; /* local, sensor1, sensor2 */
50static char *sensor_location[3] = {NULL, NULL, NULL}; 50static const char *sensor_location[3] = {NULL, NULL, NULL};
51 51
52static int limit_adjust = 0; 52static int limit_adjust = 0;
53static int fan_speed = -1; 53static int fan_speed = -1;
@@ -553,7 +553,7 @@ static int __init
553thermostat_init(void) 553thermostat_init(void)
554{ 554{
555 struct device_node* np; 555 struct device_node* np;
556 u32 *prop; 556 const u32 *prop;
557 int i = 0, offset = 0; 557 int i = 0, offset = 0;
558 558
559 np = of_find_node_by_name(NULL, "fan"); 559 np = of_find_node_by_name(NULL, "fan");
@@ -566,13 +566,13 @@ thermostat_init(void)
566 else 566 else
567 return -ENODEV; 567 return -ENODEV;
568 568
569 prop = (u32 *)get_property(np, "hwsensor-params-version", NULL); 569 prop = get_property(np, "hwsensor-params-version", NULL);
570 printk(KERN_INFO "adt746x: version %d (%ssupported)\n", *prop, 570 printk(KERN_INFO "adt746x: version %d (%ssupported)\n", *prop,
571 (*prop == 1)?"":"un"); 571 (*prop == 1)?"":"un");
572 if (*prop != 1) 572 if (*prop != 1)
573 return -ENODEV; 573 return -ENODEV;
574 574
575 prop = (u32 *)get_property(np, "reg", NULL); 575 prop = get_property(np, "reg", NULL);
576 if (!prop) 576 if (!prop)
577 return -ENODEV; 577 return -ENODEV;
578 578
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 20bf67244e2c..d00c0c37a12e 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -660,7 +660,7 @@ static int read_eeprom(int cpu, struct mpu_data *out)
660{ 660{
661 struct device_node *np; 661 struct device_node *np;
662 char nodename[64]; 662 char nodename[64];
663 u8 *data; 663 const u8 *data;
664 int len; 664 int len;
665 665
666 /* prom.c routine for finding a node by path is a bit brain dead 666 /* prom.c routine for finding a node by path is a bit brain dead
@@ -673,7 +673,7 @@ static int read_eeprom(int cpu, struct mpu_data *out)
673 printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid node from device-tree\n"); 673 printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid node from device-tree\n");
674 return -ENODEV; 674 return -ENODEV;
675 } 675 }
676 data = (u8 *)get_property(np, "cpuid", &len); 676 data = get_property(np, "cpuid", &len);
677 if (data == NULL) { 677 if (data == NULL) {
678 printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid property from device-tree\n"); 678 printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid property from device-tree\n");
679 of_node_put(np); 679 of_node_put(np);
@@ -1336,7 +1336,7 @@ static int init_backside_state(struct backside_pid_state *state)
1336 */ 1336 */
1337 u3 = of_find_node_by_path("/u3@0,f8000000"); 1337 u3 = of_find_node_by_path("/u3@0,f8000000");
1338 if (u3 != NULL) { 1338 if (u3 != NULL) {
1339 u32 *vers = (u32 *)get_property(u3, "device-rev", NULL); 1339 const u32 *vers = get_property(u3, "device-rev", NULL);
1340 if (vers) 1340 if (vers)
1341 if (((*vers) & 0x3f) < 0x34) 1341 if (((*vers) & 0x3f) < 0x34)
1342 u3h = 0; 1342 u3h = 0;
@@ -2111,8 +2111,8 @@ static void fcu_lookup_fans(struct device_node *fcu_node)
2111 2111
2112 while ((np = of_get_next_child(fcu_node, np)) != NULL) { 2112 while ((np = of_get_next_child(fcu_node, np)) != NULL) {
2113 int type = -1; 2113 int type = -1;
2114 char *loc; 2114 const char *loc;
2115 u32 *reg; 2115 const u32 *reg;
2116 2116
2117 DBG(" control: %s, type: %s\n", np->name, np->type); 2117 DBG(" control: %s, type: %s\n", np->name, np->type);
2118 2118
@@ -2128,8 +2128,8 @@ static void fcu_lookup_fans(struct device_node *fcu_node)
2128 continue; 2128 continue;
2129 2129
2130 /* Lookup for a matching location */ 2130 /* Lookup for a matching location */
2131 loc = (char *)get_property(np, "location", NULL); 2131 loc = get_property(np, "location", NULL);
2132 reg = (u32 *)get_property(np, "reg", NULL); 2132 reg = get_property(np, "reg", NULL);
2133 if (loc == NULL || reg == NULL) 2133 if (loc == NULL || reg == NULL)
2134 continue; 2134 continue;
2135 DBG(" matching location: %s, reg: 0x%08x\n", loc, *reg); 2135 DBG(" matching location: %s, reg: 0x%08x\n", loc, *reg);
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index c7d1c290cb0c..738faab1b22c 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -484,14 +484,14 @@ struct apple_thermal_info {
484static int __init 484static int __init
485g4fan_init( void ) 485g4fan_init( void )
486{ 486{
487 struct apple_thermal_info *info; 487 const struct apple_thermal_info *info;
488 struct device_node *np; 488 struct device_node *np;
489 489
490 init_MUTEX( &x.lock ); 490 init_MUTEX( &x.lock );
491 491
492 if( !(np=of_find_node_by_name(NULL, "power-mgt")) ) 492 if( !(np=of_find_node_by_name(NULL, "power-mgt")) )
493 return -ENODEV; 493 return -ENODEV;
494 info = (struct apple_thermal_info*)get_property(np, "thermal-info", NULL); 494 info = get_property(np, "thermal-info", NULL);
495 of_node_put(np); 495 of_node_put(np);
496 496
497 if( !info || !machine_is_compatible("PowerMac3,6") ) 497 if( !info || !machine_is_compatible("PowerMac3,6") )
diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c
index 69d5452fd22f..7512d1c15207 100644
--- a/drivers/macintosh/via-cuda.c
+++ b/drivers/macintosh/via-cuda.c
@@ -123,7 +123,7 @@ int __init find_via_cuda(void)
123{ 123{
124 struct adb_request req; 124 struct adb_request req;
125 phys_addr_t taddr; 125 phys_addr_t taddr;
126 u32 *reg; 126 const u32 *reg;
127 int err; 127 int err;
128 128
129 if (vias != 0) 129 if (vias != 0)
@@ -132,7 +132,7 @@ int __init find_via_cuda(void)
132 if (vias == 0) 132 if (vias == 0)
133 return 0; 133 return 0;
134 134
135 reg = (u32 *)get_property(vias, "reg", NULL); 135 reg = get_property(vias, "reg", NULL);
136 if (reg == NULL) { 136 if (reg == NULL) {
137 printk(KERN_ERR "via-cuda: No \"reg\" property !\n"); 137 printk(KERN_ERR "via-cuda: No \"reg\" property !\n");
138 goto fail; 138 goto fail;
diff --git a/drivers/macintosh/via-pmu-led.c b/drivers/macintosh/via-pmu-led.c
index 5189d5454b1f..179af10105d9 100644
--- a/drivers/macintosh/via-pmu-led.c
+++ b/drivers/macintosh/via-pmu-led.c
@@ -120,7 +120,7 @@ static int __init via_pmu_led_init(void)
120 dt = of_find_node_by_path("/"); 120 dt = of_find_node_by_path("/");
121 if (dt == NULL) 121 if (dt == NULL)
122 return -ENODEV; 122 return -ENODEV;
123 model = (const char *)get_property(dt, "model", NULL); 123 model = get_property(dt, "model", NULL);
124 if (model == NULL) 124 if (model == NULL)
125 return -ENODEV; 125 return -ENODEV;
126 if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 && 126 if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 &&
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 14610a63f580..dda03985dcf5 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -280,7 +280,7 @@ static char *pbook_type[] = {
280int __init find_via_pmu(void) 280int __init find_via_pmu(void)
281{ 281{
282 u64 taddr; 282 u64 taddr;
283 u32 *reg; 283 const u32 *reg;
284 284
285 if (via != 0) 285 if (via != 0)
286 return 1; 286 return 1;
@@ -288,7 +288,7 @@ int __init find_via_pmu(void)
288 if (vias == NULL) 288 if (vias == NULL)
289 return 0; 289 return 0;
290 290
291 reg = (u32 *)get_property(vias, "reg", NULL); 291 reg = get_property(vias, "reg", NULL);
292 if (reg == NULL) { 292 if (reg == NULL) {
293 printk(KERN_ERR "via-pmu: No \"reg\" property !\n"); 293 printk(KERN_ERR "via-pmu: No \"reg\" property !\n");
294 goto fail; 294 goto fail;
@@ -330,7 +330,7 @@ int __init find_via_pmu(void)
330 330
331 gpiop = of_find_node_by_name(NULL, "gpio"); 331 gpiop = of_find_node_by_name(NULL, "gpio");
332 if (gpiop) { 332 if (gpiop) {
333 reg = (u32 *)get_property(gpiop, "reg", NULL); 333 reg = get_property(gpiop, "reg", NULL);
334 if (reg) 334 if (reg)
335 gaddr = of_translate_address(gpiop, reg); 335 gaddr = of_translate_address(gpiop, reg);
336 if (gaddr != OF_BAD_ADDR) 336 if (gaddr != OF_BAD_ADDR)
@@ -479,9 +479,9 @@ static int __init via_pmu_dev_init(void)
479 pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; 479 pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART;
480 } else { 480 } else {
481 struct device_node* prim = find_devices("power-mgt"); 481 struct device_node* prim = find_devices("power-mgt");
482 u32 *prim_info = NULL; 482 const u32 *prim_info = NULL;
483 if (prim) 483 if (prim)
484 prim_info = (u32 *)get_property(prim, "prim-info", NULL); 484 prim_info = get_property(prim, "prim-info", NULL);
485 if (prim_info) { 485 if (prim_info) {
486 /* Other stuffs here yet unknown */ 486 /* Other stuffs here yet unknown */
487 pmu_battery_count = (prim_info[6] >> 16) & 0xff; 487 pmu_battery_count = (prim_info[6] >> 16) & 0xff;
diff --git a/drivers/macintosh/windfarm_pm81.c b/drivers/macintosh/windfarm_pm81.c
index f1df6efcbe68..2ff546e4c92f 100644
--- a/drivers/macintosh/windfarm_pm81.c
+++ b/drivers/macintosh/windfarm_pm81.c
@@ -396,7 +396,7 @@ static void wf_smu_sys_fans_tick(struct wf_smu_sys_fans_state *st)
396static void wf_smu_create_cpu_fans(void) 396static void wf_smu_create_cpu_fans(void)
397{ 397{
398 struct wf_cpu_pid_param pid_param; 398 struct wf_cpu_pid_param pid_param;
399 struct smu_sdbp_header *hdr; 399 const struct smu_sdbp_header *hdr;
400 struct smu_sdbp_cpupiddata *piddata; 400 struct smu_sdbp_cpupiddata *piddata;
401 struct smu_sdbp_fvt *fvt; 401 struct smu_sdbp_fvt *fvt;
402 s32 tmax, tdelta, maxpow, powadj; 402 s32 tmax, tdelta, maxpow, powadj;
@@ -702,7 +702,7 @@ static struct notifier_block wf_smu_events = {
702 702
703static int wf_init_pm(void) 703static int wf_init_pm(void)
704{ 704{
705 struct smu_sdbp_header *hdr; 705 const struct smu_sdbp_header *hdr;
706 706
707 hdr = smu_get_sdb_partition(SMU_SDB_SENSORTREE_ID, NULL); 707 hdr = smu_get_sdb_partition(SMU_SDB_SENSORTREE_ID, NULL);
708 if (hdr != 0) { 708 if (hdr != 0) {
diff --git a/drivers/macintosh/windfarm_pm91.c b/drivers/macintosh/windfarm_pm91.c
index 0d6372e96d32..59e9ffe37c39 100644
--- a/drivers/macintosh/windfarm_pm91.c
+++ b/drivers/macintosh/windfarm_pm91.c
@@ -144,7 +144,7 @@ static struct wf_smu_slots_fans_state *wf_smu_slots_fans;
144static void wf_smu_create_cpu_fans(void) 144static void wf_smu_create_cpu_fans(void)
145{ 145{
146 struct wf_cpu_pid_param pid_param; 146 struct wf_cpu_pid_param pid_param;
147 struct smu_sdbp_header *hdr; 147 const struct smu_sdbp_header *hdr;
148 struct smu_sdbp_cpupiddata *piddata; 148 struct smu_sdbp_cpupiddata *piddata;
149 struct smu_sdbp_fvt *fvt; 149 struct smu_sdbp_fvt *fvt;
150 s32 tmax, tdelta, maxpow, powadj; 150 s32 tmax, tdelta, maxpow, powadj;
diff --git a/drivers/macintosh/windfarm_smu_controls.c b/drivers/macintosh/windfarm_smu_controls.c
index a9e88edc0c72..bff1f372f188 100644
--- a/drivers/macintosh/windfarm_smu_controls.c
+++ b/drivers/macintosh/windfarm_smu_controls.c
@@ -159,14 +159,15 @@ static struct smu_fan_control *smu_fan_create(struct device_node *node,
159 int pwm_fan) 159 int pwm_fan)
160{ 160{
161 struct smu_fan_control *fct; 161 struct smu_fan_control *fct;
162 s32 *v; u32 *reg; 162 const s32 *v;
163 char *l; 163 const u32 *reg;
164 const char *l;
164 165
165 fct = kmalloc(sizeof(struct smu_fan_control), GFP_KERNEL); 166 fct = kmalloc(sizeof(struct smu_fan_control), GFP_KERNEL);
166 if (fct == NULL) 167 if (fct == NULL)
167 return NULL; 168 return NULL;
168 fct->ctrl.ops = &smu_fan_ops; 169 fct->ctrl.ops = &smu_fan_ops;
169 l = (char *)get_property(node, "location", NULL); 170 l = get_property(node, "location", NULL);
170 if (l == NULL) 171 if (l == NULL)
171 goto fail; 172 goto fail;
172 173
@@ -223,17 +224,17 @@ static struct smu_fan_control *smu_fan_create(struct device_node *node,
223 goto fail; 224 goto fail;
224 225
225 /* Get min & max values*/ 226 /* Get min & max values*/
226 v = (s32 *)get_property(node, "min-value", NULL); 227 v = get_property(node, "min-value", NULL);
227 if (v == NULL) 228 if (v == NULL)
228 goto fail; 229 goto fail;
229 fct->min = *v; 230 fct->min = *v;
230 v = (s32 *)get_property(node, "max-value", NULL); 231 v = get_property(node, "max-value", NULL);
231 if (v == NULL) 232 if (v == NULL)
232 goto fail; 233 goto fail;
233 fct->max = *v; 234 fct->max = *v;
234 235
235 /* Get "reg" value */ 236 /* Get "reg" value */
236 reg = (u32 *)get_property(node, "reg", NULL); 237 reg = get_property(node, "reg", NULL);
237 if (reg == NULL) 238 if (reg == NULL)
238 goto fail; 239 goto fail;
239 fct->reg = *reg; 240 fct->reg = *reg;
diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c
index e295a07a1ebc..aceb61d9fbc8 100644
--- a/drivers/macintosh/windfarm_smu_sat.c
+++ b/drivers/macintosh/windfarm_smu_sat.c
@@ -233,15 +233,15 @@ static void wf_sat_create(struct i2c_adapter *adapter, struct device_node *dev)
233{ 233{
234 struct wf_sat *sat; 234 struct wf_sat *sat;
235 struct wf_sat_sensor *sens; 235 struct wf_sat_sensor *sens;
236 u32 *reg; 236 const u32 *reg;
237 char *loc, *type; 237 const char *loc, *type;
238 u8 addr, chip, core; 238 u8 addr, chip, core;
239 struct device_node *child; 239 struct device_node *child;
240 int shift, cpu, index; 240 int shift, cpu, index;
241 char *name; 241 char *name;
242 int vsens[2], isens[2]; 242 int vsens[2], isens[2];
243 243
244 reg = (u32 *) get_property(dev, "reg", NULL); 244 reg = get_property(dev, "reg", NULL);
245 if (reg == NULL) 245 if (reg == NULL)
246 return; 246 return;
247 addr = *reg; 247 addr = *reg;
@@ -268,7 +268,7 @@ static void wf_sat_create(struct i2c_adapter *adapter, struct device_node *dev)
268 isens[0] = isens[1] = -1; 268 isens[0] = isens[1] = -1;
269 child = NULL; 269 child = NULL;
270 while ((child = of_get_next_child(dev, child)) != NULL) { 270 while ((child = of_get_next_child(dev, child)) != NULL) {
271 reg = (u32 *) get_property(child, "reg", NULL); 271 reg = get_property(child, "reg", NULL);
272 type = get_property(child, "device_type", NULL); 272 type = get_property(child, "device_type", NULL);
273 loc = get_property(child, "location", NULL); 273 loc = get_property(child, "location", NULL);
274 if (reg == NULL || loc == NULL) 274 if (reg == NULL || loc == NULL)
diff --git a/drivers/macintosh/windfarm_smu_sensors.c b/drivers/macintosh/windfarm_smu_sensors.c
index bed25dcf8a1e..defe9922ebd1 100644
--- a/drivers/macintosh/windfarm_smu_sensors.c
+++ b/drivers/macintosh/windfarm_smu_sensors.c
@@ -198,14 +198,14 @@ static struct wf_sensor_ops smu_slotspow_ops = {
198static struct smu_ad_sensor *smu_ads_create(struct device_node *node) 198static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
199{ 199{
200 struct smu_ad_sensor *ads; 200 struct smu_ad_sensor *ads;
201 char *c, *l; 201 const char *c, *l;
202 u32 *v; 202 const u32 *v;
203 203
204 ads = kmalloc(sizeof(struct smu_ad_sensor), GFP_KERNEL); 204 ads = kmalloc(sizeof(struct smu_ad_sensor), GFP_KERNEL);
205 if (ads == NULL) 205 if (ads == NULL)
206 return NULL; 206 return NULL;
207 c = (char *)get_property(node, "device_type", NULL); 207 c = get_property(node, "device_type", NULL);
208 l = (char *)get_property(node, "location", NULL); 208 l = get_property(node, "location", NULL);
209 if (c == NULL || l == NULL) 209 if (c == NULL || l == NULL)
210 goto fail; 210 goto fail;
211 211
@@ -255,7 +255,7 @@ static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
255 } else 255 } else
256 goto fail; 256 goto fail;
257 257
258 v = (u32 *)get_property(node, "reg", NULL); 258 v = get_property(node, "reg", NULL);
259 if (v == NULL) 259 if (v == NULL)
260 goto fail; 260 goto fail;
261 ads->reg = *v; 261 ads->reg = *v;
@@ -382,7 +382,7 @@ smu_cpu_power_create(struct wf_sensor *volts, struct wf_sensor *amps)
382 382
383static void smu_fetch_param_partitions(void) 383static void smu_fetch_param_partitions(void)
384{ 384{
385 struct smu_sdbp_header *hdr; 385 const struct smu_sdbp_header *hdr;
386 386
387 /* Get CPU voltage/current/power calibration data */ 387 /* Get CPU voltage/current/power calibration data */
388 hdr = smu_get_sdb_partition(SMU_SDB_CPUVCP_ID, NULL); 388 hdr = smu_get_sdb_partition(SMU_SDB_CPUVCP_ID, NULL);
diff --git a/drivers/mtd/Kconfig b/drivers/mtd/Kconfig
index 1344ad7a4b14..717e90448fc6 100644
--- a/drivers/mtd/Kconfig
+++ b/drivers/mtd/Kconfig
@@ -263,6 +263,14 @@ config RFD_FTL
263 263
264 http://www.gensw.com/pages/prod/bios/rfd.htm 264 http://www.gensw.com/pages/prod/bios/rfd.htm
265 265
266config SSFDC
267 bool "NAND SSFDC (SmartMedia) read only translation layer"
268 depends on MTD
269 default n
270 help
271 This enables read only access to SmartMedia formatted NAND
272 flash. You can mount it with FAT file system.
273
266source "drivers/mtd/chips/Kconfig" 274source "drivers/mtd/chips/Kconfig"
267 275
268source "drivers/mtd/maps/Kconfig" 276source "drivers/mtd/maps/Kconfig"
diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
index fc9374407c2b..1e36b9aed98b 100644
--- a/drivers/mtd/Makefile
+++ b/drivers/mtd/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_FTL) += ftl.o mtd_blkdevs.o
21obj-$(CONFIG_NFTL) += nftl.o mtd_blkdevs.o 21obj-$(CONFIG_NFTL) += nftl.o mtd_blkdevs.o
22obj-$(CONFIG_INFTL) += inftl.o mtd_blkdevs.o 22obj-$(CONFIG_INFTL) += inftl.o mtd_blkdevs.o
23obj-$(CONFIG_RFD_FTL) += rfd_ftl.o mtd_blkdevs.o 23obj-$(CONFIG_RFD_FTL) += rfd_ftl.o mtd_blkdevs.o
24obj-$(CONFIG_SSFDC) += ssfdc.o mtd_blkdevs.o
24 25
25nftl-objs := nftlcore.o nftlmount.o 26nftl-objs := nftlcore.o nftlmount.o
26inftl-objs := inftlcore.o inftlmount.o 27inftl-objs := inftlcore.o inftlmount.o
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index a482e8922de1..702ae4cd8691 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -212,6 +212,7 @@ static void fixup_use_atmel_lock(struct mtd_info *mtd, void *param)
212{ 212{
213 mtd->lock = cfi_atmel_lock; 213 mtd->lock = cfi_atmel_lock;
214 mtd->unlock = cfi_atmel_unlock; 214 mtd->unlock = cfi_atmel_unlock;
215 mtd->flags |= MTD_STUPID_LOCK;
215} 216}
216 217
217static struct cfi_fixup cfi_fixup_table[] = { 218static struct cfi_fixup cfi_fixup_table[] = {
diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c
index 2c0149708739..354e1657cc26 100644
--- a/drivers/mtd/devices/pmc551.c
+++ b/drivers/mtd/devices/pmc551.c
@@ -4,82 +4,82 @@
4 * PMC551 PCI Mezzanine Ram Device 4 * PMC551 PCI Mezzanine Ram Device
5 * 5 *
6 * Author: 6 * Author:
7 * Mark Ferrell <mferrell@mvista.com> 7 * Mark Ferrell <mferrell@mvista.com>
8 * Copyright 1999,2000 Nortel Networks 8 * Copyright 1999,2000 Nortel Networks
9 * 9 *
10 * License: 10 * License:
11 * As part of this driver was derived from the slram.c driver it 11 * As part of this driver was derived from the slram.c driver it
12 * falls under the same license, which is GNU General Public 12 * falls under the same license, which is GNU General Public
13 * License v2 13 * License v2
14 * 14 *
15 * Description: 15 * Description:
16 * This driver is intended to support the PMC551 PCI Ram device 16 * This driver is intended to support the PMC551 PCI Ram device
17 * from Ramix Inc. The PMC551 is a PMC Mezzanine module for 17 * from Ramix Inc. The PMC551 is a PMC Mezzanine module for
18 * cPCI embedded systems. The device contains a single SROM 18 * cPCI embedded systems. The device contains a single SROM
19 * that initially programs the V370PDC chipset onboard the 19 * that initially programs the V370PDC chipset onboard the
20 * device, and various banks of DRAM/SDRAM onboard. This driver 20 * device, and various banks of DRAM/SDRAM onboard. This driver
21 * implements this PCI Ram device as an MTD (Memory Technology 21 * implements this PCI Ram device as an MTD (Memory Technology
22 * Device) so that it can be used to hold a file system, or for 22 * Device) so that it can be used to hold a file system, or for
23 * added swap space in embedded systems. Since the memory on 23 * added swap space in embedded systems. Since the memory on
24 * this board isn't as fast as main memory we do not try to hook 24 * this board isn't as fast as main memory we do not try to hook
25 * it into main memory as that would simply reduce performance 25 * it into main memory as that would simply reduce performance
26 * on the system. Using it as a block device allows us to use 26 * on the system. Using it as a block device allows us to use
27 * it as high speed swap or for a high speed disk device of some 27 * it as high speed swap or for a high speed disk device of some
28 * sort. Which becomes very useful on diskless systems in the 28 * sort. Which becomes very useful on diskless systems in the
29 * embedded market I might add. 29 * embedded market I might add.
30 * 30 *
31 * Notes: 31 * Notes:
32 * Due to what I assume is more buggy SROM, the 64M PMC551 I 32 * Due to what I assume is more buggy SROM, the 64M PMC551 I
33 * have available claims that all 4 of it's DRAM banks have 64M 33 * have available claims that all 4 of it's DRAM banks have 64M
34 * of ram configured (making a grand total of 256M onboard). 34 * of ram configured (making a grand total of 256M onboard).
35 * This is slightly annoying since the BAR0 size reflects the 35 * This is slightly annoying since the BAR0 size reflects the
36 * aperture size, not the dram size, and the V370PDC supplies no 36 * aperture size, not the dram size, and the V370PDC supplies no
37 * other method for memory size discovery. This problem is 37 * other method for memory size discovery. This problem is
38 * mostly only relevant when compiled as a module, as the 38 * mostly only relevant when compiled as a module, as the
39 * unloading of the module with an aperture size smaller then 39 * unloading of the module with an aperture size smaller then
40 * the ram will cause the driver to detect the onboard memory 40 * the ram will cause the driver to detect the onboard memory
41 * size to be equal to the aperture size when the module is 41 * size to be equal to the aperture size when the module is
42 * reloaded. Soooo, to help, the module supports an msize 42 * reloaded. Soooo, to help, the module supports an msize
43 * option to allow the specification of the onboard memory, and 43 * option to allow the specification of the onboard memory, and
44 * an asize option, to allow the specification of the aperture 44 * an asize option, to allow the specification of the aperture
45 * size. The aperture must be equal to or less then the memory 45 * size. The aperture must be equal to or less then the memory
46 * size, the driver will correct this if you screw it up. This 46 * size, the driver will correct this if you screw it up. This
47 * problem is not relevant for compiled in drivers as compiled 47 * problem is not relevant for compiled in drivers as compiled
48 * in drivers only init once. 48 * in drivers only init once.
49 * 49 *
50 * Credits: 50 * Credits:
51 * Saeed Karamooz <saeed@ramix.com> of Ramix INC. for the 51 * Saeed Karamooz <saeed@ramix.com> of Ramix INC. for the
52 * initial example code of how to initialize this device and for 52 * initial example code of how to initialize this device and for
53 * help with questions I had concerning operation of the device. 53 * help with questions I had concerning operation of the device.
54 * 54 *
55 * Most of the MTD code for this driver was originally written 55 * Most of the MTD code for this driver was originally written
56 * for the slram.o module in the MTD drivers package which 56 * for the slram.o module in the MTD drivers package which
57 * allows the mapping of system memory into an MTD device. 57 * allows the mapping of system memory into an MTD device.
58 * Since the PMC551 memory module is accessed in the same 58 * Since the PMC551 memory module is accessed in the same
59 * fashion as system memory, the slram.c code became a very nice 59 * fashion as system memory, the slram.c code became a very nice
60 * fit to the needs of this driver. All we added was PCI 60 * fit to the needs of this driver. All we added was PCI
61 * detection/initialization to the driver and automatically figure 61 * detection/initialization to the driver and automatically figure
62 * out the size via the PCI detection.o, later changes by Corey 62 * out the size via the PCI detection.o, later changes by Corey
63 * Minyard set up the card to utilize a 1M sliding apature. 63 * Minyard set up the card to utilize a 1M sliding apature.
64 * 64 *
65 * Corey Minyard <minyard@nortelnetworks.com> 65 * Corey Minyard <minyard@nortelnetworks.com>
66 * * Modified driver to utilize a sliding aperture instead of 66 * * Modified driver to utilize a sliding aperture instead of
67 * mapping all memory into kernel space which turned out to 67 * mapping all memory into kernel space which turned out to
68 * be very wasteful. 68 * be very wasteful.
69 * * Located a bug in the SROM's initialization sequence that 69 * * Located a bug in the SROM's initialization sequence that
70 * made the memory unusable, added a fix to code to touch up 70 * made the memory unusable, added a fix to code to touch up
71 * the DRAM some. 71 * the DRAM some.
72 * 72 *
73 * Bugs/FIXME's: 73 * Bugs/FIXME's:
74 * * MUST fix the init function to not spin on a register 74 * * MUST fix the init function to not spin on a register
75 * waiting for it to set .. this does not safely handle busted 75 * waiting for it to set .. this does not safely handle busted
76 * devices that never reset the register correctly which will 76 * devices that never reset the register correctly which will
77 * cause the system to hang w/ a reboot being the only chance at 77 * cause the system to hang w/ a reboot being the only chance at
78 * recover. [sort of fixed, could be better] 78 * recover. [sort of fixed, could be better]
79 * * Add I2C handling of the SROM so we can read the SROM's information 79 * * Add I2C handling of the SROM so we can read the SROM's information
80 * about the aperture size. This should always accurately reflect the 80 * about the aperture size. This should always accurately reflect the
81 * onboard memory size. 81 * onboard memory size.
82 * * Comb the init routine. It's still a bit cludgy on a few things. 82 * * Comb the init routine. It's still a bit cludgy on a few things.
83 */ 83 */
84 84
85#include <linux/kernel.h> 85#include <linux/kernel.h>
@@ -105,74 +105,77 @@
105 105
106static struct mtd_info *pmc551list; 106static struct mtd_info *pmc551list;
107 107
108static int pmc551_erase (struct mtd_info *mtd, struct erase_info *instr) 108static int pmc551_erase(struct mtd_info *mtd, struct erase_info *instr)
109{ 109{
110 struct mypriv *priv = mtd->priv; 110 struct mypriv *priv = mtd->priv;
111 u32 soff_hi, soff_lo; /* start address offset hi/lo */ 111 u32 soff_hi, soff_lo; /* start address offset hi/lo */
112 u32 eoff_hi, eoff_lo; /* end address offset hi/lo */ 112 u32 eoff_hi, eoff_lo; /* end address offset hi/lo */
113 unsigned long end; 113 unsigned long end;
114 u_char *ptr; 114 u_char *ptr;
115 size_t retlen; 115 size_t retlen;
116 116
117#ifdef CONFIG_MTD_PMC551_DEBUG 117#ifdef CONFIG_MTD_PMC551_DEBUG
118 printk(KERN_DEBUG "pmc551_erase(pos:%ld, len:%ld)\n", (long)instr->addr, (long)instr->len); 118 printk(KERN_DEBUG "pmc551_erase(pos:%ld, len:%ld)\n", (long)instr->addr,
119 (long)instr->len);
119#endif 120#endif
120 121
121 end = instr->addr + instr->len - 1; 122 end = instr->addr + instr->len - 1;
122 123
123 /* Is it past the end? */ 124 /* Is it past the end? */
124 if ( end > mtd->size ) { 125 if (end > mtd->size) {
125#ifdef CONFIG_MTD_PMC551_DEBUG 126#ifdef CONFIG_MTD_PMC551_DEBUG
126 printk(KERN_DEBUG "pmc551_erase() out of bounds (%ld > %ld)\n", (long)end, (long)mtd->size); 127 printk(KERN_DEBUG "pmc551_erase() out of bounds (%ld > %ld)\n",
128 (long)end, (long)mtd->size);
127#endif 129#endif
128 return -EINVAL; 130 return -EINVAL;
129 } 131 }
130 132
131 eoff_hi = end & ~(priv->asize - 1); 133 eoff_hi = end & ~(priv->asize - 1);
132 soff_hi = instr->addr & ~(priv->asize - 1); 134 soff_hi = instr->addr & ~(priv->asize - 1);
133 eoff_lo = end & (priv->asize - 1); 135 eoff_lo = end & (priv->asize - 1);
134 soff_lo = instr->addr & (priv->asize - 1); 136 soff_lo = instr->addr & (priv->asize - 1);
135 137
136 pmc551_point (mtd, instr->addr, instr->len, &retlen, &ptr); 138 pmc551_point(mtd, instr->addr, instr->len, &retlen, &ptr);
137 139
138 if ( soff_hi == eoff_hi || mtd->size == priv->asize) { 140 if (soff_hi == eoff_hi || mtd->size == priv->asize) {
139 /* The whole thing fits within one access, so just one shot 141 /* The whole thing fits within one access, so just one shot
140 will do it. */ 142 will do it. */
141 memset(ptr, 0xff, instr->len); 143 memset(ptr, 0xff, instr->len);
142 } else { 144 } else {
143 /* We have to do multiple writes to get all the data 145 /* We have to do multiple writes to get all the data
144 written. */ 146 written. */
145 while (soff_hi != eoff_hi) { 147 while (soff_hi != eoff_hi) {
146#ifdef CONFIG_MTD_PMC551_DEBUG 148#ifdef CONFIG_MTD_PMC551_DEBUG
147 printk( KERN_DEBUG "pmc551_erase() soff_hi: %ld, eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi); 149 printk(KERN_DEBUG "pmc551_erase() soff_hi: %ld, "
150 "eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi);
148#endif 151#endif
149 memset(ptr, 0xff, priv->asize); 152 memset(ptr, 0xff, priv->asize);
150 if (soff_hi + priv->asize >= mtd->size) { 153 if (soff_hi + priv->asize >= mtd->size) {
151 goto out; 154 goto out;
152 } 155 }
153 soff_hi += priv->asize; 156 soff_hi += priv->asize;
154 pmc551_point (mtd,(priv->base_map0|soff_hi), 157 pmc551_point(mtd, (priv->base_map0 | soff_hi),
155 priv->asize, &retlen, &ptr); 158 priv->asize, &retlen, &ptr);
156 } 159 }
157 memset (ptr, 0xff, eoff_lo); 160 memset(ptr, 0xff, eoff_lo);
158 } 161 }
159 162
160out: 163 out:
161 instr->state = MTD_ERASE_DONE; 164 instr->state = MTD_ERASE_DONE;
162#ifdef CONFIG_MTD_PMC551_DEBUG 165#ifdef CONFIG_MTD_PMC551_DEBUG
163 printk(KERN_DEBUG "pmc551_erase() done\n"); 166 printk(KERN_DEBUG "pmc551_erase() done\n");
164#endif 167#endif
165 168
166 mtd_erase_callback(instr); 169 mtd_erase_callback(instr);
167 return 0; 170 return 0;
168} 171}
169 172
170 173static int pmc551_point(struct mtd_info *mtd, loff_t from, size_t len,
171static int pmc551_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf) 174 size_t * retlen, u_char ** mtdbuf)
172{ 175{
173 struct mypriv *priv = mtd->priv; 176 struct mypriv *priv = mtd->priv;
174 u32 soff_hi; 177 u32 soff_hi;
175 u32 soff_lo; 178 u32 soff_lo;
176 179
177#ifdef CONFIG_MTD_PMC551_DEBUG 180#ifdef CONFIG_MTD_PMC551_DEBUG
178 printk(KERN_DEBUG "pmc551_point(%ld, %ld)\n", (long)from, (long)len); 181 printk(KERN_DEBUG "pmc551_point(%ld, %ld)\n", (long)from, (long)len);
@@ -180,18 +183,19 @@ static int pmc551_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *
180 183
181 if (from + len > mtd->size) { 184 if (from + len > mtd->size) {
182#ifdef CONFIG_MTD_PMC551_DEBUG 185#ifdef CONFIG_MTD_PMC551_DEBUG
183 printk(KERN_DEBUG "pmc551_point() out of bounds (%ld > %ld)\n", (long)from+len, (long)mtd->size); 186 printk(KERN_DEBUG "pmc551_point() out of bounds (%ld > %ld)\n",
187 (long)from + len, (long)mtd->size);
184#endif 188#endif
185 return -EINVAL; 189 return -EINVAL;
186 } 190 }
187 191
188 soff_hi = from & ~(priv->asize - 1); 192 soff_hi = from & ~(priv->asize - 1);
189 soff_lo = from & (priv->asize - 1); 193 soff_lo = from & (priv->asize - 1);
190 194
191 /* Cheap hack optimization */ 195 /* Cheap hack optimization */
192 if( priv->curr_map0 != from ) { 196 if (priv->curr_map0 != from) {
193 pci_write_config_dword ( priv->dev, PMC551_PCI_MEM_MAP0, 197 pci_write_config_dword(priv->dev, PMC551_PCI_MEM_MAP0,
194 (priv->base_map0 | soff_hi) ); 198 (priv->base_map0 | soff_hi));
195 priv->curr_map0 = soff_hi; 199 priv->curr_map0 = soff_hi;
196 } 200 }
197 201
@@ -200,137 +204,144 @@ static int pmc551_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *
200 return 0; 204 return 0;
201} 205}
202 206
203 207static void pmc551_unpoint(struct mtd_info *mtd, u_char * addr, loff_t from,
204static void pmc551_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from, size_t len) 208 size_t len)
205{ 209{
206#ifdef CONFIG_MTD_PMC551_DEBUG 210#ifdef CONFIG_MTD_PMC551_DEBUG
207 printk(KERN_DEBUG "pmc551_unpoint()\n"); 211 printk(KERN_DEBUG "pmc551_unpoint()\n");
208#endif 212#endif
209} 213}
210 214
211 215static int pmc551_read(struct mtd_info *mtd, loff_t from, size_t len,
212static int pmc551_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) 216 size_t * retlen, u_char * buf)
213{ 217{
214 struct mypriv *priv = mtd->priv; 218 struct mypriv *priv = mtd->priv;
215 u32 soff_hi, soff_lo; /* start address offset hi/lo */ 219 u32 soff_hi, soff_lo; /* start address offset hi/lo */
216 u32 eoff_hi, eoff_lo; /* end address offset hi/lo */ 220 u32 eoff_hi, eoff_lo; /* end address offset hi/lo */
217 unsigned long end; 221 unsigned long end;
218 u_char *ptr; 222 u_char *ptr;
219 u_char *copyto = buf; 223 u_char *copyto = buf;
220 224
221#ifdef CONFIG_MTD_PMC551_DEBUG 225#ifdef CONFIG_MTD_PMC551_DEBUG
222 printk(KERN_DEBUG "pmc551_read(pos:%ld, len:%ld) asize: %ld\n", (long)from, (long)len, (long)priv->asize); 226 printk(KERN_DEBUG "pmc551_read(pos:%ld, len:%ld) asize: %ld\n",
227 (long)from, (long)len, (long)priv->asize);
223#endif 228#endif
224 229
225 end = from + len - 1; 230 end = from + len - 1;
226 231
227 /* Is it past the end? */ 232 /* Is it past the end? */
228 if (end > mtd->size) { 233 if (end > mtd->size) {
229#ifdef CONFIG_MTD_PMC551_DEBUG 234#ifdef CONFIG_MTD_PMC551_DEBUG
230 printk(KERN_DEBUG "pmc551_read() out of bounds (%ld > %ld)\n", (long) end, (long)mtd->size); 235 printk(KERN_DEBUG "pmc551_read() out of bounds (%ld > %ld)\n",
236 (long)end, (long)mtd->size);
231#endif 237#endif
232 return -EINVAL; 238 return -EINVAL;
233 } 239 }
234 240
235 soff_hi = from & ~(priv->asize - 1); 241 soff_hi = from & ~(priv->asize - 1);
236 eoff_hi = end & ~(priv->asize - 1); 242 eoff_hi = end & ~(priv->asize - 1);
237 soff_lo = from & (priv->asize - 1); 243 soff_lo = from & (priv->asize - 1);
238 eoff_lo = end & (priv->asize - 1); 244 eoff_lo = end & (priv->asize - 1);
239 245
240 pmc551_point (mtd, from, len, retlen, &ptr); 246 pmc551_point(mtd, from, len, retlen, &ptr);
241 247
242 if (soff_hi == eoff_hi) { 248 if (soff_hi == eoff_hi) {
243 /* The whole thing fits within one access, so just one shot 249 /* The whole thing fits within one access, so just one shot
244 will do it. */ 250 will do it. */
245 memcpy(copyto, ptr, len); 251 memcpy(copyto, ptr, len);
246 copyto += len; 252 copyto += len;
247 } else { 253 } else {
248 /* We have to do multiple writes to get all the data 254 /* We have to do multiple writes to get all the data
249 written. */ 255 written. */
250 while (soff_hi != eoff_hi) { 256 while (soff_hi != eoff_hi) {
251#ifdef CONFIG_MTD_PMC551_DEBUG 257#ifdef CONFIG_MTD_PMC551_DEBUG
252 printk( KERN_DEBUG "pmc551_read() soff_hi: %ld, eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi); 258 printk(KERN_DEBUG "pmc551_read() soff_hi: %ld, "
259 "eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi);
253#endif 260#endif
254 memcpy(copyto, ptr, priv->asize); 261 memcpy(copyto, ptr, priv->asize);
255 copyto += priv->asize; 262 copyto += priv->asize;
256 if (soff_hi + priv->asize >= mtd->size) { 263 if (soff_hi + priv->asize >= mtd->size) {
257 goto out; 264 goto out;
258 } 265 }
259 soff_hi += priv->asize; 266 soff_hi += priv->asize;
260 pmc551_point (mtd, soff_hi, priv->asize, retlen, &ptr); 267 pmc551_point(mtd, soff_hi, priv->asize, retlen, &ptr);
261 } 268 }
262 memcpy(copyto, ptr, eoff_lo); 269 memcpy(copyto, ptr, eoff_lo);
263 copyto += eoff_lo; 270 copyto += eoff_lo;
264 } 271 }
265 272
266out: 273 out:
267#ifdef CONFIG_MTD_PMC551_DEBUG 274#ifdef CONFIG_MTD_PMC551_DEBUG
268 printk(KERN_DEBUG "pmc551_read() done\n"); 275 printk(KERN_DEBUG "pmc551_read() done\n");
269#endif 276#endif
270 *retlen = copyto - buf; 277 *retlen = copyto - buf;
271 return 0; 278 return 0;
272} 279}
273 280
274static int pmc551_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) 281static int pmc551_write(struct mtd_info *mtd, loff_t to, size_t len,
282 size_t * retlen, const u_char * buf)
275{ 283{
276 struct mypriv *priv = mtd->priv; 284 struct mypriv *priv = mtd->priv;
277 u32 soff_hi, soff_lo; /* start address offset hi/lo */ 285 u32 soff_hi, soff_lo; /* start address offset hi/lo */
278 u32 eoff_hi, eoff_lo; /* end address offset hi/lo */ 286 u32 eoff_hi, eoff_lo; /* end address offset hi/lo */
279 unsigned long end; 287 unsigned long end;
280 u_char *ptr; 288 u_char *ptr;
281 const u_char *copyfrom = buf; 289 const u_char *copyfrom = buf;
282
283 290
284#ifdef CONFIG_MTD_PMC551_DEBUG 291#ifdef CONFIG_MTD_PMC551_DEBUG
285 printk(KERN_DEBUG "pmc551_write(pos:%ld, len:%ld) asize:%ld\n", (long)to, (long)len, (long)priv->asize); 292 printk(KERN_DEBUG "pmc551_write(pos:%ld, len:%ld) asize:%ld\n",
293 (long)to, (long)len, (long)priv->asize);
286#endif 294#endif
287 295
288 end = to + len - 1; 296 end = to + len - 1;
289 /* Is it past the end? or did the u32 wrap? */ 297 /* Is it past the end? or did the u32 wrap? */
290 if (end > mtd->size ) { 298 if (end > mtd->size) {
291#ifdef CONFIG_MTD_PMC551_DEBUG 299#ifdef CONFIG_MTD_PMC551_DEBUG
292 printk(KERN_DEBUG "pmc551_write() out of bounds (end: %ld, size: %ld, to: %ld)\n", (long) end, (long)mtd->size, (long)to); 300 printk(KERN_DEBUG "pmc551_write() out of bounds (end: %ld, "
301 "size: %ld, to: %ld)\n", (long)end, (long)mtd->size,
302 (long)to);
293#endif 303#endif
294 return -EINVAL; 304 return -EINVAL;
295 } 305 }
296 306
297 soff_hi = to & ~(priv->asize - 1); 307 soff_hi = to & ~(priv->asize - 1);
298 eoff_hi = end & ~(priv->asize - 1); 308 eoff_hi = end & ~(priv->asize - 1);
299 soff_lo = to & (priv->asize - 1); 309 soff_lo = to & (priv->asize - 1);
300 eoff_lo = end & (priv->asize - 1); 310 eoff_lo = end & (priv->asize - 1);
301 311
302 pmc551_point (mtd, to, len, retlen, &ptr); 312 pmc551_point(mtd, to, len, retlen, &ptr);
303 313
304 if (soff_hi == eoff_hi) { 314 if (soff_hi == eoff_hi) {
305 /* The whole thing fits within one access, so just one shot 315 /* The whole thing fits within one access, so just one shot
306 will do it. */ 316 will do it. */
307 memcpy(ptr, copyfrom, len); 317 memcpy(ptr, copyfrom, len);
308 copyfrom += len; 318 copyfrom += len;
309 } else { 319 } else {
310 /* We have to do multiple writes to get all the data 320 /* We have to do multiple writes to get all the data
311 written. */ 321 written. */
312 while (soff_hi != eoff_hi) { 322 while (soff_hi != eoff_hi) {
313#ifdef CONFIG_MTD_PMC551_DEBUG 323#ifdef CONFIG_MTD_PMC551_DEBUG
314 printk( KERN_DEBUG "pmc551_write() soff_hi: %ld, eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi); 324 printk(KERN_DEBUG "pmc551_write() soff_hi: %ld, "
325 "eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi);
315#endif 326#endif
316 memcpy(ptr, copyfrom, priv->asize); 327 memcpy(ptr, copyfrom, priv->asize);
317 copyfrom += priv->asize; 328 copyfrom += priv->asize;
318 if (soff_hi >= mtd->size) { 329 if (soff_hi >= mtd->size) {
319 goto out; 330 goto out;
320 } 331 }
321 soff_hi += priv->asize; 332 soff_hi += priv->asize;
322 pmc551_point (mtd, soff_hi, priv->asize, retlen, &ptr); 333 pmc551_point(mtd, soff_hi, priv->asize, retlen, &ptr);
323 } 334 }
324 memcpy(ptr, copyfrom, eoff_lo); 335 memcpy(ptr, copyfrom, eoff_lo);
325 copyfrom += eoff_lo; 336 copyfrom += eoff_lo;
326 } 337 }
327 338
328out: 339 out:
329#ifdef CONFIG_MTD_PMC551_DEBUG 340#ifdef CONFIG_MTD_PMC551_DEBUG
330 printk(KERN_DEBUG "pmc551_write() done\n"); 341 printk(KERN_DEBUG "pmc551_write() done\n");
331#endif 342#endif
332 *retlen = copyfrom - buf; 343 *retlen = copyfrom - buf;
333 return 0; 344 return 0;
334} 345}
335 346
336/* 347/*
@@ -345,58 +356,58 @@ out:
345 * mechanism 356 * mechanism
346 * returns the size of the memory region found. 357 * returns the size of the memory region found.
347 */ 358 */
348static u32 fixup_pmc551 (struct pci_dev *dev) 359static u32 fixup_pmc551(struct pci_dev *dev)
349{ 360{
350#ifdef CONFIG_MTD_PMC551_BUGFIX 361#ifdef CONFIG_MTD_PMC551_BUGFIX
351 u32 dram_data; 362 u32 dram_data;
352#endif 363#endif
353 u32 size, dcmd, cfg, dtmp; 364 u32 size, dcmd, cfg, dtmp;
354 u16 cmd, tmp, i; 365 u16 cmd, tmp, i;
355 u8 bcmd, counter; 366 u8 bcmd, counter;
356 367
357 /* Sanity Check */ 368 /* Sanity Check */
358 if(!dev) { 369 if (!dev) {
359 return -ENODEV; 370 return -ENODEV;
360 } 371 }
361 372
362 /* 373 /*
363 * Attempt to reset the card 374 * Attempt to reset the card
364 * FIXME: Stop Spinning registers 375 * FIXME: Stop Spinning registers
365 */ 376 */
366 counter=0; 377 counter = 0;
367 /* unlock registers */ 378 /* unlock registers */
368 pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, 0xA5 ); 379 pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, 0xA5);
369 /* read in old data */ 380 /* read in old data */
370 pci_read_config_byte(dev, PMC551_SYS_CTRL_REG, &bcmd ); 381 pci_read_config_byte(dev, PMC551_SYS_CTRL_REG, &bcmd);
371 /* bang the reset line up and down for a few */ 382 /* bang the reset line up and down for a few */
372 for(i=0;i<10;i++) { 383 for (i = 0; i < 10; i++) {
373 counter=0; 384 counter = 0;
374 bcmd &= ~0x80; 385 bcmd &= ~0x80;
375 while(counter++ < 100) { 386 while (counter++ < 100) {
376 pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd); 387 pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd);
377 } 388 }
378 counter=0; 389 counter = 0;
379 bcmd |= 0x80; 390 bcmd |= 0x80;
380 while(counter++ < 100) { 391 while (counter++ < 100) {
381 pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd); 392 pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd);
382 } 393 }
383 } 394 }
384 bcmd |= (0x40|0x20); 395 bcmd |= (0x40 | 0x20);
385 pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd); 396 pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd);
386 397
387 /* 398 /*
388 * Take care and turn off the memory on the device while we 399 * Take care and turn off the memory on the device while we
389 * tweak the configurations 400 * tweak the configurations
390 */ 401 */
391 pci_read_config_word(dev, PCI_COMMAND, &cmd); 402 pci_read_config_word(dev, PCI_COMMAND, &cmd);
392 tmp = cmd & ~(PCI_COMMAND_IO|PCI_COMMAND_MEMORY); 403 tmp = cmd & ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
393 pci_write_config_word(dev, PCI_COMMAND, tmp); 404 pci_write_config_word(dev, PCI_COMMAND, tmp);
394 405
395 /* 406 /*
396 * Disable existing aperture before probing memory size 407 * Disable existing aperture before probing memory size
397 */ 408 */
398 pci_read_config_dword(dev, PMC551_PCI_MEM_MAP0, &dcmd); 409 pci_read_config_dword(dev, PMC551_PCI_MEM_MAP0, &dcmd);
399 dtmp=(dcmd|PMC551_PCI_MEM_MAP_ENABLE|PMC551_PCI_MEM_MAP_REG_EN); 410 dtmp = (dcmd | PMC551_PCI_MEM_MAP_ENABLE | PMC551_PCI_MEM_MAP_REG_EN);
400 pci_write_config_dword(dev, PMC551_PCI_MEM_MAP0, dtmp); 411 pci_write_config_dword(dev, PMC551_PCI_MEM_MAP0, dtmp);
401 /* 412 /*
402 * Grab old BAR0 config so that we can figure out memory size 413 * Grab old BAR0 config so that we can figure out memory size
@@ -407,220 +418,230 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
407 * then write all 1's to the memory space, read back the result into 418 * then write all 1's to the memory space, read back the result into
408 * "size", and then write back all the old config. 419 * "size", and then write back all the old config.
409 */ 420 */
410 pci_read_config_dword( dev, PCI_BASE_ADDRESS_0, &cfg ); 421 pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &cfg);
411#ifndef CONFIG_MTD_PMC551_BUGFIX 422#ifndef CONFIG_MTD_PMC551_BUGFIX
412 pci_write_config_dword( dev, PCI_BASE_ADDRESS_0, ~0 ); 423 pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, ~0);
413 pci_read_config_dword( dev, PCI_BASE_ADDRESS_0, &size ); 424 pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &size);
414 size = (size&PCI_BASE_ADDRESS_MEM_MASK); 425 size = (size & PCI_BASE_ADDRESS_MEM_MASK);
415 size &= ~(size-1); 426 size &= ~(size - 1);
416 pci_write_config_dword( dev, PCI_BASE_ADDRESS_0, cfg ); 427 pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, cfg);
417#else 428#else
418 /* 429 /*
419 * Get the size of the memory by reading all the DRAM size values 430 * Get the size of the memory by reading all the DRAM size values
420 * and adding them up. 431 * and adding them up.
421 * 432 *
422 * KLUDGE ALERT: the boards we are using have invalid column and 433 * KLUDGE ALERT: the boards we are using have invalid column and
423 * row mux values. We fix them here, but this will break other 434 * row mux values. We fix them here, but this will break other
424 * memory configurations. 435 * memory configurations.
425 */ 436 */
426 pci_read_config_dword(dev, PMC551_DRAM_BLK0, &dram_data); 437 pci_read_config_dword(dev, PMC551_DRAM_BLK0, &dram_data);
427 size = PMC551_DRAM_BLK_GET_SIZE(dram_data); 438 size = PMC551_DRAM_BLK_GET_SIZE(dram_data);
428 dram_data = PMC551_DRAM_BLK_SET_COL_MUX(dram_data, 0x5); 439 dram_data = PMC551_DRAM_BLK_SET_COL_MUX(dram_data, 0x5);
429 dram_data = PMC551_DRAM_BLK_SET_ROW_MUX(dram_data, 0x9); 440 dram_data = PMC551_DRAM_BLK_SET_ROW_MUX(dram_data, 0x9);
430 pci_write_config_dword(dev, PMC551_DRAM_BLK0, dram_data); 441 pci_write_config_dword(dev, PMC551_DRAM_BLK0, dram_data);
431 442
432 pci_read_config_dword(dev, PMC551_DRAM_BLK1, &dram_data); 443 pci_read_config_dword(dev, PMC551_DRAM_BLK1, &dram_data);
433 size += PMC551_DRAM_BLK_GET_SIZE(dram_data); 444 size += PMC551_DRAM_BLK_GET_SIZE(dram_data);
434 dram_data = PMC551_DRAM_BLK_SET_COL_MUX(dram_data, 0x5); 445 dram_data = PMC551_DRAM_BLK_SET_COL_MUX(dram_data, 0x5);
435 dram_data = PMC551_DRAM_BLK_SET_ROW_MUX(dram_data, 0x9); 446 dram_data = PMC551_DRAM_BLK_SET_ROW_MUX(dram_data, 0x9);
436 pci_write_config_dword(dev, PMC551_DRAM_BLK1, dram_data); 447 pci_write_config_dword(dev, PMC551_DRAM_BLK1, dram_data);
437 448
438 pci_read_config_dword(dev, PMC551_DRAM_BLK2, &dram_data); 449 pci_read_config_dword(dev, PMC551_DRAM_BLK2, &dram_data);
439 size += PMC551_DRAM_BLK_GET_SIZE(dram_data); 450 size += PMC551_DRAM_BLK_GET_SIZE(dram_data);
440 dram_data = PMC551_DRAM_BLK_SET_COL_MUX(dram_data, 0x5); 451 dram_data = PMC551_DRAM_BLK_SET_COL_MUX(dram_data, 0x5);
441 dram_data = PMC551_DRAM_BLK_SET_ROW_MUX(dram_data, 0x9); 452 dram_data = PMC551_DRAM_BLK_SET_ROW_MUX(dram_data, 0x9);
442 pci_write_config_dword(dev, PMC551_DRAM_BLK2, dram_data); 453 pci_write_config_dword(dev, PMC551_DRAM_BLK2, dram_data);
443 454
444 pci_read_config_dword(dev, PMC551_DRAM_BLK3, &dram_data); 455 pci_read_config_dword(dev, PMC551_DRAM_BLK3, &dram_data);
445 size += PMC551_DRAM_BLK_GET_SIZE(dram_data); 456 size += PMC551_DRAM_BLK_GET_SIZE(dram_data);
446 dram_data = PMC551_DRAM_BLK_SET_COL_MUX(dram_data, 0x5); 457 dram_data = PMC551_DRAM_BLK_SET_COL_MUX(dram_data, 0x5);
447 dram_data = PMC551_DRAM_BLK_SET_ROW_MUX(dram_data, 0x9); 458 dram_data = PMC551_DRAM_BLK_SET_ROW_MUX(dram_data, 0x9);
448 pci_write_config_dword(dev, PMC551_DRAM_BLK3, dram_data); 459 pci_write_config_dword(dev, PMC551_DRAM_BLK3, dram_data);
449 460
450 /* 461 /*
451 * Oops .. something went wrong 462 * Oops .. something went wrong
452 */ 463 */
453 if( (size &= PCI_BASE_ADDRESS_MEM_MASK) == 0) { 464 if ((size &= PCI_BASE_ADDRESS_MEM_MASK) == 0) {
454 return -ENODEV; 465 return -ENODEV;
455 } 466 }
456#endif /* CONFIG_MTD_PMC551_BUGFIX */ 467#endif /* CONFIG_MTD_PMC551_BUGFIX */
457 468
458 if ((cfg&PCI_BASE_ADDRESS_SPACE) != PCI_BASE_ADDRESS_SPACE_MEMORY) { 469 if ((cfg & PCI_BASE_ADDRESS_SPACE) != PCI_BASE_ADDRESS_SPACE_MEMORY) {
459 return -ENODEV; 470 return -ENODEV;
460 } 471 }
461 472
462 /* 473 /*
463 * Precharge Dram 474 * Precharge Dram
464 */ 475 */
465 pci_write_config_word( dev, PMC551_SDRAM_MA, 0x0400 ); 476 pci_write_config_word(dev, PMC551_SDRAM_MA, 0x0400);
466 pci_write_config_word( dev, PMC551_SDRAM_CMD, 0x00bf ); 477 pci_write_config_word(dev, PMC551_SDRAM_CMD, 0x00bf);
467 478
468 /* 479 /*
469 * Wait until command has gone through 480 * Wait until command has gone through
470 * FIXME: register spinning issue 481 * FIXME: register spinning issue
471 */ 482 */
472 do { pci_read_config_word( dev, PMC551_SDRAM_CMD, &cmd ); 483 do {
473 if(counter++ > 100)break; 484 pci_read_config_word(dev, PMC551_SDRAM_CMD, &cmd);
474 } while ( (PCI_COMMAND_IO) & cmd ); 485 if (counter++ > 100)
475 486 break;
476 /* 487 } while ((PCI_COMMAND_IO) & cmd);
488
489 /*
477 * Turn on auto refresh 490 * Turn on auto refresh
478 * The loop is taken directly from Ramix's example code. I assume that 491 * The loop is taken directly from Ramix's example code. I assume that
479 * this must be held high for some duration of time, but I can find no 492 * this must be held high for some duration of time, but I can find no
480 * documentation refrencing the reasons why. 493 * documentation refrencing the reasons why.
481 */ 494 */
482 for ( i = 1; i<=8 ; i++) { 495 for (i = 1; i <= 8; i++) {
483 pci_write_config_word (dev, PMC551_SDRAM_CMD, 0x0df); 496 pci_write_config_word(dev, PMC551_SDRAM_CMD, 0x0df);
484 497
485 /* 498 /*
486 * Make certain command has gone through 499 * Make certain command has gone through
487 * FIXME: register spinning issue 500 * FIXME: register spinning issue
488 */ 501 */
489 counter=0; 502 counter = 0;
490 do { pci_read_config_word(dev, PMC551_SDRAM_CMD, &cmd); 503 do {
491 if(counter++ > 100)break; 504 pci_read_config_word(dev, PMC551_SDRAM_CMD, &cmd);
492 } while ( (PCI_COMMAND_IO) & cmd ); 505 if (counter++ > 100)
493 } 506 break;
494 507 } while ((PCI_COMMAND_IO) & cmd);
495 pci_write_config_word ( dev, PMC551_SDRAM_MA, 0x0020); 508 }
496 pci_write_config_word ( dev, PMC551_SDRAM_CMD, 0x0ff); 509
497 510 pci_write_config_word(dev, PMC551_SDRAM_MA, 0x0020);
498 /* 511 pci_write_config_word(dev, PMC551_SDRAM_CMD, 0x0ff);
499 * Wait until command completes 512
500 * FIXME: register spinning issue 513 /*
501 */ 514 * Wait until command completes
502 counter=0; 515 * FIXME: register spinning issue
503 do { pci_read_config_word ( dev, PMC551_SDRAM_CMD, &cmd); 516 */
504 if(counter++ > 100)break; 517 counter = 0;
505 } while ( (PCI_COMMAND_IO) & cmd ); 518 do {
506 519 pci_read_config_word(dev, PMC551_SDRAM_CMD, &cmd);
507 pci_read_config_dword ( dev, PMC551_DRAM_CFG, &dcmd); 520 if (counter++ > 100)
508 dcmd |= 0x02000000; 521 break;
509 pci_write_config_dword ( dev, PMC551_DRAM_CFG, dcmd); 522 } while ((PCI_COMMAND_IO) & cmd);
510 523
511 /* 524 pci_read_config_dword(dev, PMC551_DRAM_CFG, &dcmd);
512 * Check to make certain fast back-to-back, if not 525 dcmd |= 0x02000000;
513 * then set it so 526 pci_write_config_dword(dev, PMC551_DRAM_CFG, dcmd);
514 */ 527
515 pci_read_config_word( dev, PCI_STATUS, &cmd); 528 /*
516 if((cmd&PCI_COMMAND_FAST_BACK) == 0) { 529 * Check to make certain fast back-to-back, if not
517 cmd |= PCI_COMMAND_FAST_BACK; 530 * then set it so
518 pci_write_config_word( dev, PCI_STATUS, cmd); 531 */
519 } 532 pci_read_config_word(dev, PCI_STATUS, &cmd);
520 533 if ((cmd & PCI_COMMAND_FAST_BACK) == 0) {
521 /* 534 cmd |= PCI_COMMAND_FAST_BACK;
522 * Check to make certain the DEVSEL is set correctly, this device 535 pci_write_config_word(dev, PCI_STATUS, cmd);
523 * has a tendancy to assert DEVSEL and TRDY when a write is performed 536 }
524 * to the memory when memory is read-only 537
525 */ 538 /*
526 if((cmd&PCI_STATUS_DEVSEL_MASK) != 0x0) { 539 * Check to make certain the DEVSEL is set correctly, this device
527 cmd &= ~PCI_STATUS_DEVSEL_MASK; 540 * has a tendancy to assert DEVSEL and TRDY when a write is performed
528 pci_write_config_word( dev, PCI_STATUS, cmd ); 541 * to the memory when memory is read-only
529 } 542 */
530 /* 543 if ((cmd & PCI_STATUS_DEVSEL_MASK) != 0x0) {
531 * Set to be prefetchable and put everything back based on old cfg. 544 cmd &= ~PCI_STATUS_DEVSEL_MASK;
545 pci_write_config_word(dev, PCI_STATUS, cmd);
546 }
547 /*
548 * Set to be prefetchable and put everything back based on old cfg.
532 * it's possible that the reset of the V370PDC nuked the original 549 * it's possible that the reset of the V370PDC nuked the original
533 * setup 550 * setup
534 */ 551 */
552 /*
553 cfg |= PCI_BASE_ADDRESS_MEM_PREFETCH;
554 pci_write_config_dword( dev, PCI_BASE_ADDRESS_0, cfg );
555 */
556
535 /* 557 /*
536 cfg |= PCI_BASE_ADDRESS_MEM_PREFETCH; 558 * Turn PCI memory and I/O bus access back on
537 pci_write_config_dword( dev, PCI_BASE_ADDRESS_0, cfg ); 559 */
538 */ 560 pci_write_config_word(dev, PCI_COMMAND,
539 561 PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
540 /*
541 * Turn PCI memory and I/O bus access back on
542 */
543 pci_write_config_word( dev, PCI_COMMAND,
544 PCI_COMMAND_MEMORY | PCI_COMMAND_IO );
545#ifdef CONFIG_MTD_PMC551_DEBUG 562#ifdef CONFIG_MTD_PMC551_DEBUG
546 /* 563 /*
547 * Some screen fun 564 * Some screen fun
548 */ 565 */
549 printk(KERN_DEBUG "pmc551: %d%c (0x%x) of %sprefetchable memory at 0x%llx\n", 566 printk(KERN_DEBUG "pmc551: %d%c (0x%x) of %sprefetchable memory at "
550 (size<1024)?size:(size<1048576)?size>>10:size>>20, 567 "0x%llx\n", (size < 1024) ? size : (size < 1048576) ?
551 (size<1024)?'B':(size<1048576)?'K':'M', 568 size >> 10 : size >> 20,
552 size, ((dcmd&(0x1<<3)) == 0)?"non-":"", 569 (size < 1024) ? 'B' : (size < 1048576) ? 'K' : 'M', size,
553 (unsigned long long)((dev->resource[0].start)&PCI_BASE_ADDRESS_MEM_MASK)); 570 ((dcmd & (0x1 << 3)) == 0) ? "non-" : "",
554 571 (unsigned long long)pci_resource_start(dev, 0));
555 /* 572
556 * Check to see the state of the memory 573 /*
557 */ 574 * Check to see the state of the memory
558 pci_read_config_dword( dev, PMC551_DRAM_BLK0, &dcmd ); 575 */
559 printk(KERN_DEBUG "pmc551: DRAM_BLK0 Flags: %s,%s\n" 576 pci_read_config_dword(dev, PMC551_DRAM_BLK0, &dcmd);
560 "pmc551: DRAM_BLK0 Size: %d at %d\n" 577 printk(KERN_DEBUG "pmc551: DRAM_BLK0 Flags: %s,%s\n"
561 "pmc551: DRAM_BLK0 Row MUX: %d, Col MUX: %d\n", 578 "pmc551: DRAM_BLK0 Size: %d at %d\n"
562 (((0x1<<1)&dcmd) == 0)?"RW":"RO", 579 "pmc551: DRAM_BLK0 Row MUX: %d, Col MUX: %d\n",
563 (((0x1<<0)&dcmd) == 0)?"Off":"On", 580 (((0x1 << 1) & dcmd) == 0) ? "RW" : "RO",
564 PMC551_DRAM_BLK_GET_SIZE(dcmd), 581 (((0x1 << 0) & dcmd) == 0) ? "Off" : "On",
565 ((dcmd>>20)&0x7FF), ((dcmd>>13)&0x7), ((dcmd>>9)&0xF) ); 582 PMC551_DRAM_BLK_GET_SIZE(dcmd),
566 583 ((dcmd >> 20) & 0x7FF), ((dcmd >> 13) & 0x7),
567 pci_read_config_dword( dev, PMC551_DRAM_BLK1, &dcmd ); 584 ((dcmd >> 9) & 0xF));
568 printk(KERN_DEBUG "pmc551: DRAM_BLK1 Flags: %s,%s\n" 585
569 "pmc551: DRAM_BLK1 Size: %d at %d\n" 586 pci_read_config_dword(dev, PMC551_DRAM_BLK1, &dcmd);
570 "pmc551: DRAM_BLK1 Row MUX: %d, Col MUX: %d\n", 587 printk(KERN_DEBUG "pmc551: DRAM_BLK1 Flags: %s,%s\n"
571 (((0x1<<1)&dcmd) == 0)?"RW":"RO", 588 "pmc551: DRAM_BLK1 Size: %d at %d\n"
572 (((0x1<<0)&dcmd) == 0)?"Off":"On", 589 "pmc551: DRAM_BLK1 Row MUX: %d, Col MUX: %d\n",
573 PMC551_DRAM_BLK_GET_SIZE(dcmd), 590 (((0x1 << 1) & dcmd) == 0) ? "RW" : "RO",
574 ((dcmd>>20)&0x7FF), ((dcmd>>13)&0x7), ((dcmd>>9)&0xF) ); 591 (((0x1 << 0) & dcmd) == 0) ? "Off" : "On",
575 592 PMC551_DRAM_BLK_GET_SIZE(dcmd),
576 pci_read_config_dword( dev, PMC551_DRAM_BLK2, &dcmd ); 593 ((dcmd >> 20) & 0x7FF), ((dcmd >> 13) & 0x7),
577 printk(KERN_DEBUG "pmc551: DRAM_BLK2 Flags: %s,%s\n" 594 ((dcmd >> 9) & 0xF));
578 "pmc551: DRAM_BLK2 Size: %d at %d\n" 595
579 "pmc551: DRAM_BLK2 Row MUX: %d, Col MUX: %d\n", 596 pci_read_config_dword(dev, PMC551_DRAM_BLK2, &dcmd);
580 (((0x1<<1)&dcmd) == 0)?"RW":"RO", 597 printk(KERN_DEBUG "pmc551: DRAM_BLK2 Flags: %s,%s\n"
581 (((0x1<<0)&dcmd) == 0)?"Off":"On", 598 "pmc551: DRAM_BLK2 Size: %d at %d\n"
582 PMC551_DRAM_BLK_GET_SIZE(dcmd), 599 "pmc551: DRAM_BLK2 Row MUX: %d, Col MUX: %d\n",
583 ((dcmd>>20)&0x7FF), ((dcmd>>13)&0x7), ((dcmd>>9)&0xF) ); 600 (((0x1 << 1) & dcmd) == 0) ? "RW" : "RO",
584 601 (((0x1 << 0) & dcmd) == 0) ? "Off" : "On",
585 pci_read_config_dword( dev, PMC551_DRAM_BLK3, &dcmd ); 602 PMC551_DRAM_BLK_GET_SIZE(dcmd),
586 printk(KERN_DEBUG "pmc551: DRAM_BLK3 Flags: %s,%s\n" 603 ((dcmd >> 20) & 0x7FF), ((dcmd >> 13) & 0x7),
587 "pmc551: DRAM_BLK3 Size: %d at %d\n" 604 ((dcmd >> 9) & 0xF));
588 "pmc551: DRAM_BLK3 Row MUX: %d, Col MUX: %d\n", 605
589 (((0x1<<1)&dcmd) == 0)?"RW":"RO", 606 pci_read_config_dword(dev, PMC551_DRAM_BLK3, &dcmd);
590 (((0x1<<0)&dcmd) == 0)?"Off":"On", 607 printk(KERN_DEBUG "pmc551: DRAM_BLK3 Flags: %s,%s\n"
591 PMC551_DRAM_BLK_GET_SIZE(dcmd), 608 "pmc551: DRAM_BLK3 Size: %d at %d\n"
592 ((dcmd>>20)&0x7FF), ((dcmd>>13)&0x7), ((dcmd>>9)&0xF) ); 609 "pmc551: DRAM_BLK3 Row MUX: %d, Col MUX: %d\n",
593 610 (((0x1 << 1) & dcmd) == 0) ? "RW" : "RO",
594 pci_read_config_word( dev, PCI_COMMAND, &cmd ); 611 (((0x1 << 0) & dcmd) == 0) ? "Off" : "On",
595 printk( KERN_DEBUG "pmc551: Memory Access %s\n", 612 PMC551_DRAM_BLK_GET_SIZE(dcmd),
596 (((0x1<<1)&cmd) == 0)?"off":"on" ); 613 ((dcmd >> 20) & 0x7FF), ((dcmd >> 13) & 0x7),
597 printk( KERN_DEBUG "pmc551: I/O Access %s\n", 614 ((dcmd >> 9) & 0xF));
598 (((0x1<<0)&cmd) == 0)?"off":"on" ); 615
599 616 pci_read_config_word(dev, PCI_COMMAND, &cmd);
600 pci_read_config_word( dev, PCI_STATUS, &cmd ); 617 printk(KERN_DEBUG "pmc551: Memory Access %s\n",
601 printk( KERN_DEBUG "pmc551: Devsel %s\n", 618 (((0x1 << 1) & cmd) == 0) ? "off" : "on");
602 ((PCI_STATUS_DEVSEL_MASK&cmd)==0x000)?"Fast": 619 printk(KERN_DEBUG "pmc551: I/O Access %s\n",
603 ((PCI_STATUS_DEVSEL_MASK&cmd)==0x200)?"Medium": 620 (((0x1 << 0) & cmd) == 0) ? "off" : "on");
604 ((PCI_STATUS_DEVSEL_MASK&cmd)==0x400)?"Slow":"Invalid" ); 621
605 622 pci_read_config_word(dev, PCI_STATUS, &cmd);
606 printk( KERN_DEBUG "pmc551: %sFast Back-to-Back\n", 623 printk(KERN_DEBUG "pmc551: Devsel %s\n",
607 ((PCI_COMMAND_FAST_BACK&cmd) == 0)?"Not ":"" ); 624 ((PCI_STATUS_DEVSEL_MASK & cmd) == 0x000) ? "Fast" :
608 625 ((PCI_STATUS_DEVSEL_MASK & cmd) == 0x200) ? "Medium" :
609 pci_read_config_byte(dev, PMC551_SYS_CTRL_REG, &bcmd ); 626 ((PCI_STATUS_DEVSEL_MASK & cmd) == 0x400) ? "Slow" : "Invalid");
610 printk( KERN_DEBUG "pmc551: EEPROM is under %s control\n" 627
611 "pmc551: System Control Register is %slocked to PCI access\n" 628 printk(KERN_DEBUG "pmc551: %sFast Back-to-Back\n",
612 "pmc551: System Control Register is %slocked to EEPROM access\n", 629 ((PCI_COMMAND_FAST_BACK & cmd) == 0) ? "Not " : "");
613 (bcmd&0x1)?"software":"hardware", 630
614 (bcmd&0x20)?"":"un", (bcmd&0x40)?"":"un"); 631 pci_read_config_byte(dev, PMC551_SYS_CTRL_REG, &bcmd);
632 printk(KERN_DEBUG "pmc551: EEPROM is under %s control\n"
633 "pmc551: System Control Register is %slocked to PCI access\n"
634 "pmc551: System Control Register is %slocked to EEPROM access\n",
635 (bcmd & 0x1) ? "software" : "hardware",
636 (bcmd & 0x20) ? "" : "un", (bcmd & 0x40) ? "" : "un");
615#endif 637#endif
616 return size; 638 return size;
617} 639}
618 640
619/* 641/*
620 * Kernel version specific module stuffages 642 * Kernel version specific module stuffages
621 */ 643 */
622 644
623
624MODULE_LICENSE("GPL"); 645MODULE_LICENSE("GPL");
625MODULE_AUTHOR("Mark Ferrell <mferrell@mvista.com>"); 646MODULE_AUTHOR("Mark Ferrell <mferrell@mvista.com>");
626MODULE_DESCRIPTION(PMC551_VERSION); 647MODULE_DESCRIPTION(PMC551_VERSION);
@@ -628,11 +649,11 @@ MODULE_DESCRIPTION(PMC551_VERSION);
628/* 649/*
629 * Stuff these outside the ifdef so as to not bust compiled in driver support 650 * Stuff these outside the ifdef so as to not bust compiled in driver support
630 */ 651 */
631static int msize=0; 652static int msize = 0;
632#if defined(CONFIG_MTD_PMC551_APERTURE_SIZE) 653#if defined(CONFIG_MTD_PMC551_APERTURE_SIZE)
633static int asize=CONFIG_MTD_PMC551_APERTURE_SIZE 654static int asize = CONFIG_MTD_PMC551_APERTURE_SIZE
634#else 655#else
635static int asize=0; 656static int asize = 0;
636#endif 657#endif
637 658
638module_param(msize, int, 0); 659module_param(msize, int, 0);
@@ -645,164 +666,174 @@ MODULE_PARM_DESC(asize, "aperture size, must be <= memsize [1-1024]");
645 */ 666 */
646static int __init init_pmc551(void) 667static int __init init_pmc551(void)
647{ 668{
648 struct pci_dev *PCI_Device = NULL; 669 struct pci_dev *PCI_Device = NULL;
649 struct mypriv *priv; 670 struct mypriv *priv;
650 int count, found=0; 671 int count, found = 0;
651 struct mtd_info *mtd; 672 struct mtd_info *mtd;
652 u32 length = 0; 673 u32 length = 0;
653 674
654 if(msize) { 675 if (msize) {
655 msize = (1 << (ffs(msize) - 1))<<20; 676 msize = (1 << (ffs(msize) - 1)) << 20;
656 if (msize > (1<<30)) { 677 if (msize > (1 << 30)) {
657 printk(KERN_NOTICE "pmc551: Invalid memory size [%d]\n", msize); 678 printk(KERN_NOTICE "pmc551: Invalid memory size [%d]\n",
679 msize);
658 return -EINVAL; 680 return -EINVAL;
659 } 681 }
660 } 682 }
661 683
662 if(asize) { 684 if (asize) {
663 asize = (1 << (ffs(asize) - 1))<<20; 685 asize = (1 << (ffs(asize) - 1)) << 20;
664 if (asize > (1<<30) ) { 686 if (asize > (1 << 30)) {
665 printk(KERN_NOTICE "pmc551: Invalid aperture size [%d]\n", asize); 687 printk(KERN_NOTICE "pmc551: Invalid aperture size "
688 "[%d]\n", asize);
666 return -EINVAL; 689 return -EINVAL;
667 } 690 }
668 } 691 }
669 692
670 printk(KERN_INFO PMC551_VERSION); 693 printk(KERN_INFO PMC551_VERSION);
671 694
672 /* 695 /*
673 * PCU-bus chipset probe. 696 * PCU-bus chipset probe.
674 */ 697 */
675 for( count = 0; count < MAX_MTD_DEVICES; count++ ) { 698 for (count = 0; count < MAX_MTD_DEVICES; count++) {
676 699
677 if ((PCI_Device = pci_find_device(PCI_VENDOR_ID_V3_SEMI, 700 if ((PCI_Device = pci_get_device(PCI_VENDOR_ID_V3_SEMI,
678 PCI_DEVICE_ID_V3_SEMI_V370PDC, 701 PCI_DEVICE_ID_V3_SEMI_V370PDC,
679 PCI_Device ) ) == NULL) { 702 PCI_Device)) == NULL) {
680 break; 703 break;
681 } 704 }
682 705
683 printk(KERN_NOTICE "pmc551: Found PCI V370PDC at 0x%llx\n", 706 printk(KERN_NOTICE "pmc551: Found PCI V370PDC at 0x%llx\n",
684 (unsigned long long)PCI_Device->resource[0].start); 707 (unsigned long long)pci_resource_start(PCI_Device, 0));
685 708
686 /* 709 /*
687 * The PMC551 device acts VERY weird if you don't init it 710 * The PMC551 device acts VERY weird if you don't init it
688 * first. i.e. it will not correctly report devsel. If for 711 * first. i.e. it will not correctly report devsel. If for
689 * some reason the sdram is in a wrote-protected state the 712 * some reason the sdram is in a wrote-protected state the
690 * device will DEVSEL when it is written to causing problems 713 * device will DEVSEL when it is written to causing problems
691 * with the oldproc.c driver in 714 * with the oldproc.c driver in
692 * some kernels (2.2.*) 715 * some kernels (2.2.*)
693 */ 716 */
694 if((length = fixup_pmc551(PCI_Device)) <= 0) { 717 if ((length = fixup_pmc551(PCI_Device)) <= 0) {
695 printk(KERN_NOTICE "pmc551: Cannot init SDRAM\n"); 718 printk(KERN_NOTICE "pmc551: Cannot init SDRAM\n");
696 break; 719 break;
697 } 720 }
698 721
699 /* 722 /*
700 * This is needed until the driver is capable of reading the 723 * This is needed until the driver is capable of reading the
701 * onboard I2C SROM to discover the "real" memory size. 724 * onboard I2C SROM to discover the "real" memory size.
702 */ 725 */
703 if(msize) { 726 if (msize) {
704 length = msize; 727 length = msize;
705 printk(KERN_NOTICE "pmc551: Using specified memory size 0x%x\n", length); 728 printk(KERN_NOTICE "pmc551: Using specified memory "
729 "size 0x%x\n", length);
706 } else { 730 } else {
707 msize = length; 731 msize = length;
708 } 732 }
709 733
710 mtd = kmalloc(sizeof(struct mtd_info), GFP_KERNEL); 734 mtd = kzalloc(sizeof(struct mtd_info), GFP_KERNEL);
711 if (!mtd) { 735 if (!mtd) {
712 printk(KERN_NOTICE "pmc551: Cannot allocate new MTD device.\n"); 736 printk(KERN_NOTICE "pmc551: Cannot allocate new MTD "
713 break; 737 "device.\n");
714 } 738 break;
715 739 }
716 memset(mtd, 0, sizeof(struct mtd_info)); 740
717 741 priv = kzalloc(sizeof(struct mypriv), GFP_KERNEL);
718 priv = kmalloc (sizeof(struct mypriv), GFP_KERNEL); 742 if (!priv) {
719 if (!priv) { 743 printk(KERN_NOTICE "pmc551: Cannot allocate new MTD "
720 printk(KERN_NOTICE "pmc551: Cannot allocate new MTD device.\n"); 744 "device.\n");
721 kfree(mtd); 745 kfree(mtd);
722 break; 746 break;
723 } 747 }
724 memset(priv, 0, sizeof(*priv)); 748 mtd->priv = priv;
725 mtd->priv = priv; 749 priv->dev = PCI_Device;
726 priv->dev = PCI_Device; 750
727 751 if (asize > length) {
728 if(asize > length) { 752 printk(KERN_NOTICE "pmc551: reducing aperture size to "
729 printk(KERN_NOTICE "pmc551: reducing aperture size to fit %dM\n",length>>20); 753 "fit %dM\n", length >> 20);
730 priv->asize = asize = length; 754 priv->asize = asize = length;
731 } else if (asize == 0 || asize == length) { 755 } else if (asize == 0 || asize == length) {
732 printk(KERN_NOTICE "pmc551: Using existing aperture size %dM\n", length>>20); 756 printk(KERN_NOTICE "pmc551: Using existing aperture "
757 "size %dM\n", length >> 20);
733 priv->asize = asize = length; 758 priv->asize = asize = length;
734 } else { 759 } else {
735 printk(KERN_NOTICE "pmc551: Using specified aperture size %dM\n", asize>>20); 760 printk(KERN_NOTICE "pmc551: Using specified aperture "
761 "size %dM\n", asize >> 20);
736 priv->asize = asize; 762 priv->asize = asize;
737 } 763 }
738 priv->start = ioremap(((PCI_Device->resource[0].start) 764 priv->start = pci_iomap(PCI_Device, 0, priv->asize);
739 & PCI_BASE_ADDRESS_MEM_MASK),
740 priv->asize);
741 765
742 if (!priv->start) { 766 if (!priv->start) {
743 printk(KERN_NOTICE "pmc551: Unable to map IO space\n"); 767 printk(KERN_NOTICE "pmc551: Unable to map IO space\n");
744 kfree(mtd->priv); 768 kfree(mtd->priv);
745 kfree(mtd); 769 kfree(mtd);
746 break; 770 break;
747 } 771 }
748
749#ifdef CONFIG_MTD_PMC551_DEBUG 772#ifdef CONFIG_MTD_PMC551_DEBUG
750 printk( KERN_DEBUG "pmc551: setting aperture to %d\n", 773 printk(KERN_DEBUG "pmc551: setting aperture to %d\n",
751 ffs(priv->asize>>20)-1); 774 ffs(priv->asize >> 20) - 1);
752#endif 775#endif
753 776
754 priv->base_map0 = ( PMC551_PCI_MEM_MAP_REG_EN 777 priv->base_map0 = (PMC551_PCI_MEM_MAP_REG_EN
755 | PMC551_PCI_MEM_MAP_ENABLE 778 | PMC551_PCI_MEM_MAP_ENABLE
756 | (ffs(priv->asize>>20)-1)<<4 ); 779 | (ffs(priv->asize >> 20) - 1) << 4);
757 priv->curr_map0 = priv->base_map0; 780 priv->curr_map0 = priv->base_map0;
758 pci_write_config_dword ( priv->dev, PMC551_PCI_MEM_MAP0, 781 pci_write_config_dword(priv->dev, PMC551_PCI_MEM_MAP0,
759 priv->curr_map0 ); 782 priv->curr_map0);
760 783
761#ifdef CONFIG_MTD_PMC551_DEBUG 784#ifdef CONFIG_MTD_PMC551_DEBUG
762 printk( KERN_DEBUG "pmc551: aperture set to %d\n", 785 printk(KERN_DEBUG "pmc551: aperture set to %d\n",
763 (priv->base_map0 & 0xF0)>>4 ); 786 (priv->base_map0 & 0xF0) >> 4);
764#endif 787#endif
765 788
766 mtd->size = msize; 789 mtd->size = msize;
767 mtd->flags = MTD_CAP_RAM; 790 mtd->flags = MTD_CAP_RAM;
768 mtd->erase = pmc551_erase; 791 mtd->erase = pmc551_erase;
769 mtd->read = pmc551_read; 792 mtd->read = pmc551_read;
770 mtd->write = pmc551_write; 793 mtd->write = pmc551_write;
771 mtd->point = pmc551_point; 794 mtd->point = pmc551_point;
772 mtd->unpoint = pmc551_unpoint; 795 mtd->unpoint = pmc551_unpoint;
773 mtd->type = MTD_RAM; 796 mtd->type = MTD_RAM;
774 mtd->name = "PMC551 RAM board"; 797 mtd->name = "PMC551 RAM board";
775 mtd->erasesize = 0x10000; 798 mtd->erasesize = 0x10000;
776 mtd->writesize = 1; 799 mtd->writesize = 1;
777 mtd->owner = THIS_MODULE; 800 mtd->owner = THIS_MODULE;
778 801
779 if (add_mtd_device(mtd)) { 802 if (add_mtd_device(mtd)) {
780 printk(KERN_NOTICE "pmc551: Failed to register new device\n"); 803 printk(KERN_NOTICE "pmc551: Failed to register new "
781 iounmap(priv->start); 804 "device\n");
782 kfree(mtd->priv); 805 pci_iounmap(PCI_Device, priv->start);
783 kfree(mtd); 806 kfree(mtd->priv);
784 break; 807 kfree(mtd);
785 } 808 break;
786 printk(KERN_NOTICE "Registered pmc551 memory device.\n"); 809 }
787 printk(KERN_NOTICE "Mapped %dM of memory from 0x%p to 0x%p\n", 810
788 priv->asize>>20, 811 /* Keep a reference as the add_mtd_device worked */
789 priv->start, 812 pci_dev_get(PCI_Device);
790 priv->start + priv->asize); 813
791 printk(KERN_NOTICE "Total memory is %d%c\n", 814 printk(KERN_NOTICE "Registered pmc551 memory device.\n");
792 (length<1024)?length: 815 printk(KERN_NOTICE "Mapped %dM of memory from 0x%p to 0x%p\n",
793 (length<1048576)?length>>10:length>>20, 816 priv->asize >> 20,
794 (length<1024)?'B':(length<1048576)?'K':'M'); 817 priv->start, priv->start + priv->asize);
818 printk(KERN_NOTICE "Total memory is %d%c\n",
819 (length < 1024) ? length :
820 (length < 1048576) ? length >> 10 : length >> 20,
821 (length < 1024) ? 'B' : (length < 1048576) ? 'K' : 'M');
795 priv->nextpmc551 = pmc551list; 822 priv->nextpmc551 = pmc551list;
796 pmc551list = mtd; 823 pmc551list = mtd;
797 found++; 824 found++;
798 } 825 }
826
827 /* Exited early, reference left over */
828 if (PCI_Device)
829 pci_dev_put(PCI_Device);
799 830
800 if( !pmc551list ) { 831 if (!pmc551list) {
801 printk(KERN_NOTICE "pmc551: not detected\n"); 832 printk(KERN_NOTICE "pmc551: not detected\n");
802 return -ENODEV; 833 return -ENODEV;
803 } else { 834 } else {
804 printk(KERN_NOTICE "pmc551: %d pmc551 devices loaded\n", found); 835 printk(KERN_NOTICE "pmc551: %d pmc551 devices loaded\n", found);
805 return 0; 836 return 0;
806 } 837 }
807} 838}
808 839
@@ -811,23 +842,24 @@ static int __init init_pmc551(void)
811 */ 842 */
812static void __exit cleanup_pmc551(void) 843static void __exit cleanup_pmc551(void)
813{ 844{
814 int found=0; 845 int found = 0;
815 struct mtd_info *mtd; 846 struct mtd_info *mtd;
816 struct mypriv *priv; 847 struct mypriv *priv;
817 848
818 while((mtd=pmc551list)) { 849 while ((mtd = pmc551list)) {
819 priv = mtd->priv; 850 priv = mtd->priv;
820 pmc551list = priv->nextpmc551; 851 pmc551list = priv->nextpmc551;
821 852
822 if(priv->start) { 853 if (priv->start) {
823 printk (KERN_DEBUG "pmc551: unmapping %dM starting at 0x%p\n", 854 printk(KERN_DEBUG "pmc551: unmapping %dM starting at "
824 priv->asize>>20, priv->start); 855 "0x%p\n", priv->asize >> 20, priv->start);
825 iounmap (priv->start); 856 pci_iounmap(priv->dev, priv->start);
826 } 857 }
858 pci_dev_put(priv->dev);
827 859
828 kfree (mtd->priv); 860 kfree(mtd->priv);
829 del_mtd_device (mtd); 861 del_mtd_device(mtd);
830 kfree (mtd); 862 kfree(mtd);
831 found++; 863 found++;
832 } 864 }
833 865
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 64d1b6a6c920..24747bdc3e19 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -447,14 +447,6 @@ config MTD_DC21285
447 21285 bridge used with Intel's StrongARM processors. More info at 447 21285 bridge used with Intel's StrongARM processors. More info at
448 <http://www.intel.com/design/bridge/docs/21285_documentation.htm>. 448 <http://www.intel.com/design/bridge/docs/21285_documentation.htm>.
449 449
450config MTD_IQ80310
451 tristate "CFI Flash device mapped on the XScale IQ80310 board"
452 depends on MTD_CFI && ARCH_IQ80310
453 help
454 This enables access routines for the flash chips on the Intel XScale
455 IQ80310 evaluation board. If you have one of these boards and would
456 like to use the flash chips on it, say 'Y'.
457
458config MTD_IXP4XX 450config MTD_IXP4XX
459 tristate "CFI Flash device mapped on Intel IXP4xx based systems" 451 tristate "CFI Flash device mapped on Intel IXP4xx based systems"
460 depends on MTD_CFI && MTD_COMPLEX_MAPPINGS && ARCH_IXP4XX 452 depends on MTD_CFI && MTD_COMPLEX_MAPPINGS && ARCH_IXP4XX
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index ab71f172eb77..191c1928bbec 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -15,7 +15,6 @@ obj-$(CONFIG_MTD_CFI_FLAGADM) += cfi_flagadm.o
15obj-$(CONFIG_MTD_CSTM_MIPS_IXX) += cstm_mips_ixx.o 15obj-$(CONFIG_MTD_CSTM_MIPS_IXX) += cstm_mips_ixx.o
16obj-$(CONFIG_MTD_DC21285) += dc21285.o 16obj-$(CONFIG_MTD_DC21285) += dc21285.o
17obj-$(CONFIG_MTD_DILNETPC) += dilnetpc.o 17obj-$(CONFIG_MTD_DILNETPC) += dilnetpc.o
18obj-$(CONFIG_MTD_IQ80310) += iq80310.o
19obj-$(CONFIG_MTD_L440GX) += l440gx.o 18obj-$(CONFIG_MTD_L440GX) += l440gx.o
20obj-$(CONFIG_MTD_AMD76XROM) += amd76xrom.o 19obj-$(CONFIG_MTD_AMD76XROM) += amd76xrom.o
21obj-$(CONFIG_MTD_ICHXROM) += ichxrom.o 20obj-$(CONFIG_MTD_ICHXROM) += ichxrom.o
diff --git a/drivers/mtd/maps/amd76xrom.c b/drivers/mtd/maps/amd76xrom.c
index 447955be18af..797caffb20b1 100644
--- a/drivers/mtd/maps/amd76xrom.c
+++ b/drivers/mtd/maps/amd76xrom.c
@@ -57,6 +57,7 @@ static void amd76xrom_cleanup(struct amd76xrom_window *window)
57 /* Disable writes through the rom window */ 57 /* Disable writes through the rom window */
58 pci_read_config_byte(window->pdev, 0x40, &byte); 58 pci_read_config_byte(window->pdev, 0x40, &byte);
59 pci_write_config_byte(window->pdev, 0x40, byte & ~1); 59 pci_write_config_byte(window->pdev, 0x40, byte & ~1);
60 pci_dev_put(window->pdev);
60 } 61 }
61 62
62 /* Free all of the mtd devices */ 63 /* Free all of the mtd devices */
@@ -91,7 +92,7 @@ static int __devinit amd76xrom_init_one (struct pci_dev *pdev,
91 struct amd76xrom_map_info *map = NULL; 92 struct amd76xrom_map_info *map = NULL;
92 unsigned long map_top; 93 unsigned long map_top;
93 94
94 /* Remember the pci dev I find the window in */ 95 /* Remember the pci dev I find the window in - already have a ref */
95 window->pdev = pdev; 96 window->pdev = pdev;
96 97
97 /* Assume the rom window is properly setup, and find it's size */ 98 /* Assume the rom window is properly setup, and find it's size */
@@ -302,7 +303,7 @@ static int __init init_amd76xrom(void)
302 struct pci_device_id *id; 303 struct pci_device_id *id;
303 pdev = NULL; 304 pdev = NULL;
304 for(id = amd76xrom_pci_tbl; id->vendor; id++) { 305 for(id = amd76xrom_pci_tbl; id->vendor; id++) {
305 pdev = pci_find_device(id->vendor, id->device, NULL); 306 pdev = pci_get_device(id->vendor, id->device, NULL);
306 if (pdev) { 307 if (pdev) {
307 break; 308 break;
308 } 309 }
diff --git a/drivers/mtd/maps/arctic-mtd.c b/drivers/mtd/maps/arctic-mtd.c
index d95ae582fbe9..642d96bc8919 100644
--- a/drivers/mtd/maps/arctic-mtd.c
+++ b/drivers/mtd/maps/arctic-mtd.c
@@ -96,6 +96,8 @@ static struct mtd_partition arctic_partitions[PARTITIONS] = {
96static int __init 96static int __init
97init_arctic_mtd(void) 97init_arctic_mtd(void)
98{ 98{
99 int err = 0;
100
99 printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR); 101 printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR);
100 102
101 arctic_mtd_map.virt = ioremap(PADDR, SIZE); 103 arctic_mtd_map.virt = ioremap(PADDR, SIZE);
@@ -109,12 +111,20 @@ init_arctic_mtd(void)
109 printk("%s: probing %d-bit flash bus\n", NAME, BUSWIDTH * 8); 111 printk("%s: probing %d-bit flash bus\n", NAME, BUSWIDTH * 8);
110 arctic_mtd = do_map_probe("cfi_probe", &arctic_mtd_map); 112 arctic_mtd = do_map_probe("cfi_probe", &arctic_mtd_map);
111 113
112 if (!arctic_mtd) 114 if (!arctic_mtd) {
115 iounmap((void *) arctic_mtd_map.virt);
113 return -ENXIO; 116 return -ENXIO;
117 }
114 118
115 arctic_mtd->owner = THIS_MODULE; 119 arctic_mtd->owner = THIS_MODULE;
116 120
117 return add_mtd_partitions(arctic_mtd, arctic_partitions, PARTITIONS); 121 err = add_mtd_partitions(arctic_mtd, arctic_partitions, PARTITIONS);
122 if (err) {
123 printk("%s: add_mtd_partitions failed\n", NAME);
124 iounmap((void *) arctic_mtd_map.virt);
125 }
126
127 return err;
118} 128}
119 129
120static void __exit 130static void __exit
diff --git a/drivers/mtd/maps/beech-mtd.c b/drivers/mtd/maps/beech-mtd.c
index 5df7361d1407..a64b1a5ab316 100644
--- a/drivers/mtd/maps/beech-mtd.c
+++ b/drivers/mtd/maps/beech-mtd.c
@@ -72,6 +72,8 @@ static struct mtd_partition beech_partitions[2] = {
72static int __init 72static int __init
73init_beech_mtd(void) 73init_beech_mtd(void)
74{ 74{
75 int err = 0;
76
75 printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR); 77 printk("%s: 0x%08x at 0x%08x\n", NAME, SIZE, PADDR);
76 78
77 beech_mtd_map.virt = ioremap(PADDR, SIZE); 79 beech_mtd_map.virt = ioremap(PADDR, SIZE);
@@ -86,12 +88,20 @@ init_beech_mtd(void)
86 printk("%s: probing %d-bit flash bus\n", NAME, BUSWIDTH * 8); 88 printk("%s: probing %d-bit flash bus\n", NAME, BUSWIDTH * 8);
87 beech_mtd = do_map_probe("cfi_probe", &beech_mtd_map); 89 beech_mtd = do_map_probe("cfi_probe", &beech_mtd_map);
88 90
89 if (!beech_mtd) 91 if (!beech_mtd) {
92 iounmap((void *) beech_mtd_map.virt);
90 return -ENXIO; 93 return -ENXIO;
94 }
91 95
92 beech_mtd->owner = THIS_MODULE; 96 beech_mtd->owner = THIS_MODULE;
93 97
94 return add_mtd_partitions(beech_mtd, beech_partitions, 2); 98 err = add_mtd_partitions(beech_mtd, beech_partitions, 2);
99 if (err) {
100 printk("%s: add_mtd_partitions failed\n", NAME);
101 iounmap((void *) beech_mtd_map.virt);
102 }
103
104 return err;
95} 105}
96 106
97static void __exit 107static void __exit
diff --git a/drivers/mtd/maps/cstm_mips_ixx.c b/drivers/mtd/maps/cstm_mips_ixx.c
index aa56defb94c8..d6bef100d69a 100644
--- a/drivers/mtd/maps/cstm_mips_ixx.c
+++ b/drivers/mtd/maps/cstm_mips_ixx.c
@@ -171,7 +171,14 @@ int __init init_cstm_mips_ixx(void)
171 cstm_mips_ixx_map[i].phys = cstm_mips_ixx_board_desc[i].window_addr; 171 cstm_mips_ixx_map[i].phys = cstm_mips_ixx_board_desc[i].window_addr;
172 cstm_mips_ixx_map[i].virt = ioremap(cstm_mips_ixx_board_desc[i].window_addr, cstm_mips_ixx_board_desc[i].window_size); 172 cstm_mips_ixx_map[i].virt = ioremap(cstm_mips_ixx_board_desc[i].window_addr, cstm_mips_ixx_board_desc[i].window_size);
173 if (!cstm_mips_ixx_map[i].virt) { 173 if (!cstm_mips_ixx_map[i].virt) {
174 int j = 0;
174 printk(KERN_WARNING "Failed to ioremap\n"); 175 printk(KERN_WARNING "Failed to ioremap\n");
176 for (j = 0; j < i; j++) {
177 if (cstm_mips_ixx_map[j].virt) {
178 iounmap((void *)cstm_mips_ixx_map[j].virt);
179 cstm_mips_ixx_map[j].virt = 0;
180 }
181 }
175 return -EIO; 182 return -EIO;
176 } 183 }
177 cstm_mips_ixx_map[i].name = cstm_mips_ixx_board_desc[i].name; 184 cstm_mips_ixx_map[i].name = cstm_mips_ixx_board_desc[i].name;
@@ -204,8 +211,15 @@ int __init init_cstm_mips_ixx(void)
204 cstm_mips_ixx_map[i].map_priv_2 = (unsigned long)mymtd; 211 cstm_mips_ixx_map[i].map_priv_2 = (unsigned long)mymtd;
205 add_mtd_partitions(mymtd, parts, cstm_mips_ixx_board_desc[i].num_partitions); 212 add_mtd_partitions(mymtd, parts, cstm_mips_ixx_board_desc[i].num_partitions);
206 } 213 }
207 else 214 else {
208 return -ENXIO; 215 for (i = 0; i < PHYSMAP_NUMBER; i++) {
216 if (cstm_mips_ixx_map[i].virt) {
217 iounmap((void *)cstm_mips_ixx_map[i].virt);
218 cstm_mips_ixx_map[i].virt = 0;
219 }
220 }
221 return -ENXIO;
222 }
209 } 223 }
210 return 0; 224 return 0;
211} 225}
diff --git a/drivers/mtd/maps/ebony.c b/drivers/mtd/maps/ebony.c
index 641e1dd8479e..1488bb92f26f 100644
--- a/drivers/mtd/maps/ebony.c
+++ b/drivers/mtd/maps/ebony.c
@@ -108,6 +108,7 @@ int __init init_ebony(void)
108 ARRAY_SIZE(ebony_small_partitions)); 108 ARRAY_SIZE(ebony_small_partitions));
109 } else { 109 } else {
110 printk("map probe failed for flash\n"); 110 printk("map probe failed for flash\n");
111 iounmap(ebony_small_map.virt);
111 return -ENXIO; 112 return -ENXIO;
112 } 113 }
113 114
@@ -117,6 +118,7 @@ int __init init_ebony(void)
117 118
118 if (!ebony_large_map.virt) { 119 if (!ebony_large_map.virt) {
119 printk("Failed to ioremap flash\n"); 120 printk("Failed to ioremap flash\n");
121 iounmap(ebony_small_map.virt);
120 return -EIO; 122 return -EIO;
121 } 123 }
122 124
@@ -129,6 +131,8 @@ int __init init_ebony(void)
129 ARRAY_SIZE(ebony_large_partitions)); 131 ARRAY_SIZE(ebony_large_partitions));
130 } else { 132 } else {
131 printk("map probe failed for flash\n"); 133 printk("map probe failed for flash\n");
134 iounmap(ebony_small_map.virt);
135 iounmap(ebony_large_map.virt);
132 return -ENXIO; 136 return -ENXIO;
133 } 137 }
134 138
diff --git a/drivers/mtd/maps/fortunet.c b/drivers/mtd/maps/fortunet.c
index c6bf4e1219ef..7c50c271651c 100644
--- a/drivers/mtd/maps/fortunet.c
+++ b/drivers/mtd/maps/fortunet.c
@@ -218,8 +218,11 @@ int __init init_fortunet(void)
218 map_regions[ix].map_info.size); 218 map_regions[ix].map_info.size);
219 if(!map_regions[ix].map_info.virt) 219 if(!map_regions[ix].map_info.virt)
220 { 220 {
221 int j = 0;
221 printk(MTD_FORTUNET_PK "%s flash failed to ioremap!\n", 222 printk(MTD_FORTUNET_PK "%s flash failed to ioremap!\n",
222 map_regions[ix].map_info.name); 223 map_regions[ix].map_info.name);
224 for (j = 0 ; j < ix; j++)
225 iounmap(map_regions[j].map_info.virt);
223 return -ENXIO; 226 return -ENXIO;
224 } 227 }
225 simple_map_init(&map_regions[ix].map_info); 228 simple_map_init(&map_regions[ix].map_info);
diff --git a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c
index db4b570d874a..2bb3e63606e5 100644
--- a/drivers/mtd/maps/ichxrom.c
+++ b/drivers/mtd/maps/ichxrom.c
@@ -61,6 +61,7 @@ static void ichxrom_cleanup(struct ichxrom_window *window)
61 /* Disable writes through the rom window */ 61 /* Disable writes through the rom window */
62 pci_read_config_word(window->pdev, BIOS_CNTL, &word); 62 pci_read_config_word(window->pdev, BIOS_CNTL, &word);
63 pci_write_config_word(window->pdev, BIOS_CNTL, word & ~1); 63 pci_write_config_word(window->pdev, BIOS_CNTL, word & ~1);
64 pci_dev_put(window->pdev);
64 65
65 /* Free all of the mtd devices */ 66 /* Free all of the mtd devices */
66 list_for_each_entry_safe(map, scratch, &window->maps, list) { 67 list_for_each_entry_safe(map, scratch, &window->maps, list) {
@@ -355,7 +356,7 @@ static int __init init_ichxrom(void)
355 356
356 pdev = NULL; 357 pdev = NULL;
357 for (id = ichxrom_pci_tbl; id->vendor; id++) { 358 for (id = ichxrom_pci_tbl; id->vendor; id++) {
358 pdev = pci_find_device(id->vendor, id->device, NULL); 359 pdev = pci_get_device(id->vendor, id->device, NULL);
359 if (pdev) { 360 if (pdev) {
360 break; 361 break;
361 } 362 }
diff --git a/drivers/mtd/maps/iq80310.c b/drivers/mtd/maps/iq80310.c
deleted file mode 100644
index 62d9e87d84e2..000000000000
--- a/drivers/mtd/maps/iq80310.c
+++ /dev/null
@@ -1,118 +0,0 @@
1/*
2 * $Id: iq80310.c,v 1.21 2005/11/07 11:14:27 gleixner Exp $
3 *
4 * Mapping for the Intel XScale IQ80310 evaluation board
5 *
6 * Author: Nicolas Pitre
7 * Copyright: (C) 2001 MontaVista Software Inc.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/module.h>
15#include <linux/types.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/slab.h>
19#include <asm/io.h>
20#include <linux/mtd/mtd.h>
21#include <linux/mtd/map.h>
22#include <linux/mtd/partitions.h>
23
24
25#define WINDOW_ADDR 0
26#define WINDOW_SIZE 8*1024*1024
27#define BUSWIDTH 1
28
29static struct mtd_info *mymtd;
30
31static struct map_info iq80310_map = {
32 .name = "IQ80310 flash",
33 .size = WINDOW_SIZE,
34 .bankwidth = BUSWIDTH,
35 .phys = WINDOW_ADDR
36};
37
38static struct mtd_partition iq80310_partitions[4] = {
39 {
40 .name = "Firmware",
41 .size = 0x00080000,
42 .offset = 0,
43 .mask_flags = MTD_WRITEABLE /* force read-only */
44 },{
45 .name = "Kernel",
46 .size = 0x000a0000,
47 .offset = 0x00080000,
48 },{
49 .name = "Filesystem",
50 .size = 0x00600000,
51 .offset = 0x00120000
52 },{
53 .name = "RedBoot",
54 .size = 0x000e0000,
55 .offset = 0x00720000,
56 .mask_flags = MTD_WRITEABLE
57 }
58};
59
60static struct mtd_info *mymtd;
61static struct mtd_partition *parsed_parts;
62static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
63
64static int __init init_iq80310(void)
65{
66 struct mtd_partition *parts;
67 int nb_parts = 0;
68 int parsed_nr_parts = 0;
69 int ret;
70
71 iq80310_map.virt = ioremap(WINDOW_ADDR, WINDOW_SIZE);
72 if (!iq80310_map.virt) {
73 printk("Failed to ioremap\n");
74 return -EIO;
75 }
76 simple_map_init(&iq80310_map);
77
78 mymtd = do_map_probe("cfi_probe", &iq80310_map);
79 if (!mymtd) {
80 iounmap((void *)iq80310_map.virt);
81 return -ENXIO;
82 }
83 mymtd->owner = THIS_MODULE;
84
85 ret = parse_mtd_partitions(mymtd, probes, &parsed_parts, 0);
86
87 if (ret > 0)
88 parsed_nr_parts = ret;
89
90 if (parsed_nr_parts > 0) {
91 parts = parsed_parts;
92 nb_parts = parsed_nr_parts;
93 } else {
94 parts = iq80310_partitions;
95 nb_parts = ARRAY_SIZE(iq80310_partitions);
96 }
97 add_mtd_partitions(mymtd, parts, nb_parts);
98 return 0;
99}
100
101static void __exit cleanup_iq80310(void)
102{
103 if (mymtd) {
104 del_mtd_partitions(mymtd);
105 map_destroy(mymtd);
106 kfree(parsed_parts);
107 }
108 if (iq80310_map.virt)
109 iounmap((void *)iq80310_map.virt);
110}
111
112module_init(init_iq80310);
113module_exit(cleanup_iq80310);
114
115
116MODULE_LICENSE("GPL");
117MODULE_AUTHOR("Nicolas Pitre <nico@cam.org>");
118MODULE_DESCRIPTION("MTD map driver for Intel XScale IQ80310 evaluation board");
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
index 986c58628390..7a828e3e6446 100644
--- a/drivers/mtd/maps/ixp4xx.c
+++ b/drivers/mtd/maps/ixp4xx.c
@@ -253,7 +253,7 @@ static int ixp4xx_flash_probe(struct platform_device *dev)
253 /* Use the fast version */ 253 /* Use the fast version */
254 info->map.write = ixp4xx_write16, 254 info->map.write = ixp4xx_write16,
255 255
256 err = parse_mtd_partitions(info->mtd, probes, &info->partitions, 0); 256 err = parse_mtd_partitions(info->mtd, probes, &info->partitions, dev->resource->start);
257 if (err > 0) { 257 if (err > 0) {
258 err = add_mtd_partitions(info->mtd, info->partitions, err); 258 err = add_mtd_partitions(info->mtd, info->partitions, err);
259 if(err) 259 if(err)
diff --git a/drivers/mtd/maps/l440gx.c b/drivers/mtd/maps/l440gx.c
index 6b784ef5ee70..67620adf4811 100644
--- a/drivers/mtd/maps/l440gx.c
+++ b/drivers/mtd/maps/l440gx.c
@@ -61,14 +61,17 @@ static int __init init_l440gx(void)
61 struct resource *pm_iobase; 61 struct resource *pm_iobase;
62 __u16 word; 62 __u16 word;
63 63
64 dev = pci_find_device(PCI_VENDOR_ID_INTEL, 64 dev = pci_get_device(PCI_VENDOR_ID_INTEL,
65 PCI_DEVICE_ID_INTEL_82371AB_0, NULL); 65 PCI_DEVICE_ID_INTEL_82371AB_0, NULL);
66 66
67 pm_dev = pci_find_device(PCI_VENDOR_ID_INTEL, 67 pm_dev = pci_get_device(PCI_VENDOR_ID_INTEL,
68 PCI_DEVICE_ID_INTEL_82371AB_3, NULL); 68 PCI_DEVICE_ID_INTEL_82371AB_3, NULL);
69 69
70 pci_dev_put(dev);
71
70 if (!dev || !pm_dev) { 72 if (!dev || !pm_dev) {
71 printk(KERN_NOTICE "L440GX flash mapping: failed to find PIIX4 ISA bridge, cannot continue\n"); 73 printk(KERN_NOTICE "L440GX flash mapping: failed to find PIIX4 ISA bridge, cannot continue\n");
74 pci_dev_put(pm_dev);
72 return -ENODEV; 75 return -ENODEV;
73 } 76 }
74 77
@@ -76,6 +79,7 @@ static int __init init_l440gx(void)
76 79
77 if (!l440gx_map.virt) { 80 if (!l440gx_map.virt) {
78 printk(KERN_WARNING "Failed to ioremap L440GX flash region\n"); 81 printk(KERN_WARNING "Failed to ioremap L440GX flash region\n");
82 pci_dev_put(pm_dev);
79 return -ENOMEM; 83 return -ENOMEM;
80 } 84 }
81 simple_map_init(&l440gx_map); 85 simple_map_init(&l440gx_map);
@@ -99,8 +103,12 @@ static int __init init_l440gx(void)
99 pm_iobase->start += iobase & ~1; 103 pm_iobase->start += iobase & ~1;
100 pm_iobase->end += iobase & ~1; 104 pm_iobase->end += iobase & ~1;
101 105
106 pci_dev_put(pm_dev);
107
102 /* Allocate the resource region */ 108 /* Allocate the resource region */
103 if (pci_assign_resource(pm_dev, PIIXE_IOBASE_RESOURCE) != 0) { 109 if (pci_assign_resource(pm_dev, PIIXE_IOBASE_RESOURCE) != 0) {
110 pci_dev_put(dev);
111 pci_dev_put(pm_dev);
104 printk(KERN_WARNING "Could not allocate pm iobase resource\n"); 112 printk(KERN_WARNING "Could not allocate pm iobase resource\n");
105 iounmap(l440gx_map.virt); 113 iounmap(l440gx_map.virt);
106 return -ENXIO; 114 return -ENXIO;
diff --git a/drivers/mtd/maps/lasat.c b/drivers/mtd/maps/lasat.c
index 1c13d2dc0cdf..e34376321050 100644
--- a/drivers/mtd/maps/lasat.c
+++ b/drivers/mtd/maps/lasat.c
@@ -79,6 +79,7 @@ static int __init init_lasat(void)
79 return 0; 79 return 0;
80 } 80 }
81 81
82 iounmap(lasat_map.virt);
82 return -ENXIO; 83 return -ENXIO;
83} 84}
84 85
@@ -89,6 +90,7 @@ static void __exit cleanup_lasat(void)
89 map_destroy(lasat_mtd); 90 map_destroy(lasat_mtd);
90 } 91 }
91 if (lasat_map.virt) { 92 if (lasat_map.virt) {
93 iounmap(lasat_map.virt);
92 lasat_map.virt = 0; 94 lasat_map.virt = 0;
93 } 95 }
94} 96}
diff --git a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c
index 0994b5b2e331..198e840ff6db 100644
--- a/drivers/mtd/maps/nettel.c
+++ b/drivers/mtd/maps/nettel.c
@@ -277,6 +277,7 @@ int __init nettel_init(void)
277 nettel_amd_map.virt = ioremap_nocache(amdaddr, maxsize); 277 nettel_amd_map.virt = ioremap_nocache(amdaddr, maxsize);
278 if (!nettel_amd_map.virt) { 278 if (!nettel_amd_map.virt) {
279 printk("SNAPGEAR: failed to ioremap() BOOTCS\n"); 279 printk("SNAPGEAR: failed to ioremap() BOOTCS\n");
280 iounmap(nettel_mmcrp);
280 return(-EIO); 281 return(-EIO);
281 } 282 }
282 simple_map_init(&nettel_amd_map); 283 simple_map_init(&nettel_amd_map);
@@ -337,7 +338,8 @@ int __init nettel_init(void)
337 nettel_amd_map.virt = NULL; 338 nettel_amd_map.virt = NULL;
338#else 339#else
339 /* Only AMD flash supported */ 340 /* Only AMD flash supported */
340 return(-ENXIO); 341 rc = -ENXIO;
342 goto out_unmap2;
341#endif 343#endif
342 } 344 }
343 345
@@ -361,14 +363,15 @@ int __init nettel_init(void)
361 nettel_intel_map.virt = ioremap_nocache(intel0addr, maxsize); 363 nettel_intel_map.virt = ioremap_nocache(intel0addr, maxsize);
362 if (!nettel_intel_map.virt) { 364 if (!nettel_intel_map.virt) {
363 printk("SNAPGEAR: failed to ioremap() ROMCS1\n"); 365 printk("SNAPGEAR: failed to ioremap() ROMCS1\n");
364 return(-EIO); 366 rc = -EIO;
367 goto out_unmap2;
365 } 368 }
366 simple_map_init(&nettel_intel_map); 369 simple_map_init(&nettel_intel_map);
367 370
368 intel_mtd = do_map_probe("cfi_probe", &nettel_intel_map); 371 intel_mtd = do_map_probe("cfi_probe", &nettel_intel_map);
369 if (!intel_mtd) { 372 if (!intel_mtd) {
370 iounmap(nettel_intel_map.virt); 373 rc = -ENXIO;
371 return(-ENXIO); 374 goto out_unmap1;
372 } 375 }
373 376
374 /* Set PAR to the detected size */ 377 /* Set PAR to the detected size */
@@ -394,13 +397,14 @@ int __init nettel_init(void)
394 nettel_intel_map.virt = ioremap_nocache(intel0addr, maxsize); 397 nettel_intel_map.virt = ioremap_nocache(intel0addr, maxsize);
395 if (!nettel_intel_map.virt) { 398 if (!nettel_intel_map.virt) {
396 printk("SNAPGEAR: failed to ioremap() ROMCS1/2\n"); 399 printk("SNAPGEAR: failed to ioremap() ROMCS1/2\n");
397 return(-EIO); 400 rc = -EIO;
401 goto out_unmap2;
398 } 402 }
399 403
400 intel_mtd = do_map_probe("cfi_probe", &nettel_intel_map); 404 intel_mtd = do_map_probe("cfi_probe", &nettel_intel_map);
401 if (! intel_mtd) { 405 if (! intel_mtd) {
402 iounmap((void *) nettel_intel_map.virt); 406 rc = -ENXIO;
403 return(-ENXIO); 407 goto out_unmap1;
404 } 408 }
405 409
406 intel1size = intel_mtd->size - intel0size; 410 intel1size = intel_mtd->size - intel0size;
@@ -456,6 +460,18 @@ int __init nettel_init(void)
456#endif 460#endif
457 461
458 return(rc); 462 return(rc);
463
464#ifdef CONFIG_MTD_CFI_INTELEXT
465out_unmap1:
466 iounmap((void *) nettel_intel_map.virt);
467#endif
468
469out_unmap2:
470 iounmap(nettel_mmcrp);
471 iounmap(nettel_amd_map.virt);
472
473 return(rc);
474
459} 475}
460 476
461/****************************************************************************/ 477/****************************************************************************/
@@ -469,6 +485,10 @@ void __exit nettel_cleanup(void)
469 del_mtd_partitions(amd_mtd); 485 del_mtd_partitions(amd_mtd);
470 map_destroy(amd_mtd); 486 map_destroy(amd_mtd);
471 } 487 }
488 if (nettel_mmcrp) {
489 iounmap(nettel_mmcrp);
490 nettel_mmcrp = NULL;
491 }
472 if (nettel_amd_map.virt) { 492 if (nettel_amd_map.virt) {
473 iounmap(nettel_amd_map.virt); 493 iounmap(nettel_amd_map.virt);
474 nettel_amd_map.virt = NULL; 494 nettel_amd_map.virt = NULL;
diff --git a/drivers/mtd/maps/ocotea.c b/drivers/mtd/maps/ocotea.c
index 2f07602ba940..5522eac8c980 100644
--- a/drivers/mtd/maps/ocotea.c
+++ b/drivers/mtd/maps/ocotea.c
@@ -97,6 +97,7 @@ int __init init_ocotea(void)
97 ARRAY_SIZE(ocotea_small_partitions)); 97 ARRAY_SIZE(ocotea_small_partitions));
98 } else { 98 } else {
99 printk("map probe failed for flash\n"); 99 printk("map probe failed for flash\n");
100 iounmap(ocotea_small_map.virt);
100 return -ENXIO; 101 return -ENXIO;
101 } 102 }
102 103
@@ -106,6 +107,7 @@ int __init init_ocotea(void)
106 107
107 if (!ocotea_large_map.virt) { 108 if (!ocotea_large_map.virt) {
108 printk("Failed to ioremap flash\n"); 109 printk("Failed to ioremap flash\n");
110 iounmap(ocotea_small_map.virt);
109 return -EIO; 111 return -EIO;
110 } 112 }
111 113
@@ -118,6 +120,8 @@ int __init init_ocotea(void)
118 ARRAY_SIZE(ocotea_large_partitions)); 120 ARRAY_SIZE(ocotea_large_partitions));
119 } else { 121 } else {
120 printk("map probe failed for flash\n"); 122 printk("map probe failed for flash\n");
123 iounmap(ocotea_small_map.virt);
124 iounmap(ocotea_large_map.virt);
121 return -ENXIO; 125 return -ENXIO;
122 } 126 }
123 127
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index c861134cbc48..995347b1beba 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -602,6 +602,10 @@ static int pcmciamtd_config(struct pcmcia_device *link)
602 ret = pcmcia_request_configuration(link, &link->conf); 602 ret = pcmcia_request_configuration(link, &link->conf);
603 if(ret != CS_SUCCESS) { 603 if(ret != CS_SUCCESS) {
604 cs_error(link, RequestConfiguration, ret); 604 cs_error(link, RequestConfiguration, ret);
605 if (dev->win_base) {
606 iounmap(dev->win_base);
607 dev->win_base = NULL;
608 }
605 return -ENODEV; 609 return -ENODEV;
606 } 610 }
607 611
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 7799a25a7f2a..bc7cc71788bc 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -158,9 +158,42 @@ err_out:
158 return err; 158 return err;
159} 159}
160 160
161#ifdef CONFIG_PM
162static int physmap_flash_suspend(struct platform_device *dev, pm_message_t state)
163{
164 struct physmap_flash_info *info = platform_get_drvdata(dev);
165 int ret = 0;
166
167 if (info)
168 ret = info->mtd->suspend(info->mtd);
169
170 return ret;
171}
172
173static int physmap_flash_resume(struct platform_device *dev)
174{
175 struct physmap_flash_info *info = platform_get_drvdata(dev);
176 if (info)
177 info->mtd->resume(info->mtd);
178 return 0;
179}
180
181static void physmap_flash_shutdown(struct platform_device *dev)
182{
183 struct physmap_flash_info *info = platform_get_drvdata(dev);
184 if (info && info->mtd->suspend(info->mtd) == 0)
185 info->mtd->resume(info->mtd);
186}
187#endif
188
161static struct platform_driver physmap_flash_driver = { 189static struct platform_driver physmap_flash_driver = {
162 .probe = physmap_flash_probe, 190 .probe = physmap_flash_probe,
163 .remove = physmap_flash_remove, 191 .remove = physmap_flash_remove,
192#ifdef CONFIG_PM
193 .suspend = physmap_flash_suspend,
194 .resume = physmap_flash_resume,
195 .shutdown = physmap_flash_shutdown,
196#endif
164 .driver = { 197 .driver = {
165 .name = "physmap-flash", 198 .name = "physmap-flash",
166 }, 199 },
diff --git a/drivers/mtd/maps/redwood.c b/drivers/mtd/maps/redwood.c
index ec8fdae1dd99..2257d2b500c0 100644
--- a/drivers/mtd/maps/redwood.c
+++ b/drivers/mtd/maps/redwood.c
@@ -126,6 +126,8 @@ static struct mtd_info *redwood_mtd;
126 126
127int __init init_redwood_flash(void) 127int __init init_redwood_flash(void)
128{ 128{
129 int err = 0;
130
129 printk(KERN_NOTICE "redwood: flash mapping: %x at %x\n", 131 printk(KERN_NOTICE "redwood: flash mapping: %x at %x\n",
130 WINDOW_SIZE, WINDOW_ADDR); 132 WINDOW_SIZE, WINDOW_ADDR);
131 133
@@ -141,11 +143,18 @@ int __init init_redwood_flash(void)
141 143
142 if (redwood_mtd) { 144 if (redwood_mtd) {
143 redwood_mtd->owner = THIS_MODULE; 145 redwood_mtd->owner = THIS_MODULE;
144 return add_mtd_partitions(redwood_mtd, 146 err = add_mtd_partitions(redwood_mtd,
145 redwood_flash_partitions, 147 redwood_flash_partitions,
146 NUM_REDWOOD_FLASH_PARTITIONS); 148 NUM_REDWOOD_FLASH_PARTITIONS);
149 if (err) {
150 printk("init_redwood_flash: add_mtd_partitions failed\n");
151 iounmap(redwood_flash_map.virt);
152 }
153 return err;
154
147 } 155 }
148 156
157 iounmap(redwood_flash_map.virt);
149 return -ENXIO; 158 return -ENXIO;
150} 159}
151 160
diff --git a/drivers/mtd/maps/sbc8240.c b/drivers/mtd/maps/sbc8240.c
index 7d0fcf8f4f33..b8c1331b7a04 100644
--- a/drivers/mtd/maps/sbc8240.c
+++ b/drivers/mtd/maps/sbc8240.c
@@ -156,7 +156,7 @@ int __init init_sbc8240_mtd (void)
156 }; 156 };
157 157
158 int devicesfound = 0; 158 int devicesfound = 0;
159 int i; 159 int i,j;
160 160
161 for (i = 0; i < NUM_FLASH_BANKS; i++) { 161 for (i = 0; i < NUM_FLASH_BANKS; i++) {
162 printk (KERN_NOTICE MSG_PREFIX 162 printk (KERN_NOTICE MSG_PREFIX
@@ -166,6 +166,10 @@ int __init init_sbc8240_mtd (void)
166 (unsigned long) ioremap (pt[i].addr, pt[i].size); 166 (unsigned long) ioremap (pt[i].addr, pt[i].size);
167 if (!sbc8240_map[i].map_priv_1) { 167 if (!sbc8240_map[i].map_priv_1) {
168 printk (MSG_PREFIX "failed to ioremap\n"); 168 printk (MSG_PREFIX "failed to ioremap\n");
169 for (j = 0; j < i; j++) {
170 iounmap((void *) sbc8240_map[j].map_priv_1);
171 sbc8240_map[j].map_priv_1 = 0;
172 }
169 return -EIO; 173 return -EIO;
170 } 174 }
171 simple_map_init(&sbc8240_mtd[i]); 175 simple_map_init(&sbc8240_mtd[i]);
@@ -175,6 +179,11 @@ int __init init_sbc8240_mtd (void)
175 if (sbc8240_mtd[i]) { 179 if (sbc8240_mtd[i]) {
176 sbc8240_mtd[i]->module = THIS_MODULE; 180 sbc8240_mtd[i]->module = THIS_MODULE;
177 devicesfound++; 181 devicesfound++;
182 } else {
183 if (sbc8240_map[i].map_priv_1) {
184 iounmap((void *) sbc8240_map[i].map_priv_1);
185 sbc8240_map[i].map_priv_1 = 0;
186 }
178 } 187 }
179 } 188 }
180 189
diff --git a/drivers/mtd/maps/scx200_docflash.c b/drivers/mtd/maps/scx200_docflash.c
index 7391fd544e86..5e2bce22f37c 100644
--- a/drivers/mtd/maps/scx200_docflash.c
+++ b/drivers/mtd/maps/scx200_docflash.c
@@ -87,19 +87,23 @@ static int __init init_scx200_docflash(void)
87 87
88 printk(KERN_DEBUG NAME ": NatSemi SCx200 DOCCS Flash Driver\n"); 88 printk(KERN_DEBUG NAME ": NatSemi SCx200 DOCCS Flash Driver\n");
89 89
90 if ((bridge = pci_find_device(PCI_VENDOR_ID_NS, 90 if ((bridge = pci_get_device(PCI_VENDOR_ID_NS,
91 PCI_DEVICE_ID_NS_SCx200_BRIDGE, 91 PCI_DEVICE_ID_NS_SCx200_BRIDGE,
92 NULL)) == NULL) 92 NULL)) == NULL)
93 return -ENODEV; 93 return -ENODEV;
94 94
95 /* check that we have found the configuration block */ 95 /* check that we have found the configuration block */
96 if (!scx200_cb_present()) 96 if (!scx200_cb_present()) {
97 pci_dev_put(bridge);
97 return -ENODEV; 98 return -ENODEV;
99 }
98 100
99 if (probe) { 101 if (probe) {
100 /* Try to use the present flash mapping if any */ 102 /* Try to use the present flash mapping if any */
101 pci_read_config_dword(bridge, SCx200_DOCCS_BASE, &base); 103 pci_read_config_dword(bridge, SCx200_DOCCS_BASE, &base);
102 pci_read_config_dword(bridge, SCx200_DOCCS_CTRL, &ctrl); 104 pci_read_config_dword(bridge, SCx200_DOCCS_CTRL, &ctrl);
105 pci_dev_put(bridge);
106
103 pmr = inl(scx200_cb_base + SCx200_PMR); 107 pmr = inl(scx200_cb_base + SCx200_PMR);
104 108
105 if (base == 0 109 if (base == 0
@@ -127,6 +131,7 @@ static int __init init_scx200_docflash(void)
127 return -ENOMEM; 131 return -ENOMEM;
128 } 132 }
129 } else { 133 } else {
134 pci_dev_put(bridge);
130 for (u = size; u > 1; u >>= 1) 135 for (u = size; u > 1; u >>= 1)
131 ; 136 ;
132 if (u != 1) { 137 if (u != 1) {
diff --git a/drivers/mtd/maps/walnut.c b/drivers/mtd/maps/walnut.c
index ec80eec376bf..ca932122fb64 100644
--- a/drivers/mtd/maps/walnut.c
+++ b/drivers/mtd/maps/walnut.c
@@ -68,6 +68,7 @@ int __init init_walnut(void)
68 68
69 if (WALNUT_FLASH_ONBD_N(fpga_brds1)) { 69 if (WALNUT_FLASH_ONBD_N(fpga_brds1)) {
70 printk("The on-board flash is disabled (U79 sw 5)!"); 70 printk("The on-board flash is disabled (U79 sw 5)!");
71 iounmap(fpga_status_adr);
71 return -EIO; 72 return -EIO;
72 } 73 }
73 if (WALNUT_FLASH_SRAM_SEL(fpga_brds1)) 74 if (WALNUT_FLASH_SRAM_SEL(fpga_brds1))
@@ -81,6 +82,7 @@ int __init init_walnut(void)
81 82
82 if (!walnut_map.virt) { 83 if (!walnut_map.virt) {
83 printk("Failed to ioremap flash.\n"); 84 printk("Failed to ioremap flash.\n");
85 iounmap(fpga_status_adr);
84 return -EIO; 86 return -EIO;
85 } 87 }
86 88
@@ -93,9 +95,11 @@ int __init init_walnut(void)
93 ARRAY_SIZE(walnut_partitions)); 95 ARRAY_SIZE(walnut_partitions));
94 } else { 96 } else {
95 printk("map probe failed for flash\n"); 97 printk("map probe failed for flash\n");
98 iounmap(fpga_status_adr);
96 return -ENXIO; 99 return -ENXIO;
97 } 100 }
98 101
102 iounmap(fpga_status_adr);
99 return 0; 103 return 0;
100} 104}
101 105
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 168d3ba063c3..c4d26de74349 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -57,6 +57,16 @@ int add_mtd_device(struct mtd_info *mtd)
57 mtd->index = i; 57 mtd->index = i;
58 mtd->usecount = 0; 58 mtd->usecount = 0;
59 59
60 /* Some chips always power up locked. Unlock them now */
61 if ((mtd->flags & MTD_WRITEABLE)
62 && (mtd->flags & MTD_STUPID_LOCK) && mtd->unlock) {
63 if (mtd->unlock(mtd, 0, mtd->size))
64 printk(KERN_WARNING
65 "%s: unlock failed, "
66 "writes may not work\n",
67 mtd->name);
68 }
69
60 DEBUG(0, "mtd: Giving out device %d to %s\n",i, mtd->name); 70 DEBUG(0, "mtd: Giving out device %d to %s\n",i, mtd->name);
61 /* No need to get a refcount on the module containing 71 /* No need to get a refcount on the module containing
62 the notifier, since we hold the mtd_table_mutex */ 72 the notifier, since we hold the mtd_table_mutex */
diff --git a/drivers/mtd/nand/au1550nd.c b/drivers/mtd/nand/au1550nd.c
index 31228334da12..09e421a96893 100644
--- a/drivers/mtd/nand/au1550nd.c
+++ b/drivers/mtd/nand/au1550nd.c
@@ -21,18 +21,7 @@
21#include <linux/version.h> 21#include <linux/version.h>
22#include <asm/io.h> 22#include <asm/io.h>
23 23
24/* fixme: this is ugly */
25#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 0)
26#include <asm/mach-au1x00/au1xxx.h> 24#include <asm/mach-au1x00/au1xxx.h>
27#else
28#include <asm/au1000.h>
29#ifdef CONFIG_MIPS_PB1550
30#include <asm/pb1550.h>
31#endif
32#ifdef CONFIG_MIPS_DB1550
33#include <asm/db1x00.h>
34#endif
35#endif
36 25
37/* 26/*
38 * MTD structure for NAND controller 27 * MTD structure for NAND controller
diff --git a/drivers/mtd/nand/edb7312.c b/drivers/mtd/nand/edb7312.c
index 516c0e5e564c..12017f3c6bd6 100644
--- a/drivers/mtd/nand/edb7312.c
+++ b/drivers/mtd/nand/edb7312.c
@@ -198,6 +198,9 @@ static void __exit ep7312_cleanup(void)
198 /* Release resources, unregister device */ 198 /* Release resources, unregister device */
199 nand_release(ap7312_mtd); 199 nand_release(ap7312_mtd);
200 200
201 /* Release io resource */
202 iounmap((void *)this->IO_ADDR_R);
203
201 /* Free the MTD device structure */ 204 /* Free the MTD device structure */
202 kfree(ep7312_mtd); 205 kfree(ep7312_mtd);
203} 206}
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c
index e5bd88f2d560..039c759cfbfc 100644
--- a/drivers/mtd/nand/ndfc.c
+++ b/drivers/mtd/nand/ndfc.c
@@ -168,7 +168,7 @@ static void ndfc_chip_init(struct ndfc_nand_mtd *mtd)
168 chip->ecc.mode = NAND_ECC_HW; 168 chip->ecc.mode = NAND_ECC_HW;
169 chip->ecc.size = 256; 169 chip->ecc.size = 256;
170 chip->ecc.bytes = 3; 170 chip->ecc.bytes = 3;
171 chip->ecclayout = mtd->pl_chip->ecclayout; 171 chip->ecclayout = chip->ecc.layout = mtd->pl_chip->ecclayout;
172 mtd->mtd.priv = chip; 172 mtd->mtd.priv = chip;
173 mtd->mtd.owner = THIS_MODULE; 173 mtd->mtd.owner = THIS_MODULE;
174} 174}
diff --git a/drivers/mtd/nand/ppchameleonevb.c b/drivers/mtd/nand/ppchameleonevb.c
index 22fa65c12ab9..eb7d4d443deb 100644
--- a/drivers/mtd/nand/ppchameleonevb.c
+++ b/drivers/mtd/nand/ppchameleonevb.c
@@ -276,6 +276,7 @@ static int __init ppchameleonevb_init(void)
276 /* Scan to find existence of the device (it could not be mounted) */ 276 /* Scan to find existence of the device (it could not be mounted) */
277 if (nand_scan(ppchameleon_mtd, 1)) { 277 if (nand_scan(ppchameleon_mtd, 1)) {
278 iounmap((void *)ppchameleon_fio_base); 278 iounmap((void *)ppchameleon_fio_base);
279 ppchameleon_fio_base = NULL;
279 kfree(ppchameleon_mtd); 280 kfree(ppchameleon_mtd);
280 goto nand_evb_init; 281 goto nand_evb_init;
281 } 282 }
@@ -314,6 +315,8 @@ static int __init ppchameleonevb_init(void)
314 ppchameleonevb_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL); 315 ppchameleonevb_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip), GFP_KERNEL);
315 if (!ppchameleonevb_mtd) { 316 if (!ppchameleonevb_mtd) {
316 printk("Unable to allocate PPChameleonEVB NAND MTD device structure.\n"); 317 printk("Unable to allocate PPChameleonEVB NAND MTD device structure.\n");
318 if (ppchameleon_fio_base)
319 iounmap(ppchameleon_fio_base);
317 return -ENOMEM; 320 return -ENOMEM;
318 } 321 }
319 322
@@ -322,6 +325,8 @@ static int __init ppchameleonevb_init(void)
322 if (!ppchameleonevb_fio_base) { 325 if (!ppchameleonevb_fio_base) {
323 printk("ioremap PPChameleonEVB NAND flash failed\n"); 326 printk("ioremap PPChameleonEVB NAND flash failed\n");
324 kfree(ppchameleonevb_mtd); 327 kfree(ppchameleonevb_mtd);
328 if (ppchameleon_fio_base)
329 iounmap(ppchameleon_fio_base);
325 return -EIO; 330 return -EIO;
326 } 331 }
327 332
@@ -378,6 +383,8 @@ static int __init ppchameleonevb_init(void)
378 if (nand_scan(ppchameleonevb_mtd, 1)) { 383 if (nand_scan(ppchameleonevb_mtd, 1)) {
379 iounmap((void *)ppchameleonevb_fio_base); 384 iounmap((void *)ppchameleonevb_fio_base);
380 kfree(ppchameleonevb_mtd); 385 kfree(ppchameleonevb_mtd);
386 if (ppchameleon_fio_base)
387 iounmap(ppchameleon_fio_base);
381 return -ENXIO; 388 return -ENXIO;
382 } 389 }
383#ifdef CONFIG_MTD_PARTITIONS 390#ifdef CONFIG_MTD_PARTITIONS
diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c
new file mode 100644
index 000000000000..ddbf015f4119
--- /dev/null
+++ b/drivers/mtd/ssfdc.c
@@ -0,0 +1,468 @@
1/*
2 * Linux driver for SSFDC Flash Translation Layer (Read only)
3 * (c) 2005 Eptar srl
4 * Author: Claudio Lanconelli <lanconelli.claudio@eptar.com>
5 *
6 * Based on NTFL and MTDBLOCK_RO drivers
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/config.h>
14#include <linux/kernel.h>
15#include <linux/module.h>
16#include <linux/init.h>
17#include <linux/slab.h>
18#include <linux/hdreg.h>
19#include <linux/mtd/mtd.h>
20#include <linux/mtd/nand.h>
21#include <linux/mtd/blktrans.h>
22
23struct ssfdcr_record {
24 struct mtd_blktrans_dev mbd;
25 int usecount;
26 unsigned char heads;
27 unsigned char sectors;
28 unsigned short cylinders;
29 int cis_block; /* block n. containing CIS/IDI */
30 int erase_size; /* phys_block_size */
31 unsigned short *logic_block_map; /* all zones (max 8192 phys blocks on
32 the 128MB) */
33 int map_len; /* n. phys_blocks on the card */
34};
35
36#define SSFDCR_MAJOR 257
37#define SSFDCR_PARTN_BITS 3
38
39#define SECTOR_SIZE 512
40#define SECTOR_SHIFT 9
41#define OOB_SIZE 16
42
43#define MAX_LOGIC_BLK_PER_ZONE 1000
44#define MAX_PHYS_BLK_PER_ZONE 1024
45
46#define KB(x) ( (x) * 1024L )
47#define MB(x) ( KB(x) * 1024L )
48
49/** CHS Table
50 1MB 2MB 4MB 8MB 16MB 32MB 64MB 128MB
51NCylinder 125 125 250 250 500 500 500 500
52NHead 4 4 4 4 4 8 8 16
53NSector 4 8 8 16 16 16 32 32
54SumSector 2,000 4,000 8,000 16,000 32,000 64,000 128,000 256,000
55SectorSize 512 512 512 512 512 512 512 512
56**/
57
58typedef struct {
59 unsigned long size;
60 unsigned short cyl;
61 unsigned char head;
62 unsigned char sec;
63} chs_entry_t;
64
65/* Must be ordered by size */
66static const chs_entry_t chs_table[] = {
67 { MB( 1), 125, 4, 4 },
68 { MB( 2), 125, 4, 8 },
69 { MB( 4), 250, 4, 8 },
70 { MB( 8), 250, 4, 16 },
71 { MB( 16), 500, 4, 16 },
72 { MB( 32), 500, 8, 16 },
73 { MB( 64), 500, 8, 32 },
74 { MB(128), 500, 16, 32 },
75 { 0 },
76};
77
78static int get_chs(unsigned long size, unsigned short *cyl, unsigned char *head,
79 unsigned char *sec)
80{
81 int k;
82 int found = 0;
83
84 k = 0;
85 while (chs_table[k].size > 0 && size > chs_table[k].size)
86 k++;
87
88 if (chs_table[k].size > 0) {
89 if (cyl)
90 *cyl = chs_table[k].cyl;
91 if (head)
92 *head = chs_table[k].head;
93 if (sec)
94 *sec = chs_table[k].sec;
95 found = 1;
96 }
97
98 return found;
99}
100
101/* These bytes are the signature for the CIS/IDI sector */
102static const uint8_t cis_numbers[] = {
103 0x01, 0x03, 0xD9, 0x01, 0xFF, 0x18, 0x02, 0xDF, 0x01, 0x20
104};
105
106/* Read and check for a valid CIS sector */
107static int get_valid_cis_sector(struct mtd_info *mtd)
108{
109 int ret, k, cis_sector;
110 size_t retlen;
111 loff_t offset;
112 uint8_t sect_buf[SECTOR_SIZE];
113
114 /*
115 * Look for CIS/IDI sector on the first GOOD block (give up after 4 bad
116 * blocks). If the first good block doesn't contain CIS number the flash
117 * is not SSFDC formatted
118 */
119 cis_sector = -1;
120 for (k = 0, offset = 0; k < 4; k++, offset += mtd->erasesize) {
121 if (!mtd->block_isbad(mtd, offset)) {
122 ret = mtd->read(mtd, offset, SECTOR_SIZE, &retlen,
123 sect_buf);
124
125 /* CIS pattern match on the sector buffer */
126 if ( ret < 0 || retlen != SECTOR_SIZE ) {
127 printk(KERN_WARNING
128 "SSFDC_RO:can't read CIS/IDI sector\n");
129 } else if ( !memcmp(sect_buf, cis_numbers,
130 sizeof(cis_numbers)) ) {
131 /* Found */
132 cis_sector = (int)(offset >> SECTOR_SHIFT);
133 } else {
134 DEBUG(MTD_DEBUG_LEVEL1,
135 "SSFDC_RO: CIS/IDI sector not found"
136 " on %s (mtd%d)\n", mtd->name,
137 mtd->index);
138 }
139 break;
140 }
141 }
142
143 return cis_sector;
144}
145
146/* Read physical sector (wrapper to MTD_READ) */
147static int read_physical_sector(struct mtd_info *mtd, uint8_t *sect_buf,
148 int sect_no)
149{
150 int ret;
151 size_t retlen;
152 loff_t offset = (loff_t)sect_no << SECTOR_SHIFT;
153
154 ret = mtd->read(mtd, offset, SECTOR_SIZE, &retlen, sect_buf);
155 if (ret < 0 || retlen != SECTOR_SIZE)
156 return -1;
157
158 return 0;
159}
160
161/* Read redundancy area (wrapper to MTD_READ_OOB */
162static int read_raw_oob(struct mtd_info *mtd, loff_t offs, uint8_t *buf)
163{
164 struct mtd_oob_ops ops;
165 int ret;
166
167 ops.mode = MTD_OOB_RAW;
168 ops.ooboffs = 0;
169 ops.ooblen = mtd->oobsize;
170 ops.len = OOB_SIZE;
171 ops.oobbuf = buf;
172 ops.datbuf = NULL;
173
174 ret = mtd->read_oob(mtd, offs, &ops);
175 if (ret < 0 || ops.retlen != OOB_SIZE)
176 return -1;
177
178 return 0;
179}
180
181/* Parity calculator on a word of n bit size */
182static int get_parity(int number, int size)
183{
184 int k;
185 int parity;
186
187 parity = 1;
188 for (k = 0; k < size; k++) {
189 parity += (number >> k);
190 parity &= 1;
191 }
192 return parity;
193}
194
195/* Read and validate the logical block address field stored in the OOB */
196static int get_logical_address(uint8_t *oob_buf)
197{
198 int block_address, parity;
199 int offset[2] = {6, 11}; /* offset of the 2 address fields within OOB */
200 int j;
201 int ok = 0;
202
203 /*
204 * Look for the first valid logical address
205 * Valid address has fixed pattern on most significant bits and
206 * parity check
207 */
208 for (j = 0; j < ARRAY_SIZE(offset); j++) {
209 block_address = ((int)oob_buf[offset[j]] << 8) |
210 oob_buf[offset[j]+1];
211
212 /* Check for the signature bits in the address field (MSBits) */
213 if ((block_address & ~0x7FF) == 0x1000) {
214 parity = block_address & 0x01;
215 block_address &= 0x7FF;
216 block_address >>= 1;
217
218 if (get_parity(block_address, 10) != parity) {
219 DEBUG(MTD_DEBUG_LEVEL0,
220 "SSFDC_RO: logical address field%d"
221 "parity error(0x%04X)\n", j+1,
222 block_address);
223 } else {
224 ok = 1;
225 break;
226 }
227 }
228 }
229
230 if ( !ok )
231 block_address = -2;
232
233 DEBUG(MTD_DEBUG_LEVEL3, "SSFDC_RO: get_logical_address() %d\n",
234 block_address);
235
236 return block_address;
237}
238
239/* Build the logic block map */
240static int build_logical_block_map(struct ssfdcr_record *ssfdc)
241{
242 unsigned long offset;
243 uint8_t oob_buf[OOB_SIZE];
244 int ret, block_address, phys_block;
245 struct mtd_info *mtd = ssfdc->mbd.mtd;
246
247 DEBUG(MTD_DEBUG_LEVEL1, "SSFDC_RO: build_block_map() nblks=%d (%luK)\n",
248 ssfdc->map_len, (unsigned long)ssfdc->map_len *
249 ssfdc->erase_size / 1024 );
250
251 /* Scan every physical block, skip CIS block */
252 for (phys_block = ssfdc->cis_block + 1; phys_block < ssfdc->map_len;
253 phys_block++) {
254 offset = (unsigned long)phys_block * ssfdc->erase_size;
255 if (mtd->block_isbad(mtd, offset))
256 continue; /* skip bad blocks */
257
258 ret = read_raw_oob(mtd, offset, oob_buf);
259 if (ret < 0) {
260 DEBUG(MTD_DEBUG_LEVEL0,
261 "SSFDC_RO: mtd read_oob() failed at %lu\n",
262 offset);
263 return -1;
264 }
265 block_address = get_logical_address(oob_buf);
266
267 /* Skip invalid addresses */
268 if (block_address >= 0 &&
269 block_address < MAX_LOGIC_BLK_PER_ZONE) {
270 int zone_index;
271
272 zone_index = phys_block / MAX_PHYS_BLK_PER_ZONE;
273 block_address += zone_index * MAX_LOGIC_BLK_PER_ZONE;
274 ssfdc->logic_block_map[block_address] =
275 (unsigned short)phys_block;
276
277 DEBUG(MTD_DEBUG_LEVEL2,
278 "SSFDC_RO: build_block_map() phys_block=%d,"
279 "logic_block_addr=%d, zone=%d\n",
280 phys_block, block_address, zone_index);
281 }
282 }
283 return 0;
284}
285
286static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
287{
288 struct ssfdcr_record *ssfdc;
289 int cis_sector;
290
291 /* Check for small page NAND flash */
292 if (mtd->type != MTD_NANDFLASH || mtd->oobsize != OOB_SIZE)
293 return;
294
295 /* Check for SSDFC format by reading CIS/IDI sector */
296 cis_sector = get_valid_cis_sector(mtd);
297 if (cis_sector == -1)
298 return;
299
300 ssfdc = kzalloc(sizeof(struct ssfdcr_record), GFP_KERNEL);
301 if (!ssfdc) {
302 printk(KERN_WARNING
303 "SSFDC_RO: out of memory for data structures\n");
304 return;
305 }
306
307 ssfdc->mbd.mtd = mtd;
308 ssfdc->mbd.devnum = -1;
309 ssfdc->mbd.blksize = SECTOR_SIZE;
310 ssfdc->mbd.tr = tr;
311 ssfdc->mbd.readonly = 1;
312
313 ssfdc->cis_block = cis_sector / (mtd->erasesize >> SECTOR_SHIFT);
314 ssfdc->erase_size = mtd->erasesize;
315 ssfdc->map_len = mtd->size / mtd->erasesize;
316
317 DEBUG(MTD_DEBUG_LEVEL1,
318 "SSFDC_RO: cis_block=%d,erase_size=%d,map_len=%d,n_zones=%d\n",
319 ssfdc->cis_block, ssfdc->erase_size, ssfdc->map_len,
320 (ssfdc->map_len + MAX_PHYS_BLK_PER_ZONE - 1) /
321 MAX_PHYS_BLK_PER_ZONE);
322
323 /* Set geometry */
324 ssfdc->heads = 16;
325 ssfdc->sectors = 32;
326 get_chs( mtd->size, NULL, &ssfdc->heads, &ssfdc->sectors);
327 ssfdc->cylinders = (unsigned short)((mtd->size >> SECTOR_SHIFT) /
328 ((long)ssfdc->sectors * (long)ssfdc->heads));
329
330 DEBUG(MTD_DEBUG_LEVEL1, "SSFDC_RO: using C:%d H:%d S:%d == %ld sects\n",
331 ssfdc->cylinders, ssfdc->heads , ssfdc->sectors,
332 (long)ssfdc->cylinders * (long)ssfdc->heads *
333 (long)ssfdc->sectors );
334
335 ssfdc->mbd.size = (long)ssfdc->heads * (long)ssfdc->cylinders *
336 (long)ssfdc->sectors;
337
338 /* Allocate logical block map */
339 ssfdc->logic_block_map = kmalloc( sizeof(ssfdc->logic_block_map[0]) *
340 ssfdc->map_len, GFP_KERNEL);
341 if (!ssfdc->logic_block_map) {
342 printk(KERN_WARNING
343 "SSFDC_RO: out of memory for data structures\n");
344 goto out_err;
345 }
346 memset(ssfdc->logic_block_map, 0xff, sizeof(ssfdc->logic_block_map[0]) *
347 ssfdc->map_len);
348
349 /* Build logical block map */
350 if (build_logical_block_map(ssfdc) < 0)
351 goto out_err;
352
353 /* Register device + partitions */
354 if (add_mtd_blktrans_dev(&ssfdc->mbd))
355 goto out_err;
356
357 printk(KERN_INFO "SSFDC_RO: Found ssfdc%c on mtd%d (%s)\n",
358 ssfdc->mbd.devnum + 'a', mtd->index, mtd->name);
359 return;
360
361out_err:
362 kfree(ssfdc->logic_block_map);
363 kfree(ssfdc);
364}
365
366static void ssfdcr_remove_dev(struct mtd_blktrans_dev *dev)
367{
368 struct ssfdcr_record *ssfdc = (struct ssfdcr_record *)dev;
369
370 DEBUG(MTD_DEBUG_LEVEL1, "SSFDC_RO: remove_dev (i=%d)\n", dev->devnum);
371
372 del_mtd_blktrans_dev(dev);
373 kfree(ssfdc->logic_block_map);
374 kfree(ssfdc);
375}
376
377static int ssfdcr_readsect(struct mtd_blktrans_dev *dev,
378 unsigned long logic_sect_no, char *buf)
379{
380 struct ssfdcr_record *ssfdc = (struct ssfdcr_record *)dev;
381 int sectors_per_block, offset, block_address;
382
383 sectors_per_block = ssfdc->erase_size >> SECTOR_SHIFT;
384 offset = (int)(logic_sect_no % sectors_per_block);
385 block_address = (int)(logic_sect_no / sectors_per_block);
386
387 DEBUG(MTD_DEBUG_LEVEL3,
388 "SSFDC_RO: ssfdcr_readsect(%lu) sec_per_blk=%d, ofst=%d,"
389 " block_addr=%d\n", logic_sect_no, sectors_per_block, offset,
390 block_address);
391
392 if (block_address >= ssfdc->map_len)
393 BUG();
394
395 block_address = ssfdc->logic_block_map[block_address];
396
397 DEBUG(MTD_DEBUG_LEVEL3,
398 "SSFDC_RO: ssfdcr_readsect() phys_block_addr=%d\n",
399 block_address);
400
401 if (block_address < 0xffff) {
402 unsigned long sect_no;
403
404 sect_no = (unsigned long)block_address * sectors_per_block +
405 offset;
406
407 DEBUG(MTD_DEBUG_LEVEL3,
408 "SSFDC_RO: ssfdcr_readsect() phys_sect_no=%lu\n",
409 sect_no);
410
411 if (read_physical_sector( ssfdc->mbd.mtd, buf, sect_no ) < 0)
412 return -EIO;
413 } else {
414 memset(buf, 0xff, SECTOR_SIZE);
415 }
416
417 return 0;
418}
419
420static int ssfdcr_getgeo(struct mtd_blktrans_dev *dev, struct hd_geometry *geo)
421{
422 struct ssfdcr_record *ssfdc = (struct ssfdcr_record *)dev;
423
424 DEBUG(MTD_DEBUG_LEVEL1, "SSFDC_RO: ssfdcr_getgeo() C=%d, H=%d, S=%d\n",
425 ssfdc->cylinders, ssfdc->heads, ssfdc->sectors);
426
427 geo->heads = ssfdc->heads;
428 geo->sectors = ssfdc->sectors;
429 geo->cylinders = ssfdc->cylinders;
430
431 return 0;
432}
433
434/****************************************************************************
435 *
436 * Module stuff
437 *
438 ****************************************************************************/
439
440static struct mtd_blktrans_ops ssfdcr_tr = {
441 .name = "ssfdc",
442 .major = SSFDCR_MAJOR,
443 .part_bits = SSFDCR_PARTN_BITS,
444 .getgeo = ssfdcr_getgeo,
445 .readsect = ssfdcr_readsect,
446 .add_mtd = ssfdcr_add_mtd,
447 .remove_dev = ssfdcr_remove_dev,
448 .owner = THIS_MODULE,
449};
450
451static int __init init_ssfdcr(void)
452{
453 printk(KERN_INFO "SSFDC read-only Flash Translation layer\n");
454
455 return register_mtd_blktrans(&ssfdcr_tr);
456}
457
458static void __exit cleanup_ssfdcr(void)
459{
460 deregister_mtd_blktrans(&ssfdcr_tr);
461}
462
463module_init(init_ssfdcr);
464module_exit(cleanup_ssfdcr);
465
466MODULE_LICENSE("GPL");
467MODULE_AUTHOR("Claudio Lanconelli <lanconelli.claudio@eptar.com>");
468MODULE_DESCRIPTION("Flash Translation Layer for read-only SSFDC SmartMedia card");
diff --git a/drivers/net/bmac.c b/drivers/net/bmac.c
index 6fad83f24c4f..711609665632 100644
--- a/drivers/net/bmac.c
+++ b/drivers/net/bmac.c
@@ -1264,7 +1264,8 @@ static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_i
1264{ 1264{
1265 int j, rev, ret; 1265 int j, rev, ret;
1266 struct bmac_data *bp; 1266 struct bmac_data *bp;
1267 unsigned char *addr; 1267 const unsigned char *prop_addr;
1268 unsigned char addr[6];
1268 struct net_device *dev; 1269 struct net_device *dev;
1269 int is_bmac_plus = ((int)match->data) != 0; 1270 int is_bmac_plus = ((int)match->data) != 0;
1270 1271
@@ -1272,14 +1273,16 @@ static int __devinit bmac_probe(struct macio_dev *mdev, const struct of_device_i
1272 printk(KERN_ERR "BMAC: can't use, need 3 addrs and 3 intrs\n"); 1273 printk(KERN_ERR "BMAC: can't use, need 3 addrs and 3 intrs\n");
1273 return -ENODEV; 1274 return -ENODEV;
1274 } 1275 }
1275 addr = get_property(macio_get_of_node(mdev), "mac-address", NULL); 1276 prop_addr = get_property(macio_get_of_node(mdev), "mac-address", NULL);
1276 if (addr == NULL) { 1277 if (prop_addr == NULL) {
1277 addr = get_property(macio_get_of_node(mdev), "local-mac-address", NULL); 1278 prop_addr = get_property(macio_get_of_node(mdev),
1278 if (addr == NULL) { 1279 "local-mac-address", NULL);
1280 if (prop_addr == NULL) {
1279 printk(KERN_ERR "BMAC: Can't get mac-address\n"); 1281 printk(KERN_ERR "BMAC: Can't get mac-address\n");
1280 return -ENODEV; 1282 return -ENODEV;
1281 } 1283 }
1282 } 1284 }
1285 memcpy(addr, prop_addr, sizeof(addr));
1283 1286
1284 dev = alloc_etherdev(PRIV_BYTES); 1287 dev = alloc_etherdev(PRIV_BYTES);
1285 if (!dev) { 1288 if (!dev) {
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 0464e78f733a..e56eac88b809 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -702,7 +702,8 @@ static int ibmveth_start_xmit(struct sk_buff *skb, struct net_device *netdev)
702 desc[3].desc, 702 desc[3].desc,
703 desc[4].desc, 703 desc[4].desc,
704 desc[5].desc, 704 desc[5].desc,
705 correlator); 705 correlator,
706 &correlator);
706 } while ((lpar_rc == H_BUSY) && (retry_count--)); 707 } while ((lpar_rc == H_BUSY) && (retry_count--));
707 708
708 if(lpar_rc != H_SUCCESS && lpar_rc != H_DROPPED) { 709 if(lpar_rc != H_SUCCESS && lpar_rc != H_DROPPED) {
diff --git a/drivers/net/ibmveth.h b/drivers/net/ibmveth.h
index 8385bf836507..f5b25bff1540 100644
--- a/drivers/net/ibmveth.h
+++ b/drivers/net/ibmveth.h
@@ -41,16 +41,6 @@
41#define IbmVethMcastRemoveFilter 0x2UL 41#define IbmVethMcastRemoveFilter 0x2UL
42#define IbmVethMcastClearFilterTable 0x3UL 42#define IbmVethMcastClearFilterTable 0x3UL
43 43
44/* hcall numbers */
45#define H_VIO_SIGNAL 0x104
46#define H_REGISTER_LOGICAL_LAN 0x114
47#define H_FREE_LOGICAL_LAN 0x118
48#define H_ADD_LOGICAL_LAN_BUFFER 0x11C
49#define H_SEND_LOGICAL_LAN 0x120
50#define H_MULTICAST_CTRL 0x130
51#define H_CHANGE_LOGICAL_LAN_MAC 0x14C
52#define H_FREE_LOGICAL_LAN_BUFFER 0x1D4
53
54/* hcall macros */ 44/* hcall macros */
55#define h_register_logical_lan(ua, buflst, rxq, fltlst, mac) \ 45#define h_register_logical_lan(ua, buflst, rxq, fltlst, mac) \
56 plpar_hcall_norets(H_REGISTER_LOGICAL_LAN, ua, buflst, rxq, fltlst, mac) 46 plpar_hcall_norets(H_REGISTER_LOGICAL_LAN, ua, buflst, rxq, fltlst, mac)
@@ -61,8 +51,21 @@
61#define h_add_logical_lan_buffer(ua, buf) \ 51#define h_add_logical_lan_buffer(ua, buf) \
62 plpar_hcall_norets(H_ADD_LOGICAL_LAN_BUFFER, ua, buf) 52 plpar_hcall_norets(H_ADD_LOGICAL_LAN_BUFFER, ua, buf)
63 53
64#define h_send_logical_lan(ua, buf1, buf2, buf3, buf4, buf5, buf6, correlator) \ 54static inline long h_send_logical_lan(unsigned long unit_address,
65 plpar_hcall_8arg_2ret(H_SEND_LOGICAL_LAN, ua, buf1, buf2, buf3, buf4, buf5, buf6, correlator, &correlator) 55 unsigned long desc1, unsigned long desc2, unsigned long desc3,
56 unsigned long desc4, unsigned long desc5, unsigned long desc6,
57 unsigned long corellator_in, unsigned long *corellator_out)
58{
59 long rc;
60 unsigned long retbuf[PLPAR_HCALL9_BUFSIZE];
61
62 rc = plpar_hcall9(H_SEND_LOGICAL_LAN, retbuf, unit_address, desc1,
63 desc2, desc3, desc4, desc5, desc6, corellator_in);
64
65 *corellator_out = retbuf[0];
66
67 return rc;
68}
66 69
67#define h_multicast_ctrl(ua, cmd, mac) \ 70#define h_multicast_ctrl(ua, cmd, mac) \
68 plpar_hcall_norets(H_MULTICAST_CTRL, ua, cmd, mac) 71 plpar_hcall_norets(H_MULTICAST_CTRL, ua, cmd, mac)
diff --git a/drivers/net/mace.c b/drivers/net/mace.c
index 29e4b5aa6ead..5d80e0e6a8e9 100644
--- a/drivers/net/mace.c
+++ b/drivers/net/mace.c
@@ -113,7 +113,7 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i
113 struct device_node *mace = macio_get_of_node(mdev); 113 struct device_node *mace = macio_get_of_node(mdev);
114 struct net_device *dev; 114 struct net_device *dev;
115 struct mace_data *mp; 115 struct mace_data *mp;
116 unsigned char *addr; 116 const unsigned char *addr;
117 int j, rev, rc = -EBUSY; 117 int j, rev, rc = -EBUSY;
118 118
119 if (macio_resource_count(mdev) != 3 || macio_irq_count(mdev) != 3) { 119 if (macio_resource_count(mdev) != 3 || macio_irq_count(mdev) != 3) {
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index 88907218457a..d64e718afbd2 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -1697,10 +1697,10 @@ spider_net_setup_phy(struct spider_net_card *card)
1697 */ 1697 */
1698static int 1698static int
1699spider_net_download_firmware(struct spider_net_card *card, 1699spider_net_download_firmware(struct spider_net_card *card,
1700 u8 *firmware_ptr) 1700 const void *firmware_ptr)
1701{ 1701{
1702 int sequencer, i; 1702 int sequencer, i;
1703 u32 *fw_ptr = (u32 *)firmware_ptr; 1703 const u32 *fw_ptr = firmware_ptr;
1704 1704
1705 /* stop sequencers */ 1705 /* stop sequencers */
1706 spider_net_write_reg(card, SPIDER_NET_GSINIT, 1706 spider_net_write_reg(card, SPIDER_NET_GSINIT,
@@ -1757,7 +1757,7 @@ spider_net_init_firmware(struct spider_net_card *card)
1757{ 1757{
1758 struct firmware *firmware = NULL; 1758 struct firmware *firmware = NULL;
1759 struct device_node *dn; 1759 struct device_node *dn;
1760 u8 *fw_prop = NULL; 1760 const u8 *fw_prop = NULL;
1761 int err = -ENOENT; 1761 int err = -ENOENT;
1762 int fw_size; 1762 int fw_size;
1763 1763
@@ -1783,7 +1783,7 @@ try_host_fw:
1783 if (!dn) 1783 if (!dn)
1784 goto out_err; 1784 goto out_err;
1785 1785
1786 fw_prop = (u8 *)get_property(dn, "firmware", &fw_size); 1786 fw_prop = get_property(dn, "firmware", &fw_size);
1787 if (!fw_prop) 1787 if (!fw_prop)
1788 goto out_err; 1788 goto out_err;
1789 1789
@@ -1986,7 +1986,7 @@ spider_net_setup_netdev(struct spider_net_card *card)
1986 struct net_device *netdev = card->netdev; 1986 struct net_device *netdev = card->netdev;
1987 struct device_node *dn; 1987 struct device_node *dn;
1988 struct sockaddr addr; 1988 struct sockaddr addr;
1989 u8 *mac; 1989 const u8 *mac;
1990 1990
1991 SET_MODULE_OWNER(netdev); 1991 SET_MODULE_OWNER(netdev);
1992 SET_NETDEV_DEV(netdev, &card->pdev->dev); 1992 SET_NETDEV_DEV(netdev, &card->pdev->dev);
@@ -2019,7 +2019,7 @@ spider_net_setup_netdev(struct spider_net_card *card)
2019 if (!dn) 2019 if (!dn)
2020 return -EIO; 2020 return -EIO;
2021 2021
2022 mac = (u8 *)get_property(dn, "local-mac-address", NULL); 2022 mac = get_property(dn, "local-mac-address", NULL);
2023 if (!mac) 2023 if (!mac)
2024 return -EIO; 2024 return -EIO;
2025 memcpy(addr.sa_data, mac, ETH_ALEN); 2025 memcpy(addr.sa_data, mac, ETH_ALEN);
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index b70bbd748978..d7b1d1882cab 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -2896,7 +2896,7 @@ static int __devinit gem_get_device_address(struct gem *gp)
2896 if (use_idprom) 2896 if (use_idprom)
2897 memcpy(dev->dev_addr, idprom->id_ethaddr, 6); 2897 memcpy(dev->dev_addr, idprom->id_ethaddr, 6);
2898#elif defined(CONFIG_PPC_PMAC) 2898#elif defined(CONFIG_PPC_PMAC)
2899 unsigned char *addr; 2899 const unsigned char *addr;
2900 2900
2901 addr = get_property(gp->of_node, "local-mac-address", NULL); 2901 addr = get_property(gp->of_node, "local-mac-address", NULL);
2902 if (addr == NULL) { 2902 if (addr == NULL) {
diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c
index 076bd6dcafae..7288a3eccfb3 100644
--- a/drivers/pci/hotplug/rpaphp_core.c
+++ b/drivers/pci/hotplug/rpaphp_core.c
@@ -176,16 +176,16 @@ static int get_max_bus_speed(struct hotplug_slot *hotplug_slot, enum pci_bus_spe
176 return 0; 176 return 0;
177} 177}
178 178
179static int get_children_props(struct device_node *dn, int **drc_indexes, 179static int get_children_props(struct device_node *dn, const int **drc_indexes,
180 int **drc_names, int **drc_types, int **drc_power_domains) 180 const int **drc_names, const int **drc_types,
181 const int **drc_power_domains)
181{ 182{
182 int *indexes, *names; 183 const int *indexes, *names, *types, *domains;
183 int *types, *domains;
184 184
185 indexes = (int *) get_property(dn, "ibm,drc-indexes", NULL); 185 indexes = get_property(dn, "ibm,drc-indexes", NULL);
186 names = (int *) get_property(dn, "ibm,drc-names", NULL); 186 names = get_property(dn, "ibm,drc-names", NULL);
187 types = (int *) get_property(dn, "ibm,drc-types", NULL); 187 types = get_property(dn, "ibm,drc-types", NULL);
188 domains = (int *) get_property(dn, "ibm,drc-power-domains", NULL); 188 domains = get_property(dn, "ibm,drc-power-domains", NULL);
189 189
190 if (!indexes || !names || !types || !domains) { 190 if (!indexes || !names || !types || !domains) {
191 /* Slot does not have dynamically-removable children */ 191 /* Slot does not have dynamically-removable children */
@@ -212,13 +212,13 @@ static int get_children_props(struct device_node *dn, int **drc_indexes,
212int rpaphp_get_drc_props(struct device_node *dn, int *drc_index, 212int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
213 char **drc_name, char **drc_type, int *drc_power_domain) 213 char **drc_name, char **drc_type, int *drc_power_domain)
214{ 214{
215 int *indexes, *names; 215 const int *indexes, *names;
216 int *types, *domains; 216 const int *types, *domains;
217 unsigned int *my_index; 217 const unsigned int *my_index;
218 char *name_tmp, *type_tmp; 218 char *name_tmp, *type_tmp;
219 int i, rc; 219 int i, rc;
220 220
221 my_index = (int *) get_property(dn, "ibm,my-drc-index", NULL); 221 my_index = get_property(dn, "ibm,my-drc-index", NULL);
222 if (!my_index) { 222 if (!my_index) {
223 /* Node isn't DLPAR/hotplug capable */ 223 /* Node isn't DLPAR/hotplug capable */
224 return -EINVAL; 224 return -EINVAL;
@@ -265,10 +265,10 @@ static int is_php_type(char *drc_type)
265 return 1; 265 return 1;
266} 266}
267 267
268static int is_php_dn(struct device_node *dn, int **indexes, int **names, 268static int is_php_dn(struct device_node *dn, const int **indexes,
269 int **types, int **power_domains) 269 const int **names, const int **types, const int **power_domains)
270{ 270{
271 int *drc_types; 271 const int *drc_types;
272 int rc; 272 int rc;
273 273
274 rc = get_children_props(dn, indexes, names, &drc_types, power_domains); 274 rc = get_children_props(dn, indexes, names, &drc_types, power_domains);
@@ -296,7 +296,7 @@ int rpaphp_add_slot(struct device_node *dn)
296 struct slot *slot; 296 struct slot *slot;
297 int retval = 0; 297 int retval = 0;
298 int i; 298 int i;
299 int *indexes, *names, *types, *power_domains; 299 const int *indexes, *names, *types, *power_domains;
300 char *name, *type; 300 char *name, *type;
301 301
302 dbg("Entry %s: dn->full_name=%s\n", __FUNCTION__, dn->full_name); 302 dbg("Entry %s: dn->full_name=%s\n", __FUNCTION__, dn->full_name);
diff --git a/drivers/scsi/ibmvscsi/rpa_vscsi.c b/drivers/scsi/ibmvscsi/rpa_vscsi.c
index ed22b96580c6..01b8ac641eb8 100644
--- a/drivers/scsi/ibmvscsi/rpa_vscsi.c
+++ b/drivers/scsi/ibmvscsi/rpa_vscsi.c
@@ -156,8 +156,8 @@ static void gather_partition_info(void)
156{ 156{
157 struct device_node *rootdn; 157 struct device_node *rootdn;
158 158
159 char *ppartition_name; 159 const char *ppartition_name;
160 unsigned int *p_number_ptr; 160 const unsigned int *p_number_ptr;
161 161
162 /* Retrieve information about this partition */ 162 /* Retrieve information about this partition */
163 rootdn = find_path_device("/"); 163 rootdn = find_path_device("/");
@@ -165,14 +165,11 @@ static void gather_partition_info(void)
165 return; 165 return;
166 } 166 }
167 167
168 ppartition_name = 168 ppartition_name = get_property(rootdn, "ibm,partition-name", NULL);
169 get_property(rootdn, "ibm,partition-name", NULL);
170 if (ppartition_name) 169 if (ppartition_name)
171 strncpy(partition_name, ppartition_name, 170 strncpy(partition_name, ppartition_name,
172 sizeof(partition_name)); 171 sizeof(partition_name));
173 p_number_ptr = 172 p_number_ptr = get_property(rootdn, "ibm,partition-no", NULL);
174 (unsigned int *)get_property(rootdn, "ibm,partition-no",
175 NULL);
176 if (p_number_ptr) 173 if (p_number_ptr)
177 partition_number = *p_number_ptr; 174 partition_number = *p_number_ptr;
178} 175}
diff --git a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c
index 89ef34df5a1d..6422de72bf43 100644
--- a/drivers/scsi/mac53c94.c
+++ b/drivers/scsi/mac53c94.c
@@ -431,7 +431,7 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *mat
431 struct fsc_state *state; 431 struct fsc_state *state;
432 struct Scsi_Host *host; 432 struct Scsi_Host *host;
433 void *dma_cmd_space; 433 void *dma_cmd_space;
434 unsigned char *clkprop; 434 const unsigned char *clkprop;
435 int proplen, rc = -ENODEV; 435 int proplen, rc = -ENODEV;
436 436
437 if (macio_resource_count(mdev) != 2 || macio_irq_count(mdev) != 2) { 437 if (macio_resource_count(mdev) != 2 || macio_irq_count(mdev) != 2) {
diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c
index 5572981a9f92..592b52afe658 100644
--- a/drivers/scsi/mesh.c
+++ b/drivers/scsi/mesh.c
@@ -1850,7 +1850,8 @@ static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match)
1850{ 1850{
1851 struct device_node *mesh = macio_get_of_node(mdev); 1851 struct device_node *mesh = macio_get_of_node(mdev);
1852 struct pci_dev* pdev = macio_get_pci_dev(mdev); 1852 struct pci_dev* pdev = macio_get_pci_dev(mdev);
1853 int tgt, *cfp, minper; 1853 int tgt, minper;
1854 const int *cfp;
1854 struct mesh_state *ms; 1855 struct mesh_state *ms;
1855 struct Scsi_Host *mesh_host; 1856 struct Scsi_Host *mesh_host;
1856 void *dma_cmd_space; 1857 void *dma_cmd_space;
@@ -1939,7 +1940,7 @@ static int mesh_probe(struct macio_dev *mdev, const struct of_device_id *match)
1939 ms->tgts[tgt].current_req = NULL; 1940 ms->tgts[tgt].current_req = NULL;
1940 } 1941 }
1941 1942
1942 if ((cfp = (int *) get_property(mesh, "clock-frequency", NULL))) 1943 if ((cfp = get_property(mesh, "clock-frequency", NULL)))
1943 ms->clk_freq = *cfp; 1944 ms->clk_freq = *cfp;
1944 else { 1945 else {
1945 printk(KERN_INFO "mesh: assuming 50MHz clock frequency\n"); 1946 printk(KERN_INFO "mesh: assuming 50MHz clock frequency\n");
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index 7d0858095e1f..6b70c3c76dfd 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -268,7 +268,7 @@ static int k2_sata_proc_info(struct Scsi_Host *shost, char *page, char **start,
268 /* Match it to a port node */ 268 /* Match it to a port node */
269 index = (ap == ap->host_set->ports[0]) ? 0 : 1; 269 index = (ap == ap->host_set->ports[0]) ? 0 : 1;
270 for (np = np->child; np != NULL; np = np->sibling) { 270 for (np = np->child; np != NULL; np = np->sibling) {
271 u32 *reg = (u32 *)get_property(np, "reg", NULL); 271 const u32 *reg = get_property(np, "reg", NULL);
272 if (!reg) 272 if (!reg)
273 continue; 273 continue;
274 if (index == *reg) 274 if (index == *reg)
diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c
index bfd2a22759eb..a3b99caf80e6 100644
--- a/drivers/serial/pmac_zilog.c
+++ b/drivers/serial/pmac_zilog.c
@@ -1400,8 +1400,8 @@ static struct uart_ops pmz_pops = {
1400static int __init pmz_init_port(struct uart_pmac_port *uap) 1400static int __init pmz_init_port(struct uart_pmac_port *uap)
1401{ 1401{
1402 struct device_node *np = uap->node; 1402 struct device_node *np = uap->node;
1403 char *conn; 1403 const char *conn;
1404 struct slot_names_prop { 1404 const struct slot_names_prop {
1405 int count; 1405 int count;
1406 char name[1]; 1406 char name[1];
1407 } *slots; 1407 } *slots;
@@ -1458,7 +1458,7 @@ no_dma:
1458 uap->flags |= PMACZILOG_FLAG_IS_IRDA; 1458 uap->flags |= PMACZILOG_FLAG_IS_IRDA;
1459 uap->port_type = PMAC_SCC_ASYNC; 1459 uap->port_type = PMAC_SCC_ASYNC;
1460 /* 1999 Powerbook G3 has slot-names property instead */ 1460 /* 1999 Powerbook G3 has slot-names property instead */
1461 slots = (struct slot_names_prop *)get_property(np, "slot-names", &len); 1461 slots = get_property(np, "slot-names", &len);
1462 if (slots && slots->count > 0) { 1462 if (slots && slots->count > 0) {
1463 if (strcmp(slots->name, "IrDA") == 0) 1463 if (strcmp(slots->name, "IrDA") == 0)
1464 uap->flags |= PMACZILOG_FLAG_IS_IRDA; 1464 uap->flags |= PMACZILOG_FLAG_IS_IRDA;
@@ -1470,7 +1470,8 @@ no_dma:
1470 if (ZS_IS_INTMODEM(uap)) { 1470 if (ZS_IS_INTMODEM(uap)) {
1471 struct device_node* i2c_modem = find_devices("i2c-modem"); 1471 struct device_node* i2c_modem = find_devices("i2c-modem");
1472 if (i2c_modem) { 1472 if (i2c_modem) {
1473 char* mid = get_property(i2c_modem, "modem-id", NULL); 1473 const char* mid =
1474 get_property(i2c_modem, "modem-id", NULL);
1474 if (mid) switch(*mid) { 1475 if (mid) switch(*mid) {
1475 case 0x04 : 1476 case 0x04 :
1476 case 0x05 : 1477 case 0x05 :
diff --git a/drivers/video/S3triofb.c b/drivers/video/S3triofb.c
index afd146f5f683..397005eb392d 100644
--- a/drivers/video/S3triofb.c
+++ b/drivers/video/S3triofb.c
@@ -349,30 +349,30 @@ static void __init s3triofb_of_init(struct device_node *dp)
349 s3trio_name[sizeof(s3trio_name)-1] = '\0'; 349 s3trio_name[sizeof(s3trio_name)-1] = '\0';
350 strcpy(fb_fix.id, s3trio_name); 350 strcpy(fb_fix.id, s3trio_name);
351 351
352 if((pp = (int *)get_property(dp, "vendor-id", &len)) != NULL 352 if((pp = get_property(dp, "vendor-id", &len)) != NULL
353 && *pp!=PCI_VENDOR_ID_S3) { 353 && *pp!=PCI_VENDOR_ID_S3) {
354 printk("%s: can't find S3 Trio board\n", dp->full_name); 354 printk("%s: can't find S3 Trio board\n", dp->full_name);
355 return; 355 return;
356 } 356 }
357 357
358 if((pp = (int *)get_property(dp, "device-id", &len)) != NULL 358 if((pp = get_property(dp, "device-id", &len)) != NULL
359 && *pp!=PCI_DEVICE_ID_S3_TRIO) { 359 && *pp!=PCI_DEVICE_ID_S3_TRIO) {
360 printk("%s: can't find S3 Trio board\n", dp->full_name); 360 printk("%s: can't find S3 Trio board\n", dp->full_name);
361 return; 361 return;
362 } 362 }
363 363
364 if ((pp = (int *)get_property(dp, "depth", &len)) != NULL 364 if ((pp = get_property(dp, "depth", &len)) != NULL
365 && len == sizeof(int) && *pp != 8) { 365 && len == sizeof(int) && *pp != 8) {
366 printk("%s: can't use depth = %d\n", dp->full_name, *pp); 366 printk("%s: can't use depth = %d\n", dp->full_name, *pp);
367 return; 367 return;
368 } 368 }
369 if ((pp = (int *)get_property(dp, "width", &len)) != NULL 369 if ((pp = get_property(dp, "width", &len)) != NULL
370 && len == sizeof(int)) 370 && len == sizeof(int))
371 fb_var.xres = fb_var.xres_virtual = *pp; 371 fb_var.xres = fb_var.xres_virtual = *pp;
372 if ((pp = (int *)get_property(dp, "height", &len)) != NULL 372 if ((pp = get_property(dp, "height", &len)) != NULL
373 && len == sizeof(int)) 373 && len == sizeof(int))
374 fb_var.yres = fb_var.yres_virtual = *pp; 374 fb_var.yres = fb_var.yres_virtual = *pp;
375 if ((pp = (int *)get_property(dp, "linebytes", &len)) != NULL 375 if ((pp = get_property(dp, "linebytes", &len)) != NULL
376 && len == sizeof(int)) 376 && len == sizeof(int))
377 fb_fix.line_length = *pp; 377 fb_fix.line_length = *pp;
378 else 378 else
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c
index 8e3400d5dd21..0ed577e7cc21 100644
--- a/drivers/video/aty/radeon_base.c
+++ b/drivers/video/aty/radeon_base.c
@@ -413,11 +413,11 @@ static int __devinit radeon_find_mem_vbios(struct radeonfb_info *rinfo)
413static int __devinit radeon_read_xtal_OF (struct radeonfb_info *rinfo) 413static int __devinit radeon_read_xtal_OF (struct radeonfb_info *rinfo)
414{ 414{
415 struct device_node *dp = rinfo->of_node; 415 struct device_node *dp = rinfo->of_node;
416 u32 *val; 416 const u32 *val;
417 417
418 if (dp == NULL) 418 if (dp == NULL)
419 return -ENODEV; 419 return -ENODEV;
420 val = (u32 *) get_property(dp, "ATY,RefCLK", NULL); 420 val = get_property(dp, "ATY,RefCLK", NULL);
421 if (!val || !*val) { 421 if (!val || !*val) {
422 printk(KERN_WARNING "radeonfb: No ATY,RefCLK property !\n"); 422 printk(KERN_WARNING "radeonfb: No ATY,RefCLK property !\n");
423 return -EINVAL; 423 return -EINVAL;
@@ -425,11 +425,11 @@ static int __devinit radeon_read_xtal_OF (struct radeonfb_info *rinfo)
425 425
426 rinfo->pll.ref_clk = (*val) / 10; 426 rinfo->pll.ref_clk = (*val) / 10;
427 427
428 val = (u32 *) get_property(dp, "ATY,SCLK", NULL); 428 val = get_property(dp, "ATY,SCLK", NULL);
429 if (val && *val) 429 if (val && *val)
430 rinfo->pll.sclk = (*val) / 10; 430 rinfo->pll.sclk = (*val) / 10;
431 431
432 val = (u32 *) get_property(dp, "ATY,MCLK", NULL); 432 val = get_property(dp, "ATY,MCLK", NULL);
433 if (val && *val) 433 if (val && *val)
434 rinfo->pll.mclk = (*val) / 10; 434 rinfo->pll.mclk = (*val) / 10;
435 435
diff --git a/drivers/video/aty/radeon_monitor.c b/drivers/video/aty/radeon_monitor.c
index 98c05bc0de44..ea531a6f45d1 100644
--- a/drivers/video/aty/radeon_monitor.c
+++ b/drivers/video/aty/radeon_monitor.c
@@ -64,13 +64,13 @@ static int __devinit radeon_parse_montype_prop(struct device_node *dp, u8 **out_
64{ 64{
65 static char *propnames[] = { "DFP,EDID", "LCD,EDID", "EDID", 65 static char *propnames[] = { "DFP,EDID", "LCD,EDID", "EDID",
66 "EDID1", "EDID2", NULL }; 66 "EDID1", "EDID2", NULL };
67 u8 *pedid = NULL; 67 const u8 *pedid = NULL;
68 u8 *pmt = NULL; 68 const u8 *pmt = NULL;
69 u8 *tmp; 69 u8 *tmp;
70 int i, mt = MT_NONE; 70 int i, mt = MT_NONE;
71 71
72 RTRACE("analyzing OF properties...\n"); 72 RTRACE("analyzing OF properties...\n");
73 pmt = (u8 *)get_property(dp, "display-type", NULL); 73 pmt = get_property(dp, "display-type", NULL);
74 if (!pmt) 74 if (!pmt)
75 return MT_NONE; 75 return MT_NONE;
76 RTRACE("display-type: %s\n", pmt); 76 RTRACE("display-type: %s\n", pmt);
@@ -89,7 +89,7 @@ static int __devinit radeon_parse_montype_prop(struct device_node *dp, u8 **out_
89 } 89 }
90 90
91 for (i = 0; propnames[i] != NULL; ++i) { 91 for (i = 0; propnames[i] != NULL; ++i) {
92 pedid = (u8 *)get_property(dp, propnames[i], NULL); 92 pedid = get_property(dp, propnames[i], NULL);
93 if (pedid != NULL) 93 if (pedid != NULL)
94 break; 94 break;
95 } 95 }
@@ -124,14 +124,14 @@ static int __devinit radeon_probe_OF_head(struct radeonfb_info *rinfo, int head_
124 return MT_NONE; 124 return MT_NONE;
125 125
126 if (rinfo->has_CRTC2) { 126 if (rinfo->has_CRTC2) {
127 char *pname; 127 const char *pname;
128 int len, second = 0; 128 int len, second = 0;
129 129
130 dp = dp->child; 130 dp = dp->child;
131 do { 131 do {
132 if (!dp) 132 if (!dp)
133 return MT_NONE; 133 return MT_NONE;
134 pname = (char *)get_property(dp, "name", NULL); 134 pname = get_property(dp, "name", NULL);
135 if (!pname) 135 if (!pname)
136 return MT_NONE; 136 return MT_NONE;
137 len = strlen(pname); 137 len = strlen(pname);
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index f31e606a2ded..e308ed2d249a 100644
--- a/drivers/video/aty/radeon_pm.c
+++ b/drivers/video/aty/radeon_pm.c
@@ -1268,7 +1268,7 @@ static void radeon_pm_full_reset_sdram(struct radeonfb_info *rinfo)
1268 0x21320032, 0xa1320032, 0x21320032, 0xffffffff, 1268 0x21320032, 0xa1320032, 0x21320032, 0xffffffff,
1269 0x31320032 }; 1269 0x31320032 };
1270 1270
1271 u32 *mrtable = default_mrtable; 1271 const u32 *mrtable = default_mrtable;
1272 int i, mrtable_size = ARRAY_SIZE(default_mrtable); 1272 int i, mrtable_size = ARRAY_SIZE(default_mrtable);
1273 1273
1274 mdelay(30); 1274 mdelay(30);
@@ -1287,7 +1287,7 @@ static void radeon_pm_full_reset_sdram(struct radeonfb_info *rinfo)
1287 if (rinfo->of_node != NULL) { 1287 if (rinfo->of_node != NULL) {
1288 int size; 1288 int size;
1289 1289
1290 mrtable = (u32 *)get_property(rinfo->of_node, "ATY,MRT", &size); 1290 mrtable = get_property(rinfo->of_node, "ATY,MRT", &size);
1291 if (mrtable) 1291 if (mrtable)
1292 mrtable_size = size >> 2; 1292 mrtable_size = size >> 2;
1293 else 1293 else
diff --git a/drivers/video/nvidia/nv_of.c b/drivers/video/nvidia/nv_of.c
index 8209106e26ee..d9af88c2b580 100644
--- a/drivers/video/nvidia/nv_of.c
+++ b/drivers/video/nvidia/nv_of.c
@@ -32,7 +32,7 @@ int nvidia_probe_of_connector(struct fb_info *info, int conn, u8 **out_edid)
32{ 32{
33 struct nvidia_par *par = info->par; 33 struct nvidia_par *par = info->par;
34 struct device_node *parent, *dp; 34 struct device_node *parent, *dp;
35 unsigned char *pedid = NULL; 35 const unsigned char *pedid = NULL;
36 static char *propnames[] = { 36 static char *propnames[] = {
37 "DFP,EDID", "LCD,EDID", "EDID", "EDID1", 37 "DFP,EDID", "LCD,EDID", "EDID", "EDID1",
38 "EDID,B", "EDID,A", NULL }; 38 "EDID,B", "EDID,A", NULL };
@@ -42,20 +42,19 @@ int nvidia_probe_of_connector(struct fb_info *info, int conn, u8 **out_edid)
42 if (parent == NULL) 42 if (parent == NULL)
43 return -1; 43 return -1;
44 if (par->twoHeads) { 44 if (par->twoHeads) {
45 char *pname; 45 const char *pname;
46 int len; 46 int len;
47 47
48 for (dp = NULL; 48 for (dp = NULL;
49 (dp = of_get_next_child(parent, dp)) != NULL;) { 49 (dp = of_get_next_child(parent, dp)) != NULL;) {
50 pname = (char *)get_property(dp, "name", NULL); 50 pname = get_property(dp, "name", NULL);
51 if (!pname) 51 if (!pname)
52 continue; 52 continue;
53 len = strlen(pname); 53 len = strlen(pname);
54 if ((pname[len-1] == 'A' && conn == 1) || 54 if ((pname[len-1] == 'A' && conn == 1) ||
55 (pname[len-1] == 'B' && conn == 2)) { 55 (pname[len-1] == 'B' && conn == 2)) {
56 for (i = 0; propnames[i] != NULL; ++i) { 56 for (i = 0; propnames[i] != NULL; ++i) {
57 pedid = (unsigned char *) 57 pedid = get_property(dp, propnames[i],
58 get_property(dp, propnames[i],
59 NULL); 58 NULL);
60 if (pedid != NULL) 59 if (pedid != NULL)
61 break; 60 break;
@@ -67,8 +66,7 @@ int nvidia_probe_of_connector(struct fb_info *info, int conn, u8 **out_edid)
67 } 66 }
68 if (pedid == NULL) { 67 if (pedid == NULL) {
69 for (i = 0; propnames[i] != NULL; ++i) { 68 for (i = 0; propnames[i] != NULL; ++i) {
70 pedid = (unsigned char *) 69 pedid = get_property(parent, propnames[i], NULL);
71 get_property(parent, propnames[i], NULL);
72 if (pedid != NULL) 70 if (pedid != NULL)
73 break; 71 break;
74 } 72 }
diff --git a/drivers/video/offb.c b/drivers/video/offb.c
index 0013311e0564..bad0e98fb3b6 100644
--- a/drivers/video/offb.c
+++ b/drivers/video/offb.c
@@ -409,30 +409,30 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
409 unsigned int flags, rsize, addr_prop = 0; 409 unsigned int flags, rsize, addr_prop = 0;
410 unsigned long max_size = 0; 410 unsigned long max_size = 0;
411 u64 rstart, address = OF_BAD_ADDR; 411 u64 rstart, address = OF_BAD_ADDR;
412 u32 *pp, *addrp, *up; 412 const u32 *pp, *addrp, *up;
413 u64 asize; 413 u64 asize;
414 414
415 pp = (u32 *)get_property(dp, "linux,bootx-depth", &len); 415 pp = get_property(dp, "linux,bootx-depth", &len);
416 if (pp == NULL) 416 if (pp == NULL)
417 pp = (u32 *)get_property(dp, "depth", &len); 417 pp = get_property(dp, "depth", &len);
418 if (pp && len == sizeof(u32)) 418 if (pp && len == sizeof(u32))
419 depth = *pp; 419 depth = *pp;
420 420
421 pp = (u32 *)get_property(dp, "linux,bootx-width", &len); 421 pp = get_property(dp, "linux,bootx-width", &len);
422 if (pp == NULL) 422 if (pp == NULL)
423 pp = (u32 *)get_property(dp, "width", &len); 423 pp = get_property(dp, "width", &len);
424 if (pp && len == sizeof(u32)) 424 if (pp && len == sizeof(u32))
425 width = *pp; 425 width = *pp;
426 426
427 pp = (u32 *)get_property(dp, "linux,bootx-height", &len); 427 pp = get_property(dp, "linux,bootx-height", &len);
428 if (pp == NULL) 428 if (pp == NULL)
429 pp = (u32 *)get_property(dp, "height", &len); 429 pp = get_property(dp, "height", &len);
430 if (pp && len == sizeof(u32)) 430 if (pp && len == sizeof(u32))
431 height = *pp; 431 height = *pp;
432 432
433 pp = (u32 *)get_property(dp, "linux,bootx-linebytes", &len); 433 pp = get_property(dp, "linux,bootx-linebytes", &len);
434 if (pp == NULL) 434 if (pp == NULL)
435 pp = (u32 *)get_property(dp, "linebytes", &len); 435 pp = get_property(dp, "linebytes", &len);
436 if (pp && len == sizeof(u32)) 436 if (pp && len == sizeof(u32))
437 pitch = *pp; 437 pitch = *pp;
438 else 438 else
@@ -450,9 +450,9 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
450 * ranges and pick one that is both big enough and if possible encloses 450 * ranges and pick one that is both big enough and if possible encloses
451 * the "address" property. If none match, we pick the biggest 451 * the "address" property. If none match, we pick the biggest
452 */ 452 */
453 up = (u32 *)get_property(dp, "linux,bootx-addr", &len); 453 up = get_property(dp, "linux,bootx-addr", &len);
454 if (up == NULL) 454 if (up == NULL)
455 up = (u32 *)get_property(dp, "address", &len); 455 up = get_property(dp, "address", &len);
456 if (up && len == sizeof(u32)) 456 if (up && len == sizeof(u32))
457 addr_prop = *up; 457 addr_prop = *up;
458 458
diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c
index 8ddb47a56b07..67d1e1c8813d 100644
--- a/drivers/video/riva/fbdev.c
+++ b/drivers/video/riva/fbdev.c
@@ -1835,14 +1835,13 @@ static int __devinit riva_get_EDID_OF(struct fb_info *info, struct pci_dev *pd)
1835 NVTRACE_ENTER(); 1835 NVTRACE_ENTER();
1836 dp = pci_device_to_OF_node(pd); 1836 dp = pci_device_to_OF_node(pd);
1837 for (; dp != NULL; dp = dp->child) { 1837 for (; dp != NULL; dp = dp->child) {
1838 disptype = (unsigned char *)get_property(dp, "display-type", NULL); 1838 disptype = get_property(dp, "display-type", NULL);
1839 if (disptype == NULL) 1839 if (disptype == NULL)
1840 continue; 1840 continue;
1841 if (strncmp(disptype, "LCD", 3) != 0) 1841 if (strncmp(disptype, "LCD", 3) != 0)
1842 continue; 1842 continue;
1843 for (i = 0; propnames[i] != NULL; ++i) { 1843 for (i = 0; propnames[i] != NULL; ++i) {
1844 pedid = (unsigned char *) 1844 pedid = get_property(dp, propnames[i], NULL);
1845 get_property(dp, propnames[i], NULL);
1846 if (pedid != NULL) { 1845 if (pedid != NULL) {
1847 par->EDID = pedid; 1846 par->EDID = pedid;
1848 NVTRACE("LCD found.\n"); 1847 NVTRACE("LCD found.\n");
diff --git a/fs/jffs2/jffs2_fs_i.h b/fs/jffs2/jffs2_fs_i.h
index 2e0cc8e00b85..3a566077ac95 100644
--- a/fs/jffs2/jffs2_fs_i.h
+++ b/fs/jffs2/jffs2_fs_i.h
@@ -41,11 +41,7 @@ struct jffs2_inode_info {
41 41
42 uint16_t flags; 42 uint16_t flags;
43 uint8_t usercompr; 43 uint8_t usercompr;
44#if !defined (__ECOS)
45#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,2)
46 struct inode vfs_inode; 44 struct inode vfs_inode;
47#endif
48#endif
49#ifdef CONFIG_JFFS2_FS_POSIX_ACL 45#ifdef CONFIG_JFFS2_FS_POSIX_ACL
50 struct posix_acl *i_acl_access; 46 struct posix_acl *i_acl_access;
51 struct posix_acl *i_acl_default; 47 struct posix_acl *i_acl_default;
diff --git a/include/asm-powerpc/cputable.h b/include/asm-powerpc/cputable.h
index 1ba3c9983614..12707ab9dc98 100644
--- a/include/asm-powerpc/cputable.h
+++ b/include/asm-powerpc/cputable.h
@@ -23,6 +23,7 @@
23#define PPC_FEATURE_SMT 0x00004000 23#define PPC_FEATURE_SMT 0x00004000
24#define PPC_FEATURE_ICACHE_SNOOP 0x00002000 24#define PPC_FEATURE_ICACHE_SNOOP 0x00002000
25#define PPC_FEATURE_ARCH_2_05 0x00001000 25#define PPC_FEATURE_ARCH_2_05 0x00001000
26#define PPC_FEATURE_PA6T 0x00000800
26 27
27#define PPC_FEATURE_TRUE_LE 0x00000002 28#define PPC_FEATURE_TRUE_LE 0x00000002
28#define PPC_FEATURE_PPC_LE 0x00000001 29#define PPC_FEATURE_PPC_LE 0x00000001
@@ -36,6 +37,7 @@
36struct cpu_spec; 37struct cpu_spec;
37 38
38typedef void (*cpu_setup_t)(unsigned long offset, struct cpu_spec* spec); 39typedef void (*cpu_setup_t)(unsigned long offset, struct cpu_spec* spec);
40typedef void (*cpu_restore_t)(void);
39 41
40enum powerpc_oprofile_type { 42enum powerpc_oprofile_type {
41 PPC_OPROFILE_INVALID = 0, 43 PPC_OPROFILE_INVALID = 0,
@@ -65,6 +67,8 @@ struct cpu_spec {
65 * BHT, SPD, etc... from head.S before branching to identify_machine 67 * BHT, SPD, etc... from head.S before branching to identify_machine
66 */ 68 */
67 cpu_setup_t cpu_setup; 69 cpu_setup_t cpu_setup;
70 /* Used to restore cpu setup on secondary processors and at resume */
71 cpu_restore_t cpu_restore;
68 72
69 /* Used by oprofile userspace to select the right counters */ 73 /* Used by oprofile userspace to select the right counters */
70 char *oprofile_cpu_type; 74 char *oprofile_cpu_type;
@@ -145,7 +149,7 @@ extern void do_cpu_ftr_fixups(unsigned long offset);
145 149
146#define CPU_FTR_PPCAS_ARCH_V2_BASE (CPU_FTR_SLB | \ 150#define CPU_FTR_PPCAS_ARCH_V2_BASE (CPU_FTR_SLB | \
147 CPU_FTR_TLBIEL | CPU_FTR_NOEXECUTE | \ 151 CPU_FTR_TLBIEL | CPU_FTR_NOEXECUTE | \
148 CPU_FTR_NODSISRALIGN | CPU_FTR_CTRL) 152 CPU_FTR_NODSISRALIGN)
149 153
150/* iSeries doesn't support large pages */ 154/* iSeries doesn't support large pages */
151#ifdef CONFIG_PPC_ISERIES 155#ifdef CONFIG_PPC_ISERIES
@@ -310,24 +314,29 @@ extern void do_cpu_ftr_fixups(unsigned long offset);
310 CPU_FTR_HPTE_TABLE | CPU_FTR_IABR | \ 314 CPU_FTR_HPTE_TABLE | CPU_FTR_IABR | \
311 CPU_FTR_MMCRA | CPU_FTR_CTRL) 315 CPU_FTR_MMCRA | CPU_FTR_CTRL)
312#define CPU_FTRS_POWER4 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ 316#define CPU_FTRS_POWER4 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
313 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_MMCRA) 317 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
318 CPU_FTR_MMCRA)
314#define CPU_FTRS_PPC970 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ 319#define CPU_FTRS_PPC970 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
315 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | \ 320 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
316 CPU_FTR_ALTIVEC_COMP | CPU_FTR_CAN_NAP | CPU_FTR_MMCRA) 321 CPU_FTR_ALTIVEC_COMP | CPU_FTR_CAN_NAP | CPU_FTR_MMCRA)
317#define CPU_FTRS_POWER5 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ 322#define CPU_FTRS_POWER5 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
318 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | \ 323 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
319 CPU_FTR_MMCRA | CPU_FTR_SMT | \ 324 CPU_FTR_MMCRA | CPU_FTR_SMT | \
320 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | \ 325 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | \
321 CPU_FTR_PURR) 326 CPU_FTR_PURR)
322#define CPU_FTRS_POWER6 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ 327#define CPU_FTRS_POWER6 (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
323 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | \ 328 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
324 CPU_FTR_MMCRA | CPU_FTR_SMT | \ 329 CPU_FTR_MMCRA | CPU_FTR_SMT | \
325 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | \ 330 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | \
326 CPU_FTR_PURR | CPU_FTR_CI_LARGE_PAGE | CPU_FTR_REAL_LE) 331 CPU_FTR_PURR | CPU_FTR_CI_LARGE_PAGE | CPU_FTR_REAL_LE)
327#define CPU_FTRS_CELL (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ 332#define CPU_FTRS_CELL (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
328 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | \ 333 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
329 CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \ 334 CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \
330 CPU_FTR_CTRL | CPU_FTR_PAUSE_ZERO | CPU_FTR_CI_LARGE_PAGE) 335 CPU_FTR_PAUSE_ZERO | CPU_FTR_CI_LARGE_PAGE)
336#define CPU_FTRS_PA6T (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
337 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | \
338 CPU_FTR_ALTIVEC_COMP | CPU_FTR_CI_LARGE_PAGE | \
339 CPU_FTR_PURR | CPU_FTR_REAL_LE)
331#define CPU_FTRS_COMPATIBLE (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \ 340#define CPU_FTRS_COMPATIBLE (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB | \
332 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2) 341 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2)
333#endif 342#endif
@@ -336,7 +345,7 @@ extern void do_cpu_ftr_fixups(unsigned long offset);
336#define CPU_FTRS_POSSIBLE \ 345#define CPU_FTRS_POSSIBLE \
337 (CPU_FTRS_POWER3 | CPU_FTRS_RS64 | CPU_FTRS_POWER4 | \ 346 (CPU_FTRS_POWER3 | CPU_FTRS_RS64 | CPU_FTRS_POWER4 | \
338 CPU_FTRS_PPC970 | CPU_FTRS_POWER5 | CPU_FTRS_POWER6 | \ 347 CPU_FTRS_PPC970 | CPU_FTRS_POWER5 | CPU_FTRS_POWER6 | \
339 CPU_FTRS_CELL | CPU_FTR_CI_LARGE_PAGE) 348 CPU_FTRS_CELL | CPU_FTRS_PA6T)
340#else 349#else
341enum { 350enum {
342 CPU_FTRS_POSSIBLE = 351 CPU_FTRS_POSSIBLE =
@@ -375,7 +384,7 @@ enum {
375#define CPU_FTRS_ALWAYS \ 384#define CPU_FTRS_ALWAYS \
376 (CPU_FTRS_POWER3 & CPU_FTRS_RS64 & CPU_FTRS_POWER4 & \ 385 (CPU_FTRS_POWER3 & CPU_FTRS_RS64 & CPU_FTRS_POWER4 & \
377 CPU_FTRS_PPC970 & CPU_FTRS_POWER5 & CPU_FTRS_POWER6 & \ 386 CPU_FTRS_PPC970 & CPU_FTRS_POWER5 & CPU_FTRS_POWER6 & \
378 CPU_FTRS_CELL & CPU_FTRS_POSSIBLE) 387 CPU_FTRS_CELL & CPU_FTRS_PA6T & CPU_FTRS_POSSIBLE)
379#else 388#else
380enum { 389enum {
381 CPU_FTRS_ALWAYS = 390 CPU_FTRS_ALWAYS =
diff --git a/include/asm-powerpc/hvcall.h b/include/asm-powerpc/hvcall.h
index 0d3c4e85711a..257d1cecb8c9 100644
--- a/include/asm-powerpc/hvcall.h
+++ b/include/asm-powerpc/hvcall.h
@@ -164,9 +164,15 @@
164#define H_VIO_SIGNAL 0x104 164#define H_VIO_SIGNAL 0x104
165#define H_SEND_CRQ 0x108 165#define H_SEND_CRQ 0x108
166#define H_COPY_RDMA 0x110 166#define H_COPY_RDMA 0x110
167#define H_REGISTER_LOGICAL_LAN 0x114
168#define H_FREE_LOGICAL_LAN 0x118
169#define H_ADD_LOGICAL_LAN_BUFFER 0x11C
170#define H_SEND_LOGICAL_LAN 0x120
171#define H_MULTICAST_CTRL 0x130
167#define H_SET_XDABR 0x134 172#define H_SET_XDABR 0x134
168#define H_STUFF_TCE 0x138 173#define H_STUFF_TCE 0x138
169#define H_PUT_TCE_INDIRECT 0x13C 174#define H_PUT_TCE_INDIRECT 0x13C
175#define H_CHANGE_LOGICAL_LAN_MAC 0x14C
170#define H_VTERM_PARTNER_INFO 0x150 176#define H_VTERM_PARTNER_INFO 0x150
171#define H_REGISTER_VTERM 0x154 177#define H_REGISTER_VTERM 0x154
172#define H_FREE_VTERM 0x158 178#define H_FREE_VTERM 0x158
@@ -196,102 +202,59 @@
196#define H_GET_HCA_INFO 0x1B8 202#define H_GET_HCA_INFO 0x1B8
197#define H_GET_PERF_COUNT 0x1BC 203#define H_GET_PERF_COUNT 0x1BC
198#define H_MANAGE_TRACE 0x1C0 204#define H_MANAGE_TRACE 0x1C0
205#define H_FREE_LOGICAL_LAN_BUFFER 0x1D4
199#define H_QUERY_INT_STATE 0x1E4 206#define H_QUERY_INT_STATE 0x1E4
200#define H_POLL_PENDING 0x1D8 207#define H_POLL_PENDING 0x1D8
201#define H_JOIN 0x298 208#define H_JOIN 0x298
202#define H_VASI_STATE 0x2A4 209#define H_VASI_STATE 0x2A4
203#define H_ENABLE_CRQ 0x2B0 210#define H_ENABLE_CRQ 0x2B0
211#define MAX_HCALL_OPCODE H_ENABLE_CRQ
204 212
205#ifndef __ASSEMBLY__ 213#ifndef __ASSEMBLY__
206 214
207/* plpar_hcall() -- Generic call interface using above opcodes 215/**
216 * plpar_hcall_norets: - Make a pseries hypervisor call with no return arguments
217 * @opcode: The hypervisor call to make.
208 * 218 *
209 * The actual call interface is a hypervisor call instruction with 219 * This call supports up to 7 arguments and only returns the status of
210 * the opcode in R3 and input args in R4-R7. 220 * the hcall. Use this version where possible, its slightly faster than
211 * Status is returned in R3 with variable output values in R4-R11. 221 * the other plpar_hcalls.
212 * Only H_PTE_READ with H_READ_4 uses R6-R11 so we ignore it for now
213 * and return only two out args which MUST ALWAYS BE PROVIDED.
214 */
215long plpar_hcall(unsigned long opcode,
216 unsigned long arg1,
217 unsigned long arg2,
218 unsigned long arg3,
219 unsigned long arg4,
220 unsigned long *out1,
221 unsigned long *out2,
222 unsigned long *out3);
223
224/* Same as plpar_hcall but for those opcodes that return no values
225 * other than status. Slightly more efficient.
226 */ 222 */
227long plpar_hcall_norets(unsigned long opcode, ...); 223long plpar_hcall_norets(unsigned long opcode, ...);
228 224
229/* 225/**
230 * Special hcall interface for ibmveth support. 226 * plpar_hcall: - Make a pseries hypervisor call
231 * Takes 8 input parms. Returns a rc and stores the 227 * @opcode: The hypervisor call to make.
232 * R4 return value in *out1. 228 * @retbuf: Buffer to store up to 4 return arguments in.
233 */
234long plpar_hcall_8arg_2ret(unsigned long opcode,
235 unsigned long arg1,
236 unsigned long arg2,
237 unsigned long arg3,
238 unsigned long arg4,
239 unsigned long arg5,
240 unsigned long arg6,
241 unsigned long arg7,
242 unsigned long arg8,
243 unsigned long *out1);
244
245/* plpar_hcall_4out()
246 * 229 *
247 * same as plpar_hcall except with 4 output arguments. 230 * This call supports up to 6 arguments and 4 return arguments. Use
231 * PLPAR_HCALL_BUFSIZE to size the return argument buffer.
248 * 232 *
233 * Used for all but the craziest of phyp interfaces (see plpar_hcall9)
249 */ 234 */
250long plpar_hcall_4out(unsigned long opcode, 235#define PLPAR_HCALL_BUFSIZE 4
251 unsigned long arg1, 236long plpar_hcall(unsigned long opcode, unsigned long *retbuf, ...);
252 unsigned long arg2,
253 unsigned long arg3,
254 unsigned long arg4,
255 unsigned long *out1,
256 unsigned long *out2,
257 unsigned long *out3,
258 unsigned long *out4);
259 237
260long plpar_hcall_7arg_7ret(unsigned long opcode, 238/**
261 unsigned long arg1, 239 * plpar_hcall9: - Make a pseries hypervisor call with up to 9 return arguments
262 unsigned long arg2, 240 * @opcode: The hypervisor call to make.
263 unsigned long arg3, 241 * @retbuf: Buffer to store up to 9 return arguments in.
264 unsigned long arg4, 242 *
265 unsigned long arg5, 243 * This call supports up to 9 arguments and 9 return arguments. Use
266 unsigned long arg6, 244 * PLPAR_HCALL9_BUFSIZE to size the return argument buffer.
267 unsigned long arg7, 245 */
268 unsigned long *out1, 246#define PLPAR_HCALL9_BUFSIZE 9
269 unsigned long *out2, 247long plpar_hcall9(unsigned long opcode, unsigned long *retbuf, ...);
270 unsigned long *out3,
271 unsigned long *out4,
272 unsigned long *out5,
273 unsigned long *out6,
274 unsigned long *out7);
275 248
276long plpar_hcall_9arg_9ret(unsigned long opcode, 249/* For hcall instrumentation. One structure per-hcall, per-CPU */
277 unsigned long arg1, 250struct hcall_stats {
278 unsigned long arg2, 251 unsigned long num_calls; /* number of calls (on this CPU) */
279 unsigned long arg3, 252 unsigned long tb_total; /* total wall time (mftb) of calls. */
280 unsigned long arg4, 253 unsigned long purr_total; /* total cpu time (PURR) of calls. */
281 unsigned long arg5, 254};
282 unsigned long arg6, 255void update_hcall_stats(unsigned long opcode, unsigned long tb_delta,
283 unsigned long arg7, 256 unsigned long purr_delta);
284 unsigned long arg8, 257#define HCALL_STAT_ARRAY_SIZE ((MAX_HCALL_OPCODE >> 2) + 1)
285 unsigned long arg9,
286 unsigned long *out1,
287 unsigned long *out2,
288 unsigned long *out3,
289 unsigned long *out4,
290 unsigned long *out5,
291 unsigned long *out6,
292 unsigned long *out7,
293 unsigned long *out8,
294 unsigned long *out9);
295 258
296#endif /* __ASSEMBLY__ */ 259#endif /* __ASSEMBLY__ */
297#endif /* __KERNEL__ */ 260#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/ibmebus.h b/include/asm-powerpc/ibmebus.h
index 7a42723d107c..7ab195a27888 100644
--- a/include/asm-powerpc/ibmebus.h
+++ b/include/asm-powerpc/ibmebus.h
@@ -48,7 +48,7 @@ extern struct dma_mapping_ops ibmebus_dma_ops;
48extern struct bus_type ibmebus_bus_type; 48extern struct bus_type ibmebus_bus_type;
49 49
50struct ibmebus_dev { 50struct ibmebus_dev {
51 char *name; 51 const char *name;
52 struct of_device ofdev; 52 struct of_device ofdev;
53}; 53};
54 54
diff --git a/include/asm-powerpc/ide.h b/include/asm-powerpc/ide.h
index b09b42af6a1e..c8390f9485de 100644
--- a/include/asm-powerpc/ide.h
+++ b/include/asm-powerpc/ide.h
@@ -12,6 +12,7 @@
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <asm/mpc8xx.h> 13#include <asm/mpc8xx.h>
14#endif 14#endif
15#include <asm/io.h>
15 16
16#ifndef MAX_HWIFS 17#ifndef MAX_HWIFS
17#ifdef __powerpc64__ 18#ifdef __powerpc64__
@@ -21,15 +22,14 @@
21#endif 22#endif
22#endif 23#endif
23 24
25#define __ide_mm_insw(p, a, c) _insw_ns((volatile u16 __iomem *)(p), (a), (c))
26#define __ide_mm_insl(p, a, c) _insl_ns((volatile u32 __iomem *)(p), (a), (c))
27#define __ide_mm_outsw(p, a, c) _outsw_ns((volatile u16 __iomem *)(p), (a), (c))
28#define __ide_mm_outsl(p, a, c) _outsl_ns((volatile u32 __iomem *)(p), (a), (c))
29
24#ifndef __powerpc64__ 30#ifndef __powerpc64__
25#include <linux/hdreg.h> 31#include <linux/hdreg.h>
26#include <linux/ioport.h> 32#include <linux/ioport.h>
27#include <asm/io.h>
28
29extern void __ide_mm_insw(void __iomem *port, void *addr, u32 count);
30extern void __ide_mm_outsw(void __iomem *port, void *addr, u32 count);
31extern void __ide_mm_insl(void __iomem *port, void *addr, u32 count);
32extern void __ide_mm_outsl(void __iomem *port, void *addr, u32 count);
33 33
34struct ide_machdep_calls { 34struct ide_machdep_calls {
35 int (*default_irq)(unsigned long base); 35 int (*default_irq)(unsigned long base);
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h
index 212428db0d8b..46bae1cf385b 100644
--- a/include/asm-powerpc/io.h
+++ b/include/asm-powerpc/io.h
@@ -20,20 +20,11 @@ extern int check_legacy_ioport(unsigned long base_port);
20#include <asm/page.h> 20#include <asm/page.h>
21#include <asm/byteorder.h> 21#include <asm/byteorder.h>
22#include <asm/paca.h> 22#include <asm/paca.h>
23#ifdef CONFIG_PPC_ISERIES
24#include <asm/iseries/iseries_io.h>
25#endif
26#include <asm/synch.h> 23#include <asm/synch.h>
27#include <asm/delay.h> 24#include <asm/delay.h>
28 25
29#include <asm-generic/iomap.h> 26#include <asm-generic/iomap.h>
30 27
31#define __ide_mm_insw(p, a, c) _insw_ns((volatile u16 __iomem *)(p), (a), (c))
32#define __ide_mm_insl(p, a, c) _insl_ns((volatile u32 __iomem *)(p), (a), (c))
33#define __ide_mm_outsw(p, a, c) _outsw_ns((volatile u16 __iomem *)(p), (a), (c))
34#define __ide_mm_outsl(p, a, c) _outsl_ns((volatile u32 __iomem *)(p), (a), (c))
35
36
37#define SIO_CONFIG_RA 0x398 28#define SIO_CONFIG_RA 0x398
38#define SIO_CONFIG_RD 0x399 29#define SIO_CONFIG_RD 0x399
39 30
@@ -43,42 +34,53 @@ extern unsigned long isa_io_base;
43extern unsigned long pci_io_base; 34extern unsigned long pci_io_base;
44 35
45#ifdef CONFIG_PPC_ISERIES 36#ifdef CONFIG_PPC_ISERIES
46/* __raw_* accessors aren't supported on iSeries */ 37
47#define __raw_readb(addr) { BUG(); 0; } 38extern int in_8(const volatile unsigned char __iomem *addr);
48#define __raw_readw(addr) { BUG(); 0; } 39extern void out_8(volatile unsigned char __iomem *addr, int val);
49#define __raw_readl(addr) { BUG(); 0; } 40extern int in_le16(const volatile unsigned short __iomem *addr);
50#define __raw_readq(addr) { BUG(); 0; } 41extern int in_be16(const volatile unsigned short __iomem *addr);
51#define __raw_writeb(v, addr) { BUG(); 0; } 42extern void out_le16(volatile unsigned short __iomem *addr, int val);
52#define __raw_writew(v, addr) { BUG(); 0; } 43extern void out_be16(volatile unsigned short __iomem *addr, int val);
53#define __raw_writel(v, addr) { BUG(); 0; } 44extern unsigned in_le32(const volatile unsigned __iomem *addr);
54#define __raw_writeq(v, addr) { BUG(); 0; } 45extern unsigned in_be32(const volatile unsigned __iomem *addr);
55#define readb(addr) iSeries_Read_Byte(addr) 46extern void out_le32(volatile unsigned __iomem *addr, int val);
56#define readw(addr) iSeries_Read_Word(addr) 47extern void out_be32(volatile unsigned __iomem *addr, int val);
57#define readl(addr) iSeries_Read_Long(addr) 48extern unsigned long in_le64(const volatile unsigned long __iomem *addr);
58#define writeb(data, addr) iSeries_Write_Byte((data),(addr)) 49extern unsigned long in_be64(const volatile unsigned long __iomem *addr);
59#define writew(data, addr) iSeries_Write_Word((data),(addr)) 50extern void out_le64(volatile unsigned long __iomem *addr, unsigned long val);
60#define writel(data, addr) iSeries_Write_Long((data),(addr)) 51extern void out_be64(volatile unsigned long __iomem *addr, unsigned long val);
61#define memset_io(a,b,c) iSeries_memset_io((a),(b),(c)) 52
62#define memcpy_fromio(a,b,c) iSeries_memcpy_fromio((a), (b), (c)) 53extern unsigned char __raw_readb(const volatile void __iomem *addr);
63#define memcpy_toio(a,b,c) iSeries_memcpy_toio((a), (b), (c)) 54extern unsigned short __raw_readw(const volatile void __iomem *addr);
64 55extern unsigned int __raw_readl(const volatile void __iomem *addr);
65#define inb(addr) readb(((void __iomem *)(long)(addr))) 56extern unsigned long __raw_readq(const volatile void __iomem *addr);
66#define inw(addr) readw(((void __iomem *)(long)(addr))) 57extern void __raw_writeb(unsigned char v, volatile void __iomem *addr);
67#define inl(addr) readl(((void __iomem *)(long)(addr))) 58extern void __raw_writew(unsigned short v, volatile void __iomem *addr);
68#define outb(data,addr) writeb(data,((void __iomem *)(long)(addr))) 59extern void __raw_writel(unsigned int v, volatile void __iomem *addr);
69#define outw(data,addr) writew(data,((void __iomem *)(long)(addr))) 60extern void __raw_writeq(unsigned long v, volatile void __iomem *addr);
70#define outl(data,addr) writel(data,((void __iomem *)(long)(addr))) 61
71/* 62extern void memset_io(volatile void __iomem *addr, int c, unsigned long n);
72 * The *_ns versions below don't do byte-swapping. 63extern void memcpy_fromio(void *dest, const volatile void __iomem *src,
73 * Neither do the standard versions now, these are just here 64 unsigned long n);
74 * for older code. 65extern void memcpy_toio(volatile void __iomem *dest, const void *src,
75 */ 66 unsigned long n);
76#define insb(port, buf, ns) _insb((u8 __iomem *)((port)+pci_io_base), (buf), (ns)) 67
77#define insw(port, buf, ns) _insw_ns((u8 __iomem *)((port)+pci_io_base), (buf), (ns)) 68#else /* CONFIG_PPC_ISERIES */
78#define insl(port, buf, nl) _insl_ns((u8 __iomem *)((port)+pci_io_base), (buf), (nl)) 69
79#define insw_ns(port, buf, ns) _insw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns)) 70#define in_8(addr) __in_8((addr))
80#define insl_ns(port, buf, nl) _insl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl)) 71#define out_8(addr, val) __out_8((addr), (val))
81#else 72#define in_le16(addr) __in_le16((addr))
73#define in_be16(addr) __in_be16((addr))
74#define out_le16(addr, val) __out_le16((addr), (val))
75#define out_be16(addr, val) __out_be16((addr), (val))
76#define in_le32(addr) __in_le32((addr))
77#define in_be32(addr) __in_be32((addr))
78#define out_le32(addr, val) __out_le32((addr), (val))
79#define out_be32(addr, val) __out_be32((addr), (val))
80#define in_le64(addr) __in_le64((addr))
81#define in_be64(addr) __in_be64((addr))
82#define out_le64(addr, val) __out_le64((addr), (val))
83#define out_be64(addr, val) __out_be64((addr), (val))
82 84
83static inline unsigned char __raw_readb(const volatile void __iomem *addr) 85static inline unsigned char __raw_readb(const volatile void __iomem *addr)
84{ 86{
@@ -112,23 +114,11 @@ static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr)
112{ 114{
113 *(volatile unsigned long __force *)addr = v; 115 *(volatile unsigned long __force *)addr = v;
114} 116}
115#define readb(addr) eeh_readb(addr)
116#define readw(addr) eeh_readw(addr)
117#define readl(addr) eeh_readl(addr)
118#define readq(addr) eeh_readq(addr)
119#define writeb(data, addr) eeh_writeb((data), (addr))
120#define writew(data, addr) eeh_writew((data), (addr))
121#define writel(data, addr) eeh_writel((data), (addr))
122#define writeq(data, addr) eeh_writeq((data), (addr))
123#define memset_io(a,b,c) eeh_memset_io((a),(b),(c)) 117#define memset_io(a,b,c) eeh_memset_io((a),(b),(c))
124#define memcpy_fromio(a,b,c) eeh_memcpy_fromio((a),(b),(c)) 118#define memcpy_fromio(a,b,c) eeh_memcpy_fromio((a),(b),(c))
125#define memcpy_toio(a,b,c) eeh_memcpy_toio((a),(b),(c)) 119#define memcpy_toio(a,b,c) eeh_memcpy_toio((a),(b),(c))
126#define inb(port) eeh_inb((unsigned long)port) 120
127#define outb(val, port) eeh_outb(val, (unsigned long)port) 121#endif /* CONFIG_PPC_ISERIES */
128#define inw(port) eeh_inw((unsigned long)port)
129#define outw(val, port) eeh_outw(val, (unsigned long)port)
130#define inl(port) eeh_inl((unsigned long)port)
131#define outl(val, port) eeh_outl(val, (unsigned long)port)
132 122
133/* 123/*
134 * The insw/outsw/insl/outsl macros don't do byte-swapping. 124 * The insw/outsw/insl/outsl macros don't do byte-swapping.
@@ -138,30 +128,37 @@ static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr)
138#define insb(port, buf, ns) eeh_insb((port), (buf), (ns)) 128#define insb(port, buf, ns) eeh_insb((port), (buf), (ns))
139#define insw(port, buf, ns) eeh_insw_ns((port), (buf), (ns)) 129#define insw(port, buf, ns) eeh_insw_ns((port), (buf), (ns))
140#define insl(port, buf, nl) eeh_insl_ns((port), (buf), (nl)) 130#define insl(port, buf, nl) eeh_insl_ns((port), (buf), (nl))
141#define insw_ns(port, buf, ns) eeh_insw_ns((port), (buf), (ns))
142#define insl_ns(port, buf, nl) eeh_insl_ns((port), (buf), (nl))
143
144#endif
145 131
146#define outsb(port, buf, ns) _outsb((u8 __iomem *)((port)+pci_io_base), (buf), (ns)) 132#define outsb(port, buf, ns) _outsb((u8 __iomem *)((port)+pci_io_base), (buf), (ns))
147#define outsw(port, buf, ns) _outsw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns)) 133#define outsw(port, buf, ns) _outsw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns))
148#define outsl(port, buf, nl) _outsl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl)) 134#define outsl(port, buf, nl) _outsl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl))
149 135
136#define readb(addr) eeh_readb(addr)
137#define readw(addr) eeh_readw(addr)
138#define readl(addr) eeh_readl(addr)
139#define readq(addr) eeh_readq(addr)
140#define writeb(data, addr) eeh_writeb((data), (addr))
141#define writew(data, addr) eeh_writew((data), (addr))
142#define writel(data, addr) eeh_writel((data), (addr))
143#define writeq(data, addr) eeh_writeq((data), (addr))
144#define inb(port) eeh_inb((unsigned long)port)
145#define outb(val, port) eeh_outb(val, (unsigned long)port)
146#define inw(port) eeh_inw((unsigned long)port)
147#define outw(val, port) eeh_outw(val, (unsigned long)port)
148#define inl(port) eeh_inl((unsigned long)port)
149#define outl(val, port) eeh_outl(val, (unsigned long)port)
150
150#define readb_relaxed(addr) readb(addr) 151#define readb_relaxed(addr) readb(addr)
151#define readw_relaxed(addr) readw(addr) 152#define readw_relaxed(addr) readw(addr)
152#define readl_relaxed(addr) readl(addr) 153#define readl_relaxed(addr) readl(addr)
153#define readq_relaxed(addr) readq(addr) 154#define readq_relaxed(addr) readq(addr)
154 155
155extern void _insb(volatile u8 __iomem *port, void *buf, int ns); 156extern void _insb(volatile u8 __iomem *port, void *buf, long count);
156extern void _outsb(volatile u8 __iomem *port, const void *buf, int ns); 157extern void _outsb(volatile u8 __iomem *port, const void *buf, long count);
157extern void _insw(volatile u16 __iomem *port, void *buf, int ns); 158extern void _insw_ns(volatile u16 __iomem *port, void *buf, long count);
158extern void _outsw(volatile u16 __iomem *port, const void *buf, int ns); 159extern void _outsw_ns(volatile u16 __iomem *port, const void *buf, long count);
159extern void _insl(volatile u32 __iomem *port, void *buf, int nl); 160extern void _insl_ns(volatile u32 __iomem *port, void *buf, long count);
160extern void _outsl(volatile u32 __iomem *port, const void *buf, int nl); 161extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count);
161extern void _insw_ns(volatile u16 __iomem *port, void *buf, int ns);
162extern void _outsw_ns(volatile u16 __iomem *port, const void *buf, int ns);
163extern void _insl_ns(volatile u32 __iomem *port, void *buf, int nl);
164extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, int nl);
165 162
166static inline void mmiowb(void) 163static inline void mmiowb(void)
167{ 164{
@@ -180,14 +177,6 @@ static inline void mmiowb(void)
180#define inl_p(port) inl(port) 177#define inl_p(port) inl(port)
181#define outl_p(val, port) (udelay(1), outl((val), (port))) 178#define outl_p(val, port) (udelay(1), outl((val), (port)))
182 179
183/*
184 * The *_ns versions below don't do byte-swapping.
185 * Neither do the standard versions now, these are just here
186 * for older code.
187 */
188#define outsw_ns(port, buf, ns) _outsw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns))
189#define outsl_ns(port, buf, nl) _outsl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl))
190
191 180
192#define IO_SPACE_LIMIT ~(0UL) 181#define IO_SPACE_LIMIT ~(0UL)
193 182
@@ -279,7 +268,7 @@ static inline void iosync(void)
279 * and should not be used directly by device drivers. Use inb/readb 268 * and should not be used directly by device drivers. Use inb/readb
280 * instead. 269 * instead.
281 */ 270 */
282static inline int in_8(const volatile unsigned char __iomem *addr) 271static inline int __in_8(const volatile unsigned char __iomem *addr)
283{ 272{
284 int ret; 273 int ret;
285 274
@@ -288,14 +277,14 @@ static inline int in_8(const volatile unsigned char __iomem *addr)
288 return ret; 277 return ret;
289} 278}
290 279
291static inline void out_8(volatile unsigned char __iomem *addr, int val) 280static inline void __out_8(volatile unsigned char __iomem *addr, int val)
292{ 281{
293 __asm__ __volatile__("sync; stb%U0%X0 %1,%0" 282 __asm__ __volatile__("sync; stb%U0%X0 %1,%0"
294 : "=m" (*addr) : "r" (val)); 283 : "=m" (*addr) : "r" (val));
295 get_paca()->io_sync = 1; 284 get_paca()->io_sync = 1;
296} 285}
297 286
298static inline int in_le16(const volatile unsigned short __iomem *addr) 287static inline int __in_le16(const volatile unsigned short __iomem *addr)
299{ 288{
300 int ret; 289 int ret;
301 290
@@ -304,7 +293,7 @@ static inline int in_le16(const volatile unsigned short __iomem *addr)
304 return ret; 293 return ret;
305} 294}
306 295
307static inline int in_be16(const volatile unsigned short __iomem *addr) 296static inline int __in_be16(const volatile unsigned short __iomem *addr)
308{ 297{
309 int ret; 298 int ret;
310 299
@@ -313,21 +302,21 @@ static inline int in_be16(const volatile unsigned short __iomem *addr)
313 return ret; 302 return ret;
314} 303}
315 304
316static inline void out_le16(volatile unsigned short __iomem *addr, int val) 305static inline void __out_le16(volatile unsigned short __iomem *addr, int val)
317{ 306{
318 __asm__ __volatile__("sync; sthbrx %1,0,%2" 307 __asm__ __volatile__("sync; sthbrx %1,0,%2"
319 : "=m" (*addr) : "r" (val), "r" (addr)); 308 : "=m" (*addr) : "r" (val), "r" (addr));
320 get_paca()->io_sync = 1; 309 get_paca()->io_sync = 1;
321} 310}
322 311
323static inline void out_be16(volatile unsigned short __iomem *addr, int val) 312static inline void __out_be16(volatile unsigned short __iomem *addr, int val)
324{ 313{
325 __asm__ __volatile__("sync; sth%U0%X0 %1,%0" 314 __asm__ __volatile__("sync; sth%U0%X0 %1,%0"
326 : "=m" (*addr) : "r" (val)); 315 : "=m" (*addr) : "r" (val));
327 get_paca()->io_sync = 1; 316 get_paca()->io_sync = 1;
328} 317}
329 318
330static inline unsigned in_le32(const volatile unsigned __iomem *addr) 319static inline unsigned __in_le32(const volatile unsigned __iomem *addr)
331{ 320{
332 unsigned ret; 321 unsigned ret;
333 322
@@ -336,7 +325,7 @@ static inline unsigned in_le32(const volatile unsigned __iomem *addr)
336 return ret; 325 return ret;
337} 326}
338 327
339static inline unsigned in_be32(const volatile unsigned __iomem *addr) 328static inline unsigned __in_be32(const volatile unsigned __iomem *addr)
340{ 329{
341 unsigned ret; 330 unsigned ret;
342 331
@@ -345,21 +334,21 @@ static inline unsigned in_be32(const volatile unsigned __iomem *addr)
345 return ret; 334 return ret;
346} 335}
347 336
348static inline void out_le32(volatile unsigned __iomem *addr, int val) 337static inline void __out_le32(volatile unsigned __iomem *addr, int val)
349{ 338{
350 __asm__ __volatile__("sync; stwbrx %1,0,%2" : "=m" (*addr) 339 __asm__ __volatile__("sync; stwbrx %1,0,%2" : "=m" (*addr)
351 : "r" (val), "r" (addr)); 340 : "r" (val), "r" (addr));
352 get_paca()->io_sync = 1; 341 get_paca()->io_sync = 1;
353} 342}
354 343
355static inline void out_be32(volatile unsigned __iomem *addr, int val) 344static inline void __out_be32(volatile unsigned __iomem *addr, int val)
356{ 345{
357 __asm__ __volatile__("sync; stw%U0%X0 %1,%0" 346 __asm__ __volatile__("sync; stw%U0%X0 %1,%0"
358 : "=m" (*addr) : "r" (val)); 347 : "=m" (*addr) : "r" (val));
359 get_paca()->io_sync = 1; 348 get_paca()->io_sync = 1;
360} 349}
361 350
362static inline unsigned long in_le64(const volatile unsigned long __iomem *addr) 351static inline unsigned long __in_le64(const volatile unsigned long __iomem *addr)
363{ 352{
364 unsigned long tmp, ret; 353 unsigned long tmp, ret;
365 354
@@ -379,7 +368,7 @@ static inline unsigned long in_le64(const volatile unsigned long __iomem *addr)
379 return ret; 368 return ret;
380} 369}
381 370
382static inline unsigned long in_be64(const volatile unsigned long __iomem *addr) 371static inline unsigned long __in_be64(const volatile unsigned long __iomem *addr)
383{ 372{
384 unsigned long ret; 373 unsigned long ret;
385 374
@@ -388,7 +377,7 @@ static inline unsigned long in_be64(const volatile unsigned long __iomem *addr)
388 return ret; 377 return ret;
389} 378}
390 379
391static inline void out_le64(volatile unsigned long __iomem *addr, unsigned long val) 380static inline void __out_le64(volatile unsigned long __iomem *addr, unsigned long val)
392{ 381{
393 unsigned long tmp; 382 unsigned long tmp;
394 383
@@ -406,15 +395,13 @@ static inline void out_le64(volatile unsigned long __iomem *addr, unsigned long
406 get_paca()->io_sync = 1; 395 get_paca()->io_sync = 1;
407} 396}
408 397
409static inline void out_be64(volatile unsigned long __iomem *addr, unsigned long val) 398static inline void __out_be64(volatile unsigned long __iomem *addr, unsigned long val)
410{ 399{
411 __asm__ __volatile__("sync; std%U0%X0 %1,%0" : "=m" (*addr) : "r" (val)); 400 __asm__ __volatile__("sync; std%U0%X0 %1,%0" : "=m" (*addr) : "r" (val));
412 get_paca()->io_sync = 1; 401 get_paca()->io_sync = 1;
413} 402}
414 403
415#ifndef CONFIG_PPC_ISERIES
416#include <asm/eeh.h> 404#include <asm/eeh.h>
417#endif
418 405
419/** 406/**
420 * check_signature - find BIOS signatures 407 * check_signature - find BIOS signatures
@@ -430,7 +417,6 @@ static inline int check_signature(const volatile void __iomem * io_addr,
430 const unsigned char *signature, int length) 417 const unsigned char *signature, int length)
431{ 418{
432 int retval = 0; 419 int retval = 0;
433#ifndef CONFIG_PPC_ISERIES
434 do { 420 do {
435 if (readb(io_addr) != *signature) 421 if (readb(io_addr) != *signature)
436 goto out; 422 goto out;
@@ -440,7 +426,6 @@ static inline int check_signature(const volatile void __iomem * io_addr,
440 } while (length); 426 } while (length);
441 retval = 1; 427 retval = 1;
442out: 428out:
443#endif
444 return retval; 429 return retval;
445} 430}
446 431
diff --git a/include/asm-powerpc/irq.h b/include/asm-powerpc/irq.h
index d903a62959da..4da41efb1319 100644
--- a/include/asm-powerpc/irq.h
+++ b/include/asm-powerpc/irq.h
@@ -137,7 +137,7 @@ struct irq_map_entry {
137extern struct irq_map_entry irq_map[NR_IRQS]; 137extern struct irq_map_entry irq_map[NR_IRQS];
138 138
139 139
140/*** 140/**
141 * irq_alloc_host - Allocate a new irq_host data structure 141 * irq_alloc_host - Allocate a new irq_host data structure
142 * @node: device-tree node of the interrupt controller 142 * @node: device-tree node of the interrupt controller
143 * @revmap_type: type of reverse mapping to use 143 * @revmap_type: type of reverse mapping to use
@@ -159,14 +159,14 @@ extern struct irq_host *irq_alloc_host(unsigned int revmap_type,
159 irq_hw_number_t inval_irq); 159 irq_hw_number_t inval_irq);
160 160
161 161
162/*** 162/**
163 * irq_find_host - Locates a host for a given device node 163 * irq_find_host - Locates a host for a given device node
164 * @node: device-tree node of the interrupt controller 164 * @node: device-tree node of the interrupt controller
165 */ 165 */
166extern struct irq_host *irq_find_host(struct device_node *node); 166extern struct irq_host *irq_find_host(struct device_node *node);
167 167
168 168
169/*** 169/**
170 * irq_set_default_host - Set a "default" host 170 * irq_set_default_host - Set a "default" host
171 * @host: default host pointer 171 * @host: default host pointer
172 * 172 *
@@ -178,7 +178,7 @@ extern struct irq_host *irq_find_host(struct device_node *node);
178extern void irq_set_default_host(struct irq_host *host); 178extern void irq_set_default_host(struct irq_host *host);
179 179
180 180
181/*** 181/**
182 * irq_set_virq_count - Set the maximum number of virt irqs 182 * irq_set_virq_count - Set the maximum number of virt irqs
183 * @count: number of linux virtual irqs, capped with NR_IRQS 183 * @count: number of linux virtual irqs, capped with NR_IRQS
184 * 184 *
@@ -188,7 +188,7 @@ extern void irq_set_default_host(struct irq_host *host);
188extern void irq_set_virq_count(unsigned int count); 188extern void irq_set_virq_count(unsigned int count);
189 189
190 190
191/*** 191/**
192 * irq_create_mapping - Map a hardware interrupt into linux virq space 192 * irq_create_mapping - Map a hardware interrupt into linux virq space
193 * @host: host owning this hardware interrupt or NULL for default host 193 * @host: host owning this hardware interrupt or NULL for default host
194 * @hwirq: hardware irq number in that host space 194 * @hwirq: hardware irq number in that host space
@@ -202,13 +202,13 @@ extern unsigned int irq_create_mapping(struct irq_host *host,
202 irq_hw_number_t hwirq); 202 irq_hw_number_t hwirq);
203 203
204 204
205/*** 205/**
206 * irq_dispose_mapping - Unmap an interrupt 206 * irq_dispose_mapping - Unmap an interrupt
207 * @virq: linux virq number of the interrupt to unmap 207 * @virq: linux virq number of the interrupt to unmap
208 */ 208 */
209extern void irq_dispose_mapping(unsigned int virq); 209extern void irq_dispose_mapping(unsigned int virq);
210 210
211/*** 211/**
212 * irq_find_mapping - Find a linux virq from an hw irq number. 212 * irq_find_mapping - Find a linux virq from an hw irq number.
213 * @host: host owning this hardware interrupt 213 * @host: host owning this hardware interrupt
214 * @hwirq: hardware irq number in that host space 214 * @hwirq: hardware irq number in that host space
@@ -221,7 +221,7 @@ extern unsigned int irq_find_mapping(struct irq_host *host,
221 irq_hw_number_t hwirq); 221 irq_hw_number_t hwirq);
222 222
223 223
224/*** 224/**
225 * irq_radix_revmap - Find a linux virq from a hw irq number. 225 * irq_radix_revmap - Find a linux virq from a hw irq number.
226 * @host: host owning this hardware interrupt 226 * @host: host owning this hardware interrupt
227 * @hwirq: hardware irq number in that host space 227 * @hwirq: hardware irq number in that host space
@@ -232,7 +232,7 @@ extern unsigned int irq_find_mapping(struct irq_host *host,
232extern unsigned int irq_radix_revmap(struct irq_host *host, 232extern unsigned int irq_radix_revmap(struct irq_host *host,
233 irq_hw_number_t hwirq); 233 irq_hw_number_t hwirq);
234 234
235/*** 235/**
236 * irq_linear_revmap - Find a linux virq from a hw irq number. 236 * irq_linear_revmap - Find a linux virq from a hw irq number.
237 * @host: host owning this hardware interrupt 237 * @host: host owning this hardware interrupt
238 * @hwirq: hardware irq number in that host space 238 * @hwirq: hardware irq number in that host space
@@ -247,7 +247,7 @@ extern unsigned int irq_linear_revmap(struct irq_host *host,
247 247
248 248
249 249
250/*** 250/**
251 * irq_alloc_virt - Allocate virtual irq numbers 251 * irq_alloc_virt - Allocate virtual irq numbers
252 * @host: host owning these new virtual irqs 252 * @host: host owning these new virtual irqs
253 * @count: number of consecutive numbers to allocate 253 * @count: number of consecutive numbers to allocate
@@ -261,7 +261,7 @@ extern unsigned int irq_alloc_virt(struct irq_host *host,
261 unsigned int count, 261 unsigned int count,
262 unsigned int hint); 262 unsigned int hint);
263 263
264/*** 264/**
265 * irq_free_virt - Free virtual irq numbers 265 * irq_free_virt - Free virtual irq numbers
266 * @virq: virtual irq number of the first interrupt to free 266 * @virq: virtual irq number of the first interrupt to free
267 * @count: number of interrupts to free 267 * @count: number of interrupts to free
@@ -300,7 +300,7 @@ extern unsigned int irq_of_parse_and_map(struct device_node *dev, int index);
300 300
301/* -- End OF helpers -- */ 301/* -- End OF helpers -- */
302 302
303/*** 303/**
304 * irq_early_init - Init irq remapping subsystem 304 * irq_early_init - Init irq remapping subsystem
305 */ 305 */
306extern void irq_early_init(void); 306extern void irq_early_init(void);
diff --git a/include/asm-powerpc/iseries/hv_call_xm.h b/include/asm-powerpc/iseries/hv_call_xm.h
index ca9202cb01ed..392ac3f54df0 100644
--- a/include/asm-powerpc/iseries/hv_call_xm.h
+++ b/include/asm-powerpc/iseries/hv_call_xm.h
@@ -16,23 +16,6 @@
16#define HvCallXmSetTce HvCallXm + 11 16#define HvCallXmSetTce HvCallXm + 11
17#define HvCallXmSetTces HvCallXm + 13 17#define HvCallXmSetTces HvCallXm + 13
18 18
19/*
20 * Structure passed to HvCallXm_getTceTableParms
21 */
22struct iommu_table_cb {
23 unsigned long itc_busno; /* Bus number for this tce table */
24 unsigned long itc_start; /* Will be NULL for secondary */
25 unsigned long itc_totalsize; /* Size (in pages) of whole table */
26 unsigned long itc_offset; /* Index into real tce table of the
27 start of our section */
28 unsigned long itc_size; /* Size (in pages) of our section */
29 unsigned long itc_index; /* Index of this tce table */
30 unsigned short itc_maxtables; /* Max num of tables for partition */
31 unsigned char itc_virtbus; /* Flag to indicate virtual bus */
32 unsigned char itc_slotno; /* IOA Tce Slot Index */
33 unsigned char itc_rsvd[4];
34};
35
36static inline void HvCallXm_getTceTableParms(u64 cb) 19static inline void HvCallXm_getTceTableParms(u64 cb)
37{ 20{
38 HvCall1(HvCallXmGetTceTableParms, cb); 21 HvCall1(HvCallXmGetTceTableParms, cb);
diff --git a/include/asm-powerpc/iseries/hv_lp_config.h b/include/asm-powerpc/iseries/hv_lp_config.h
index df8b20739719..a006fd1e4a2c 100644
--- a/include/asm-powerpc/iseries/hv_lp_config.h
+++ b/include/asm-powerpc/iseries/hv_lp_config.h
@@ -25,7 +25,6 @@
25 25
26#include <asm/iseries/hv_call_sc.h> 26#include <asm/iseries/hv_call_sc.h>
27#include <asm/iseries/hv_types.h> 27#include <asm/iseries/hv_types.h>
28#include <asm/iseries/it_lp_naca.h>
29 28
30enum { 29enum {
31 HvCallCfg_Cur = 0, 30 HvCallCfg_Cur = 0,
@@ -44,16 +43,8 @@ enum {
44#define HvCallCfgGetHostingLpIndex HvCallCfg + 32 43#define HvCallCfgGetHostingLpIndex HvCallCfg + 32
45 44
46extern HvLpIndex HvLpConfig_getLpIndex_outline(void); 45extern HvLpIndex HvLpConfig_getLpIndex_outline(void);
47 46extern HvLpIndex HvLpConfig_getLpIndex(void);
48static inline HvLpIndex HvLpConfig_getLpIndex(void) 47extern HvLpIndex HvLpConfig_getPrimaryLpIndex(void);
49{
50 return itLpNaca.xLpIndex;
51}
52
53static inline HvLpIndex HvLpConfig_getPrimaryLpIndex(void)
54{
55 return itLpNaca.xPrimaryLpIndex;
56}
57 48
58static inline u64 HvLpConfig_getMsChunks(void) 49static inline u64 HvLpConfig_getMsChunks(void)
59{ 50{
diff --git a/include/asm-powerpc/iseries/iseries_io.h b/include/asm-powerpc/iseries/iseries_io.h
deleted file mode 100644
index f29009bd63c9..000000000000
--- a/include/asm-powerpc/iseries/iseries_io.h
+++ /dev/null
@@ -1,60 +0,0 @@
1#ifndef _ASM_POWERPC_ISERIES_ISERIES_IO_H
2#define _ASM_POWERPC_ISERIES_ISERIES_IO_H
3
4
5#ifdef CONFIG_PPC_ISERIES
6#include <linux/types.h>
7/*
8 * Created by Allan Trautman on Thu Dec 28 2000.
9 *
10 * Remaps the io.h for the iSeries Io
11 * Copyright (C) 2000 Allan H Trautman, IBM Corporation
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the:
25 * Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330,
27 * Boston, MA 02111-1307 USA
28 *
29 * Change Activity:
30 * Created December 28, 2000
31 * End Change Activity
32 */
33
34#ifdef CONFIG_PCI
35extern u8 iSeries_Read_Byte(const volatile void __iomem * IoAddress);
36extern u16 iSeries_Read_Word(const volatile void __iomem * IoAddress);
37extern u32 iSeries_Read_Long(const volatile void __iomem * IoAddress);
38extern void iSeries_Write_Byte(u8 IoData, volatile void __iomem * IoAddress);
39extern void iSeries_Write_Word(u16 IoData, volatile void __iomem * IoAddress);
40extern void iSeries_Write_Long(u32 IoData, volatile void __iomem * IoAddress);
41
42extern void iSeries_memset_io(volatile void __iomem *dest, char x, size_t n);
43extern void iSeries_memcpy_toio(volatile void __iomem *dest, void *source,
44 size_t n);
45extern void iSeries_memcpy_fromio(void *dest,
46 const volatile void __iomem *source, size_t n);
47#else
48static inline u8 iSeries_Read_Byte(const volatile void __iomem *IoAddress)
49{
50 return 0xff;
51}
52
53static inline void iSeries_Write_Byte(u8 IoData,
54 volatile void __iomem *IoAddress)
55{
56}
57#endif /* CONFIG_PCI */
58
59#endif /* CONFIG_PPC_ISERIES */
60#endif /* _ASM_POWERPC_ISERIES_ISERIES_IO_H */
diff --git a/include/asm-powerpc/iseries/it_lp_queue.h b/include/asm-powerpc/iseries/it_lp_queue.h
index 284c5a7db3ac..3f6814769295 100644
--- a/include/asm-powerpc/iseries/it_lp_queue.h
+++ b/include/asm-powerpc/iseries/it_lp_queue.h
@@ -27,8 +27,6 @@
27#include <asm/types.h> 27#include <asm/types.h>
28#include <asm/ptrace.h> 28#include <asm/ptrace.h>
29 29
30struct HvLpEvent;
31
32#define IT_LP_MAX_QUEUES 8 30#define IT_LP_MAX_QUEUES 8
33 31
34#define IT_LP_NOT_USED 0 /* Queue will not be used by PLIC */ 32#define IT_LP_NOT_USED 0 /* Queue will not be used by PLIC */
diff --git a/include/asm-powerpc/iseries/vio.h b/include/asm-powerpc/iseries/vio.h
index 72a97d37aac3..7a95d296abd1 100644
--- a/include/asm-powerpc/iseries/vio.h
+++ b/include/asm-powerpc/iseries/vio.h
@@ -122,6 +122,34 @@ enum viorc {
122 viorc_openRejected = 0x0301 122 viorc_openRejected = 0x0301
123}; 123};
124 124
125/*
126 * The structure of the events that flow between us and OS/400 for chario
127 * events. You can't mess with this unless the OS/400 side changes too.
128 */
129struct viocharlpevent {
130 struct HvLpEvent event;
131 u32 reserved;
132 u16 version;
133 u16 subtype_result_code;
134 u8 virtual_device;
135 u8 len;
136 u8 data[VIOCHAR_MAX_DATA];
137};
138
139#define VIOCHAR_WINDOW 10
140
141enum viocharsubtype {
142 viocharopen = 0x0001,
143 viocharclose = 0x0002,
144 viochardata = 0x0003,
145 viocharack = 0x0004,
146 viocharconfig = 0x0005
147};
148
149enum viochar_rc {
150 viochar_rc_ebusy = 1
151};
152
125struct device; 153struct device;
126 154
127extern struct device *iSeries_vio_dev; 155extern struct device *iSeries_vio_dev;
diff --git a/include/asm-powerpc/lppaca.h b/include/asm-powerpc/lppaca.h
index 4dc514aabfe7..821ea0c512b4 100644
--- a/include/asm-powerpc/lppaca.h
+++ b/include/asm-powerpc/lppaca.h
@@ -27,7 +27,9 @@
27// 27//
28// 28//
29//---------------------------------------------------------------------------- 29//----------------------------------------------------------------------------
30#include <linux/cache.h>
30#include <asm/types.h> 31#include <asm/types.h>
32#include <asm/mmu.h>
31 33
32/* The Hypervisor barfs if the lppaca crosses a page boundary. A 1k 34/* The Hypervisor barfs if the lppaca crosses a page boundary. A 1k
33 * alignment is sufficient to prevent this */ 35 * alignment is sufficient to prevent this */
@@ -114,7 +116,7 @@ struct lppaca {
114 116
115 117
116//============================================================================= 118//=============================================================================
117// CACHE_LINE_3 0x0100 - 0x007F: This line is shared with other processors 119// CACHE_LINE_3 0x0100 - 0x017F: This line is shared with other processors
118//============================================================================= 120//=============================================================================
119 // This is the yield_count. An "odd" value (low bit on) means that 121 // This is the yield_count. An "odd" value (low bit on) means that
120 // the processor is yielded (either because of an OS yield or a PLIC 122 // the processor is yielded (either because of an OS yield or a PLIC
@@ -126,12 +128,29 @@ struct lppaca {
126 u8 reserved6[124]; // Reserved x04-x7F 128 u8 reserved6[124]; // Reserved x04-x7F
127 129
128//============================================================================= 130//=============================================================================
129// CACHE_LINE_4-5 0x0100 - 0x01FF Contains PMC interrupt data 131// CACHE_LINE_4-5 0x0180 - 0x027F Contains PMC interrupt data
130//============================================================================= 132//=============================================================================
131 u8 pmc_save_area[256]; // PMC interrupt Area x00-xFF 133 u8 pmc_save_area[256]; // PMC interrupt Area x00-xFF
132} __attribute__((__aligned__(0x400))); 134} __attribute__((__aligned__(0x400)));
133 135
134extern struct lppaca lppaca[]; 136extern struct lppaca lppaca[];
135 137
138/*
139 * SLB shadow buffer structure as defined in the PAPR. The save_area
140 * contains adjacent ESID and VSID pairs for each shadowed SLB. The
141 * ESID is stored in the lower 64bits, then the VSID.
142 */
143struct slb_shadow {
144 u32 persistent; // Number of persistent SLBs x00-x03
145 u32 buffer_length; // Total shadow buffer length x04-x07
146 u64 reserved; // Alignment x08-x0f
147 struct {
148 u64 esid;
149 u64 vsid;
150 } save_area[SLB_NUM_BOLTED]; // x10-x40
151} ____cacheline_aligned;
152
153extern struct slb_shadow slb_shadow[];
154
136#endif /* __KERNEL__ */ 155#endif /* __KERNEL__ */
137#endif /* _ASM_POWERPC_LPPACA_H */ 156#endif /* _ASM_POWERPC_LPPACA_H */
diff --git a/include/asm-powerpc/paca.h b/include/asm-powerpc/paca.h
index 3d5d590bc4b0..0a4e5c93e8e6 100644
--- a/include/asm-powerpc/paca.h
+++ b/include/asm-powerpc/paca.h
@@ -23,6 +23,7 @@
23register struct paca_struct *local_paca asm("r13"); 23register struct paca_struct *local_paca asm("r13");
24#define get_paca() local_paca 24#define get_paca() local_paca
25#define get_lppaca() (get_paca()->lppaca_ptr) 25#define get_lppaca() (get_paca()->lppaca_ptr)
26#define get_slb_shadow() (get_paca()->slb_shadow_ptr)
26 27
27struct task_struct; 28struct task_struct;
28 29
@@ -99,6 +100,8 @@ struct paca_struct {
99 u64 user_time; /* accumulated usermode TB ticks */ 100 u64 user_time; /* accumulated usermode TB ticks */
100 u64 system_time; /* accumulated system TB ticks */ 101 u64 system_time; /* accumulated system TB ticks */
101 u64 startpurr; /* PURR/TB value snapshot */ 102 u64 startpurr; /* PURR/TB value snapshot */
103
104 struct slb_shadow *slb_shadow_ptr;
102}; 105};
103 106
104extern struct paca_struct paca[]; 107extern struct paca_struct paca[];
diff --git a/include/asm-powerpc/page.h b/include/asm-powerpc/page.h
index fb597b37c2a2..b4d38b0b15f8 100644
--- a/include/asm-powerpc/page.h
+++ b/include/asm-powerpc/page.h
@@ -55,12 +55,6 @@
55#define PAGE_OFFSET ASM_CONST(CONFIG_KERNEL_START) 55#define PAGE_OFFSET ASM_CONST(CONFIG_KERNEL_START)
56#define KERNELBASE (PAGE_OFFSET + PHYSICAL_START) 56#define KERNELBASE (PAGE_OFFSET + PHYSICAL_START)
57 57
58#ifdef CONFIG_DISCONTIGMEM
59#define page_to_pfn(page) discontigmem_page_to_pfn(page)
60#define pfn_to_page(pfn) discontigmem_pfn_to_page(pfn)
61#define pfn_valid(pfn) discontigmem_pfn_valid(pfn)
62#endif
63
64#ifdef CONFIG_FLATMEM 58#ifdef CONFIG_FLATMEM
65#define pfn_valid(pfn) ((pfn) < max_mapnr) 59#define pfn_valid(pfn) ((pfn) < max_mapnr)
66#endif 60#endif
diff --git a/include/asm-powerpc/ppc-pci.h b/include/asm-powerpc/ppc-pci.h
index cf79bc7ebb55..1115756c79f9 100644
--- a/include/asm-powerpc/ppc-pci.h
+++ b/include/asm-powerpc/ppc-pci.h
@@ -69,6 +69,17 @@ struct pci_dev *pci_get_device_by_addr(unsigned long addr);
69void eeh_slot_error_detail (struct pci_dn *pdn, int severity); 69void eeh_slot_error_detail (struct pci_dn *pdn, int severity);
70 70
71/** 71/**
72 * rtas_pci_enableo - enable IO transfers for this slot
73 * @pdn: pci device node
74 * @function: either EEH_THAW_MMIO or EEH_THAW_DMA
75 *
76 * Enable I/O transfers to this slot
77 */
78#define EEH_THAW_MMIO 2
79#define EEH_THAW_DMA 3
80int rtas_pci_enable(struct pci_dn *pdn, int function);
81
82/**
72 * rtas_set_slot_reset -- unfreeze a frozen slot 83 * rtas_set_slot_reset -- unfreeze a frozen slot
73 * 84 *
74 * Clear the EEH-frozen condition on a slot. This routine 85 * Clear the EEH-frozen condition on a slot. This routine
diff --git a/include/asm-powerpc/processor.h b/include/asm-powerpc/processor.h
index 22e54a2a6604..6cb6fb19e57f 100644
--- a/include/asm-powerpc/processor.h
+++ b/include/asm-powerpc/processor.h
@@ -32,6 +32,7 @@
32#define _CHRP_Motorola 0x04 /* motorola chrp, the cobra */ 32#define _CHRP_Motorola 0x04 /* motorola chrp, the cobra */
33#define _CHRP_IBM 0x05 /* IBM chrp, the longtrail and longtrail 2 */ 33#define _CHRP_IBM 0x05 /* IBM chrp, the longtrail and longtrail 2 */
34#define _CHRP_Pegasos 0x06 /* Genesi/bplan's Pegasos and Pegasos2 */ 34#define _CHRP_Pegasos 0x06 /* Genesi/bplan's Pegasos and Pegasos2 */
35#define _CHRP_briq 0x07 /* TotalImpact's briQ */
35 36
36#if defined(__KERNEL__) && defined(CONFIG_PPC32) 37#if defined(__KERNEL__) && defined(CONFIG_PPC32)
37 38
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h
index d0fa1b9aed35..524629769336 100644
--- a/include/asm-powerpc/prom.h
+++ b/include/asm-powerpc/prom.h
@@ -72,8 +72,8 @@ struct property {
72}; 72};
73 73
74struct device_node { 74struct device_node {
75 char *name; 75 const char *name;
76 char *type; 76 const char *type;
77 phandle node; 77 phandle node;
78 phandle linux_phandle; 78 phandle linux_phandle;
79 char *full_name; 79 char *full_name;
@@ -160,7 +160,7 @@ extern void unflatten_device_tree(void);
160extern void early_init_devtree(void *); 160extern void early_init_devtree(void *);
161extern int device_is_compatible(struct device_node *device, const char *); 161extern int device_is_compatible(struct device_node *device, const char *);
162extern int machine_is_compatible(const char *compat); 162extern int machine_is_compatible(const char *compat);
163extern void *get_property(struct device_node *node, const char *name, 163extern const void *get_property(struct device_node *node, const char *name,
164 int *lenp); 164 int *lenp);
165extern void print_properties(struct device_node *node); 165extern void print_properties(struct device_node *node);
166extern int prom_n_addr_cells(struct device_node* np); 166extern int prom_n_addr_cells(struct device_node* np);
@@ -197,8 +197,8 @@ extern int release_OF_resource(struct device_node* node, int index);
197 */ 197 */
198 198
199 199
200/* Helper to read a big number */ 200/* Helper to read a big number; size is in cells (not bytes) */
201static inline u64 of_read_number(u32 *cell, int size) 201static inline u64 of_read_number(const u32 *cell, int size)
202{ 202{
203 u64 r = 0; 203 u64 r = 0;
204 while (size--) 204 while (size--)
@@ -206,18 +206,28 @@ static inline u64 of_read_number(u32 *cell, int size)
206 return r; 206 return r;
207} 207}
208 208
209/* Like of_read_number, but we want an unsigned long result */
210#ifdef CONFIG_PPC32
211static inline unsigned long of_read_ulong(const u32 *cell, int size)
212{
213 return cell[size-1];
214}
215#else
216#define of_read_ulong(cell, size) of_read_number(cell, size)
217#endif
218
209/* Translate an OF address block into a CPU physical address 219/* Translate an OF address block into a CPU physical address
210 */ 220 */
211#define OF_BAD_ADDR ((u64)-1) 221#define OF_BAD_ADDR ((u64)-1)
212extern u64 of_translate_address(struct device_node *np, u32 *addr); 222extern u64 of_translate_address(struct device_node *np, const u32 *addr);
213 223
214/* Extract an address from a device, returns the region size and 224/* Extract an address from a device, returns the region size and
215 * the address space flags too. The PCI version uses a BAR number 225 * the address space flags too. The PCI version uses a BAR number
216 * instead of an absolute index 226 * instead of an absolute index
217 */ 227 */
218extern u32 *of_get_address(struct device_node *dev, int index, 228extern const u32 *of_get_address(struct device_node *dev, int index,
219 u64 *size, unsigned int *flags); 229 u64 *size, unsigned int *flags);
220extern u32 *of_get_pci_address(struct device_node *dev, int bar_no, 230extern const u32 *of_get_pci_address(struct device_node *dev, int bar_no,
221 u64 *size, unsigned int *flags); 231 u64 *size, unsigned int *flags);
222 232
223/* Get an address as a resource. Note that if your address is 233/* Get an address as a resource. Note that if your address is
@@ -234,7 +244,7 @@ extern int of_pci_address_to_resource(struct device_node *dev, int bar,
234/* Parse the ibm,dma-window property of an OF node into the busno, phys and 244/* Parse the ibm,dma-window property of an OF node into the busno, phys and
235 * size parameters. 245 * size parameters.
236 */ 246 */
237void of_parse_dma_window(struct device_node *dn, unsigned char *dma_window_prop, 247void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
238 unsigned long *busno, unsigned long *phys, unsigned long *size); 248 unsigned long *busno, unsigned long *phys, unsigned long *size);
239 249
240extern void kdump_move_device_tree(void); 250extern void kdump_move_device_tree(void);
@@ -259,7 +269,7 @@ struct of_irq {
259 u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */ 269 u32 specifier[OF_MAX_IRQ_SPEC]; /* Specifier copy */
260}; 270};
261 271
262/*** 272/**
263 * of_irq_map_init - Initialize the irq remapper 273 * of_irq_map_init - Initialize the irq remapper
264 * @flags: flags defining workarounds to enable 274 * @flags: flags defining workarounds to enable
265 * 275 *
@@ -272,7 +282,7 @@ struct of_irq {
272 282
273extern void of_irq_map_init(unsigned int flags); 283extern void of_irq_map_init(unsigned int flags);
274 284
275/*** 285/**
276 * of_irq_map_raw - Low level interrupt tree parsing 286 * of_irq_map_raw - Low level interrupt tree parsing
277 * @parent: the device interrupt parent 287 * @parent: the device interrupt parent
278 * @intspec: interrupt specifier ("interrupts" property of the device) 288 * @intspec: interrupt specifier ("interrupts" property of the device)
@@ -289,12 +299,12 @@ extern void of_irq_map_init(unsigned int flags);
289 * 299 *
290 */ 300 */
291 301
292extern int of_irq_map_raw(struct device_node *parent, u32 *intspec, 302extern int of_irq_map_raw(struct device_node *parent, const u32 *intspec,
293 u32 ointsize, u32 *addr, 303 u32 ointsize, const u32 *addr,
294 struct of_irq *out_irq); 304 struct of_irq *out_irq);
295 305
296 306
297/*** 307/**
298 * of_irq_map_one - Resolve an interrupt for a device 308 * of_irq_map_one - Resolve an interrupt for a device
299 * @device: the device whose interrupt is to be resolved 309 * @device: the device whose interrupt is to be resolved
300 * @index: index of the interrupt to resolve 310 * @index: index of the interrupt to resolve
@@ -307,7 +317,7 @@ extern int of_irq_map_raw(struct device_node *parent, u32 *intspec,
307extern int of_irq_map_one(struct device_node *device, int index, 317extern int of_irq_map_one(struct device_node *device, int index,
308 struct of_irq *out_irq); 318 struct of_irq *out_irq);
309 319
310/*** 320/**
311 * of_irq_map_pci - Resolve the interrupt for a PCI device 321 * of_irq_map_pci - Resolve the interrupt for a PCI device
312 * @pdev: the device whose interrupt is to be resolved 322 * @pdev: the device whose interrupt is to be resolved
313 * @out_irq: structure of_irq filled by this function 323 * @out_irq: structure of_irq filled by this function
diff --git a/include/asm-powerpc/ptrace.h b/include/asm-powerpc/ptrace.h
index dc4cb9cc73a1..4435efe85d0e 100644
--- a/include/asm-powerpc/ptrace.h
+++ b/include/asm-powerpc/ptrace.h
@@ -215,12 +215,10 @@ do { \
215#define PTRACE_GETVRREGS 18 215#define PTRACE_GETVRREGS 18
216#define PTRACE_SETVRREGS 19 216#define PTRACE_SETVRREGS 19
217 217
218#ifndef __powerpc64__
219/* Get/set all the upper 32-bits of the SPE registers, accumulator, and 218/* Get/set all the upper 32-bits of the SPE registers, accumulator, and
220 * spefscr, in one go */ 219 * spefscr, in one go */
221#define PTRACE_GETEVRREGS 20 220#define PTRACE_GETEVRREGS 20
222#define PTRACE_SETEVRREGS 21 221#define PTRACE_SETEVRREGS 21
223#endif /* __powerpc64__ */
224 222
225/* 223/*
226 * Get or set a debug register. The first 16 are DABR registers and the 224 * Get or set a debug register. The first 16 are DABR registers and the
@@ -235,7 +233,6 @@ do { \
235#define PPC_PTRACE_GETFPREGS 0x97 /* Get FPRs 0 - 31 */ 233#define PPC_PTRACE_GETFPREGS 0x97 /* Get FPRs 0 - 31 */
236#define PPC_PTRACE_SETFPREGS 0x96 /* Set FPRs 0 - 31 */ 234#define PPC_PTRACE_SETFPREGS 0x96 /* Set FPRs 0 - 31 */
237 235
238#ifdef __powerpc64__
239/* Calls to trace a 64bit program from a 32bit program */ 236/* Calls to trace a 64bit program from a 32bit program */
240#define PPC_PTRACE_PEEKTEXT_3264 0x95 237#define PPC_PTRACE_PEEKTEXT_3264 0x95
241#define PPC_PTRACE_PEEKDATA_3264 0x94 238#define PPC_PTRACE_PEEKDATA_3264 0x94
@@ -243,6 +240,5 @@ do { \
243#define PPC_PTRACE_POKEDATA_3264 0x92 240#define PPC_PTRACE_POKEDATA_3264 0x92
244#define PPC_PTRACE_PEEKUSR_3264 0x91 241#define PPC_PTRACE_PEEKUSR_3264 0x91
245#define PPC_PTRACE_POKEUSR_3264 0x90 242#define PPC_PTRACE_POKEUSR_3264 0x90
246#endif /* __powerpc64__ */
247 243
248#endif /* _ASM_POWERPC_PTRACE_H */ 244#endif /* _ASM_POWERPC_PTRACE_H */
diff --git a/include/asm-powerpc/reg.h b/include/asm-powerpc/reg.h
index cf73475a0c69..3a9fcc15811b 100644
--- a/include/asm-powerpc/reg.h
+++ b/include/asm-powerpc/reg.h
@@ -592,6 +592,7 @@
592#define PV_630p 0x0041 592#define PV_630p 0x0041
593#define PV_970MP 0x0044 593#define PV_970MP 0x0044
594#define PV_BE 0x0070 594#define PV_BE 0x0070
595#define PV_PA6T 0x0090
595 596
596/* 597/*
597 * Number of entries in the SLB. If this ever changes we should handle 598 * Number of entries in the SLB. If this ever changes we should handle
diff --git a/include/asm-powerpc/rtas.h b/include/asm-powerpc/rtas.h
index 82a27e9a041f..d34f9e1f242c 100644
--- a/include/asm-powerpc/rtas.h
+++ b/include/asm-powerpc/rtas.h
@@ -230,5 +230,21 @@ extern unsigned long rtas_rmo_buf;
230 230
231#define GLOBAL_INTERRUPT_QUEUE 9005 231#define GLOBAL_INTERRUPT_QUEUE 9005
232 232
233/**
234 * rtas_config_addr - Format a busno, devfn and reg for RTAS.
235 * @busno: The bus number.
236 * @devfn: The device and function number as encoded by PCI_DEVFN().
237 * @reg: The register number.
238 *
239 * This function encodes the given busno, devfn and register number as
240 * required for RTAS calls that take a "config_addr" parameter.
241 * See PAPR requirement 7.3.4-1 for more info.
242 */
243static inline u32 rtas_config_addr(int busno, int devfn, int reg)
244{
245 return ((reg & 0xf00) << 20) | ((busno & 0xff) << 16) |
246 (devfn << 8) | (reg & 0xff);
247}
248
233#endif /* __KERNEL__ */ 249#endif /* __KERNEL__ */
234#endif /* _POWERPC_RTAS_H */ 250#endif /* _POWERPC_RTAS_H */
diff --git a/include/asm-powerpc/smu.h b/include/asm-powerpc/smu.h
index 51e65fc46a03..e49f644ca63a 100644
--- a/include/asm-powerpc/smu.h
+++ b/include/asm-powerpc/smu.h
@@ -517,7 +517,7 @@ struct smu_sdbp_cpupiddata {
517 * This returns the pointer to an SMU "sdb" partition data or NULL 517 * This returns the pointer to an SMU "sdb" partition data or NULL
518 * if not found. The data format is described below 518 * if not found. The data format is described below
519 */ 519 */
520extern struct smu_sdbp_header *smu_get_sdb_partition(int id, 520extern const struct smu_sdbp_header *smu_get_sdb_partition(int id,
521 unsigned int *size); 521 unsigned int *size);
522 522
523/* Get "sdb" partition data from an SMU satellite */ 523/* Get "sdb" partition data from an SMU satellite */
diff --git a/include/asm-powerpc/spu.h b/include/asm-powerpc/spu.h
index c02d105d8294..b42b53c40f5d 100644
--- a/include/asm-powerpc/spu.h
+++ b/include/asm-powerpc/spu.h
@@ -106,7 +106,7 @@ struct spu_context;
106struct spu_runqueue; 106struct spu_runqueue;
107 107
108struct spu { 108struct spu {
109 char *name; 109 const char *name;
110 unsigned long local_store_phys; 110 unsigned long local_store_phys;
111 u8 *local_store; 111 u8 *local_store;
112 unsigned long problem_phys; 112 unsigned long problem_phys;
diff --git a/include/asm-powerpc/system.h b/include/asm-powerpc/system.h
index 4c9f5229e833..4b41deaa8d8d 100644
--- a/include/asm-powerpc/system.h
+++ b/include/asm-powerpc/system.h
@@ -177,11 +177,6 @@ extern u32 booke_wdt_enabled;
177extern u32 booke_wdt_period; 177extern u32 booke_wdt_period;
178#endif /* CONFIG_BOOKE_WDT */ 178#endif /* CONFIG_BOOKE_WDT */
179 179
180/* EBCDIC -> ASCII conversion for [0-9A-Z] on iSeries */
181extern unsigned char e2a(unsigned char);
182extern unsigned char* strne2a(unsigned char *dest,
183 const unsigned char *src, size_t n);
184
185struct device_node; 180struct device_node;
186extern void note_scsi_host(struct device_node *, void *); 181extern void note_scsi_host(struct device_node *, void *);
187 182
diff --git a/include/asm-powerpc/vio.h b/include/asm-powerpc/vio.h
index dc9bd101ca14..4b51d42e1419 100644
--- a/include/asm-powerpc/vio.h
+++ b/include/asm-powerpc/vio.h
@@ -46,8 +46,8 @@ struct iommu_table;
46 */ 46 */
47struct vio_dev { 47struct vio_dev {
48 struct iommu_table *iommu_table; /* vio_map_* uses this */ 48 struct iommu_table *iommu_table; /* vio_map_* uses this */
49 char *name; 49 const char *name;
50 char *type; 50 const char *type;
51 uint32_t unit_address; 51 uint32_t unit_address;
52 unsigned int irq; 52 unsigned int irq;
53 struct device dev; 53 struct device dev;
diff --git a/include/asm-ppc/io.h b/include/asm-ppc/io.h
index 680555be22ec..3d9a9e6f3321 100644
--- a/include/asm-ppc/io.h
+++ b/include/asm-ppc/io.h
@@ -327,26 +327,12 @@ __do_out_asm(outl, "stwbrx")
327#define inl_p(port) inl((port)) 327#define inl_p(port) inl((port))
328#define outl_p(val, port) outl((val), (port)) 328#define outl_p(val, port) outl((val), (port))
329 329
330extern void _insb(volatile u8 __iomem *port, void *buf, int ns); 330extern void _insb(volatile u8 __iomem *port, void *buf, long count);
331extern void _outsb(volatile u8 __iomem *port, const void *buf, int ns); 331extern void _outsb(volatile u8 __iomem *port, const void *buf, long count);
332extern void _insw(volatile u16 __iomem *port, void *buf, int ns); 332extern void _insw_ns(volatile u16 __iomem *port, void *buf, long count);
333extern void _outsw(volatile u16 __iomem *port, const void *buf, int ns); 333extern void _outsw_ns(volatile u16 __iomem *port, const void *buf, long count);
334extern void _insl(volatile u32 __iomem *port, void *buf, int nl); 334extern void _insl_ns(volatile u32 __iomem *port, void *buf, long count);
335extern void _outsl(volatile u32 __iomem *port, const void *buf, int nl); 335extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count);
336extern void _insw_ns(volatile u16 __iomem *port, void *buf, int ns);
337extern void _outsw_ns(volatile u16 __iomem *port, const void *buf, int ns);
338extern void _insl_ns(volatile u32 __iomem *port, void *buf, int nl);
339extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, int nl);
340
341/*
342 * The *_ns versions below don't do byte-swapping.
343 * Neither do the standard versions now, these are just here
344 * for older code.
345 */
346#define insw_ns(port, buf, ns) _insw_ns((port)+___IO_BASE, (buf), (ns))
347#define outsw_ns(port, buf, ns) _outsw_ns((port)+___IO_BASE, (buf), (ns))
348#define insl_ns(port, buf, nl) _insl_ns((port)+___IO_BASE, (buf), (nl))
349#define outsl_ns(port, buf, nl) _outsl_ns((port)+___IO_BASE, (buf), (nl))
350 336
351 337
352#define IO_SPACE_LIMIT ~0 338#define IO_SPACE_LIMIT ~0
diff --git a/include/asm-ppc/mpc8260_pci9.h b/include/asm-ppc/mpc8260_pci9.h
index 26b3f6e787bc..9f7176881c56 100644
--- a/include/asm-ppc/mpc8260_pci9.h
+++ b/include/asm-ppc/mpc8260_pci9.h
@@ -30,8 +30,6 @@
30#undef inb 30#undef inb
31#undef inw 31#undef inw
32#undef inl 32#undef inl
33#undef insw_ns
34#undef insl_ns
35#undef memcpy_fromio 33#undef memcpy_fromio
36 34
37extern int readb(volatile unsigned char *addr); 35extern int readb(volatile unsigned char *addr);
@@ -43,8 +41,6 @@ extern void insl(unsigned port, void *buf, int nl);
43extern int inb(unsigned port); 41extern int inb(unsigned port);
44extern int inw(unsigned port); 42extern int inw(unsigned port);
45extern unsigned inl(unsigned port); 43extern unsigned inl(unsigned port);
46extern void insw_ns(unsigned port, void *buf, int ns);
47extern void insl_ns(unsigned port, void *buf, int nl);
48extern void *memcpy_fromio(void *dest, unsigned long src, size_t count); 44extern void *memcpy_fromio(void *dest, unsigned long src, size_t count);
49 45
50#endif /* !__CONFIG_8260_PCI9_DEFS */ 46#endif /* !__CONFIG_8260_PCI9_DEFS */
diff --git a/include/asm-ppc/reg_booke.h b/include/asm-ppc/reg_booke.h
index 4944c0fb8bea..602fbadeaf48 100644
--- a/include/asm-ppc/reg_booke.h
+++ b/include/asm-ppc/reg_booke.h
@@ -300,14 +300,14 @@ do { \
300#define DBSR_IC 0x80000000 /* Instruction Completion */ 300#define DBSR_IC 0x80000000 /* Instruction Completion */
301#define DBSR_BT 0x40000000 /* Branch taken */ 301#define DBSR_BT 0x40000000 /* Branch taken */
302#define DBSR_TIE 0x10000000 /* Trap Instruction debug Event */ 302#define DBSR_TIE 0x10000000 /* Trap Instruction debug Event */
303#define DBSR_IAC1 0x00800000 /* Instruction Address Compare 1 Event */ 303#define DBSR_IAC1 0x04000000 /* Instruction Address Compare 1 Event */
304#define DBSR_IAC2 0x00400000 /* Instruction Address Compare 2 Event */ 304#define DBSR_IAC2 0x02000000 /* Instruction Address Compare 2 Event */
305#define DBSR_IAC3 0x00200000 /* Instruction Address Compare 3 Event */ 305#define DBSR_IAC3 0x00080000 /* Instruction Address Compare 3 Event */
306#define DBSR_IAC4 0x00100000 /* Instruction Address Compare 4 Event */ 306#define DBSR_IAC4 0x00040000 /* Instruction Address Compare 4 Event */
307#define DBSR_DAC1R 0x00080000 /* Data Address Compare 1 Read Event */ 307#define DBSR_DAC1R 0x01000000 /* Data Address Compare 1 Read Event */
308#define DBSR_DAC1W 0x00040000 /* Data Address Compare 1 Write Event */ 308#define DBSR_DAC1W 0x00800000 /* Data Address Compare 1 Write Event */
309#define DBSR_DAC2R 0x00020000 /* Data Address Compare 2 Read Event */ 309#define DBSR_DAC2R 0x00400000 /* Data Address Compare 2 Read Event */
310#define DBSR_DAC2W 0x00010000 /* Data Address Compare 2 Write Event */ 310#define DBSR_DAC2W 0x00200000 /* Data Address Compare 2 Write Event */
311#endif 311#endif
312 312
313/* Bit definitions related to the ESR. */ 313/* Bit definitions related to the ESR. */
diff --git a/include/mtd/mtd-abi.h b/include/mtd/mtd-abi.h
index 1da3f7fa7993..b0a67b7ffdcd 100644
--- a/include/mtd/mtd-abi.h
+++ b/include/mtd/mtd-abi.h
@@ -34,6 +34,7 @@ struct mtd_oob_buf {
34#define MTD_WRITEABLE 0x400 /* Device is writeable */ 34#define MTD_WRITEABLE 0x400 /* Device is writeable */
35#define MTD_BIT_WRITEABLE 0x800 /* Single bits can be flipped */ 35#define MTD_BIT_WRITEABLE 0x800 /* Single bits can be flipped */
36#define MTD_NO_ERASE 0x1000 /* No erase necessary */ 36#define MTD_NO_ERASE 0x1000 /* No erase necessary */
37#define MTD_STUPID_LOCK 0x2000 /* Always locked after reset */
37 38
38// Some common devices / combinations of capabilities 39// Some common devices / combinations of capabilities
39#define MTD_CAP_ROM 0 40#define MTD_CAP_ROM 0
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index b34924663ac1..f7844f6aa487 100755
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
@@ -62,6 +62,8 @@ my (@stack, $re, $x, $xs);
62 } elsif ($arch eq 'ppc64') { 62 } elsif ($arch eq 'ppc64') {
63 #XXX 63 #XXX
64 $re = qr/.*stdu.*r1,-($x{1,8})\(r1\)/o; 64 $re = qr/.*stdu.*r1,-($x{1,8})\(r1\)/o;
65 } elsif ($arch eq 'powerpc') {
66 $re = qr/.*st[dw]u.*r1,-($x{1,8})\(r1\)/o;
65 } elsif ($arch =~ /^s390x?$/) { 67 } elsif ($arch =~ /^s390x?$/) {
66 # 11160: a7 fb ff 60 aghi %r15,-160 68 # 11160: a7 fb ff 60 aghi %r15,-160
67 $re = qr/.*ag?hi.*\%r15,-(([0-9]{2}|[3-9])[0-9]{2})/o; 69 $re = qr/.*ag?hi.*\%r15,-(([0-9]{2}|[3-9])[0-9]{2})/o;
diff --git a/sound/aoa/core/snd-aoa-gpio-feature.c b/sound/aoa/core/snd-aoa-gpio-feature.c
index f69d33357a28..7c26089527f6 100644
--- a/sound/aoa/core/snd-aoa-gpio-feature.c
+++ b/sound/aoa/core/snd-aoa-gpio-feature.c
@@ -56,7 +56,7 @@ static struct device_node *get_gpio(char *name,
56{ 56{
57 struct device_node *np, *gpio; 57 struct device_node *np, *gpio;
58 u32 *reg; 58 u32 *reg;
59 char *audio_gpio; 59 const char *audio_gpio;
60 60
61 *gpioptr = -1; 61 *gpioptr = -1;
62 62
diff --git a/sound/oss/dmasound/dmasound_awacs.c b/sound/oss/dmasound/dmasound_awacs.c
index 4359903f4376..9ae659f82430 100644
--- a/sound/oss/dmasound/dmasound_awacs.c
+++ b/sound/oss/dmasound/dmasound_awacs.c
@@ -347,8 +347,8 @@ int
347setup_audio_gpio(const char *name, const char* compatible, int *gpio_addr, int* gpio_pol) 347setup_audio_gpio(const char *name, const char* compatible, int *gpio_addr, int* gpio_pol)
348{ 348{
349 struct device_node *np; 349 struct device_node *np;
350 u32* pp; 350 const u32* pp;
351 351
352 np = find_devices("gpio"); 352 np = find_devices("gpio");
353 if (!np) 353 if (!np)
354 return -ENODEV; 354 return -ENODEV;
@@ -356,7 +356,8 @@ setup_audio_gpio(const char *name, const char* compatible, int *gpio_addr, int*
356 np = np->child; 356 np = np->child;
357 while(np != 0) { 357 while(np != 0) {
358 if (name) { 358 if (name) {
359 char *property = get_property(np,"audio-gpio",NULL); 359 const char *property =
360 get_property(np,"audio-gpio",NULL);
360 if (property != 0 && strcmp(property,name) == 0) 361 if (property != 0 && strcmp(property,name) == 0)
361 break; 362 break;
362 } else if (compatible && device_is_compatible(np, compatible)) 363 } else if (compatible && device_is_compatible(np, compatible))
@@ -365,11 +366,11 @@ setup_audio_gpio(const char *name, const char* compatible, int *gpio_addr, int*
365 } 366 }
366 if (!np) 367 if (!np)
367 return -ENODEV; 368 return -ENODEV;
368 pp = (u32 *)get_property(np, "AAPL,address", NULL); 369 pp = get_property(np, "AAPL,address", NULL);
369 if (!pp) 370 if (!pp)
370 return -ENODEV; 371 return -ENODEV;
371 *gpio_addr = (*pp) & 0x0000ffff; 372 *gpio_addr = (*pp) & 0x0000ffff;
372 pp = (u32 *)get_property(np, "audio-gpio-active-state", NULL); 373 pp = get_property(np, "audio-gpio-active-state", NULL);
373 if (pp) 374 if (pp)
374 *gpio_pol = *pp; 375 *gpio_pol = *pp;
375 else 376 else
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
index 84f6b19c07ca..6ae2d5b9aa4a 100644
--- a/sound/ppc/tumbler.c
+++ b/sound/ppc/tumbler.c
@@ -1035,7 +1035,7 @@ static struct device_node *find_audio_device(const char *name)
1035 return NULL; 1035 return NULL;
1036 1036
1037 for (np = np->child; np; np = np->sibling) { 1037 for (np = np->child; np; np = np->sibling) {
1038 char *property = get_property(np, "audio-gpio", NULL); 1038 const char *property = get_property(np, "audio-gpio", NULL);
1039 if (property && strcmp(property, name) == 0) 1039 if (property && strcmp(property, name) == 0)
1040 return np; 1040 return np;
1041 } 1041 }
@@ -1062,7 +1062,8 @@ static long tumbler_find_device(const char *device, const char *platform,
1062 struct pmac_gpio *gp, int is_compatible) 1062 struct pmac_gpio *gp, int is_compatible)
1063{ 1063{
1064 struct device_node *node; 1064 struct device_node *node;
1065 u32 *base, addr; 1065 const u32 *base;
1066 u32 addr;
1066 1067
1067 if (is_compatible) 1068 if (is_compatible)
1068 node = find_compatible_audio_device(device); 1069 node = find_compatible_audio_device(device);
@@ -1074,9 +1075,9 @@ static long tumbler_find_device(const char *device, const char *platform,
1074 return -ENODEV; 1075 return -ENODEV;
1075 } 1076 }
1076 1077
1077 base = (u32 *)get_property(node, "AAPL,address", NULL); 1078 base = get_property(node, "AAPL,address", NULL);
1078 if (! base) { 1079 if (! base) {
1079 base = (u32 *)get_property(node, "reg", NULL); 1080 base = get_property(node, "reg", NULL);
1080 if (!base) { 1081 if (!base) {
1081 DBG("(E) cannot find address for device %s !\n", device); 1082 DBG("(E) cannot find address for device %s !\n", device);
1082 snd_printd("cannot find address for device %s\n", device); 1083 snd_printd("cannot find address for device %s\n", device);
@@ -1090,13 +1091,13 @@ static long tumbler_find_device(const char *device, const char *platform,
1090 1091
1091 gp->addr = addr & 0x0000ffff; 1092 gp->addr = addr & 0x0000ffff;
1092 /* Try to find the active state, default to 0 ! */ 1093 /* Try to find the active state, default to 0 ! */
1093 base = (u32 *)get_property(node, "audio-gpio-active-state", NULL); 1094 base = get_property(node, "audio-gpio-active-state", NULL);
1094 if (base) { 1095 if (base) {
1095 gp->active_state = *base; 1096 gp->active_state = *base;
1096 gp->active_val = (*base) ? 0x5 : 0x4; 1097 gp->active_val = (*base) ? 0x5 : 0x4;
1097 gp->inactive_val = (*base) ? 0x4 : 0x5; 1098 gp->inactive_val = (*base) ? 0x4 : 0x5;
1098 } else { 1099 } else {
1099 u32 *prop = NULL; 1100 const u32 *prop = NULL;
1100 gp->active_state = 0; 1101 gp->active_state = 0;
1101 gp->active_val = 0x4; 1102 gp->active_val = 0x4;
1102 gp->inactive_val = 0x5; 1103 gp->inactive_val = 0x5;
@@ -1105,7 +1106,7 @@ static long tumbler_find_device(const char *device, const char *platform,
1105 * as we don't yet have an interpreter for these things 1106 * as we don't yet have an interpreter for these things
1106 */ 1107 */
1107 if (platform) 1108 if (platform)
1108 prop = (u32 *)get_property(node, platform, NULL); 1109 prop = get_property(node, platform, NULL);
1109 if (prop) { 1110 if (prop) {
1110 if (prop[3] == 0x9 && prop[4] == 0x9) { 1111 if (prop[3] == 0x9 && prop[4] == 0x9) {
1111 gp->active_val = 0xd; 1112 gp->active_val = 0xd;