aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/powerpc/booting-without-of.txt256
-rw-r--r--arch/powerpc/Kconfig472
-rw-r--r--arch/powerpc/Kconfig.debug12
-rw-r--r--arch/powerpc/Makefile11
-rw-r--r--arch/powerpc/boot/.gitignore3
-rw-r--r--arch/powerpc/boot/Makefile122
-rw-r--r--arch/powerpc/boot/crt0.S37
-rw-r--r--arch/powerpc/boot/cuboot-83xx.c68
-rw-r--r--arch/powerpc/boot/cuboot-85xx.c69
-rw-r--r--arch/powerpc/boot/devtree.c307
-rw-r--r--arch/powerpc/boot/dts/kuroboxHD.dts7
-rw-r--r--arch/powerpc/boot/dts/kuroboxHG.dts7
-rw-r--r--arch/powerpc/boot/dts/lite5200.dts1
-rw-r--r--arch/powerpc/boot/dts/lite5200b.dts1
-rw-r--r--arch/powerpc/boot/dts/mpc7448hpc2.dts1
-rw-r--r--arch/powerpc/boot/dts/mpc8272ads.dts1
-rw-r--r--arch/powerpc/boot/dts/mpc8313erdb.dts1
-rw-r--r--arch/powerpc/boot/dts/mpc832x_mds.dts1
-rw-r--r--arch/powerpc/boot/dts/mpc832x_rdb.dts291
-rw-r--r--arch/powerpc/boot/dts/mpc8349emitx.dts1
-rw-r--r--arch/powerpc/boot/dts/mpc8349emitxgp.dts1
-rw-r--r--arch/powerpc/boot/dts/mpc834x_mds.dts1
-rw-r--r--arch/powerpc/boot/dts/mpc836x_mds.dts1
-rw-r--r--arch/powerpc/boot/dts/mpc8540ads.dts1
-rw-r--r--arch/powerpc/boot/dts/mpc8541cds.dts1
-rw-r--r--arch/powerpc/boot/dts/mpc8544ds.dts136
-rw-r--r--arch/powerpc/boot/dts/mpc8548cds.dts1
-rw-r--r--arch/powerpc/boot/dts/mpc8555cds.dts1
-rw-r--r--arch/powerpc/boot/dts/mpc8560ads.dts1
-rw-r--r--arch/powerpc/boot/dts/mpc8568mds.dts1
-rw-r--r--arch/powerpc/boot/dts/mpc8641_hpcn.dts25
-rw-r--r--arch/powerpc/boot/dts/mpc866ads.dts1
-rw-r--r--arch/powerpc/boot/dts/mpc885ads.dts1
-rw-r--r--arch/powerpc/boot/elf.h8
-rw-r--r--arch/powerpc/boot/elf_util.c76
-rw-r--r--arch/powerpc/boot/flatdevtree.c199
-rw-r--r--arch/powerpc/boot/flatdevtree.h7
-rw-r--r--arch/powerpc/boot/flatdevtree_misc.c42
-rw-r--r--arch/powerpc/boot/gunzip_util.c206
-rw-r--r--arch/powerpc/boot/gunzip_util.h45
-rw-r--r--arch/powerpc/boot/main.c369
-rw-r--r--arch/powerpc/boot/ns16550.c9
-rw-r--r--arch/powerpc/boot/of.c21
-rw-r--r--arch/powerpc/boot/ops.h103
-rw-r--r--arch/powerpc/boot/ppcboot.h108
-rw-r--r--arch/powerpc/boot/reg.h22
-rw-r--r--arch/powerpc/boot/simple_alloc.c31
-rw-r--r--arch/powerpc/boot/stdio.h5
-rwxr-xr-xarch/powerpc/boot/wrapper53
-rw-r--r--arch/powerpc/boot/zImage.coff.lds.S3
-rw-r--r--arch/powerpc/boot/zImage.lds.S1
-rw-r--r--arch/powerpc/configs/cell_defconfig57
-rw-r--r--arch/powerpc/configs/g5_defconfig2
-rw-r--r--arch/powerpc/configs/maple_defconfig2
-rw-r--r--arch/powerpc/configs/mpc832x_rdb_defconfig1292
-rw-r--r--arch/powerpc/configs/mpc8544_ds_defconfig1077
-rw-r--r--arch/powerpc/configs/ppc64_defconfig2
-rw-r--r--arch/powerpc/kernel/Makefile4
-rw-r--r--arch/powerpc/kernel/align.c56
-rw-r--r--arch/powerpc/kernel/asm-offsets.c2
-rw-r--r--arch/powerpc/kernel/btext.c22
-rw-r--r--arch/powerpc/kernel/cpu_setup_pa6t.S2
-rw-r--r--arch/powerpc/kernel/cputable.c14
-rw-r--r--arch/powerpc/kernel/entry_32.S1
-rw-r--r--arch/powerpc/kernel/head_64.S16
-rw-r--r--arch/powerpc/kernel/ibmebus.c288
-rw-r--r--arch/powerpc/kernel/iommu.c35
-rw-r--r--arch/powerpc/kernel/irq.c2
-rw-r--r--arch/powerpc/kernel/kprobes.c36
-rw-r--r--arch/powerpc/kernel/legacy_serial.c24
-rw-r--r--arch/powerpc/kernel/lparcfg.c58
-rw-r--r--arch/powerpc/kernel/machine_kexec_64.c14
-rw-r--r--arch/powerpc/kernel/misc_32.S4
-rw-r--r--arch/powerpc/kernel/of_device.c112
-rw-r--r--arch/powerpc/kernel/of_platform.c5
-rw-r--r--arch/powerpc/kernel/pci_32.c42
-rw-r--r--arch/powerpc/kernel/pci_64.c32
-rw-r--r--arch/powerpc/kernel/pci_dn.c9
-rw-r--r--arch/powerpc/kernel/ppc_ksyms.c1
-rw-r--r--arch/powerpc/kernel/process.c54
-rw-r--r--arch/powerpc/kernel/prom.c167
-rw-r--r--arch/powerpc/kernel/prom_init.c55
-rw-r--r--arch/powerpc/kernel/prom_parse.c51
-rw-r--r--arch/powerpc/kernel/rtas-proc.c4
-rw-r--r--arch/powerpc/kernel/rtas.c19
-rw-r--r--arch/powerpc/kernel/rtas_pci.c14
-rw-r--r--arch/powerpc/kernel/setup-common.c68
-rw-r--r--arch/powerpc/kernel/setup_32.c17
-rw-r--r--arch/powerpc/kernel/setup_64.c11
-rw-r--r--arch/powerpc/kernel/smp.c4
-rw-r--r--arch/powerpc/kernel/sys_ppc32.c4
-rw-r--r--arch/powerpc/kernel/sysfs.c17
-rw-r--r--arch/powerpc/kernel/time.c2
-rw-r--r--arch/powerpc/kernel/traps.c76
-rw-r--r--arch/powerpc/kernel/vio.c17
-rw-r--r--arch/powerpc/lib/copyuser_64.S6
-rw-r--r--arch/powerpc/lib/locks.c4
-rw-r--r--arch/powerpc/lib/mem_64.S6
-rw-r--r--arch/powerpc/lib/memcpy_64.S6
-rw-r--r--arch/powerpc/lib/sstep.c45
-rw-r--r--arch/powerpc/mm/hash_low_32.S22
-rw-r--r--arch/powerpc/mm/hash_low_64.S5
-rw-r--r--arch/powerpc/mm/hash_native_64.c2
-rw-r--r--arch/powerpc/mm/hash_utils_64.c127
-rw-r--r--arch/powerpc/mm/hugetlbpage.c16
-rw-r--r--arch/powerpc/mm/init_32.c4
-rw-r--r--arch/powerpc/mm/lmb.c4
-rw-r--r--arch/powerpc/mm/mem.c3
-rw-r--r--arch/powerpc/mm/mmu_decl.h5
-rw-r--r--arch/powerpc/mm/numa.c24
-rw-r--r--arch/powerpc/mm/pgtable_32.c76
-rw-r--r--arch/powerpc/mm/ppc_mmu_32.c4
-rw-r--r--arch/powerpc/mm/tlb_64.c68
-rw-r--r--arch/powerpc/oprofile/Makefile2
-rw-r--r--arch/powerpc/oprofile/common.c3
-rw-r--r--arch/powerpc/oprofile/op_model_cell.c3
-rw-r--r--arch/powerpc/oprofile/op_model_pa6t.c234
-rw-r--r--arch/powerpc/platforms/4xx/Kconfig372
-rw-r--r--arch/powerpc/platforms/52xx/Kconfig35
-rw-r--r--arch/powerpc/platforms/52xx/efika.c15
-rw-r--r--arch/powerpc/platforms/52xx/lite5200.c12
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_common.c2
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_pci.c2
-rw-r--r--arch/powerpc/platforms/82xx/Kconfig45
-rw-r--r--arch/powerpc/platforms/82xx/mpc82xx.c6
-rw-r--r--arch/powerpc/platforms/82xx/mpc82xx_ads.c12
-rw-r--r--arch/powerpc/platforms/83xx/Kconfig15
-rw-r--r--arch/powerpc/platforms/83xx/Makefile1
-rw-r--r--arch/powerpc/platforms/83xx/mpc832x_mds.c1
-rw-r--r--arch/powerpc/platforms/83xx/mpc832x_mds.h19
-rw-r--r--arch/powerpc/platforms/83xx/mpc832x_rdb.c138
-rw-r--r--arch/powerpc/platforms/83xx/mpc834x_itx.h23
-rw-r--r--arch/powerpc/platforms/83xx/pci.c2
-rw-r--r--arch/powerpc/platforms/85xx/Kconfig38
-rw-r--r--arch/powerpc/platforms/85xx/Makefile1
-rw-r--r--arch/powerpc/platforms/85xx/mpc8544_ds.c144
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_ads.c2
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_cds.c2
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_mds.c2
-rw-r--r--arch/powerpc/platforms/85xx/pci.c2
-rw-r--r--arch/powerpc/platforms/86xx/Kconfig18
-rw-r--r--arch/powerpc/platforms/86xx/Makefile2
-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/8xx/Kconfig67
-rw-r--r--arch/powerpc/platforms/8xx/m8xx_setup.c8
-rw-r--r--arch/powerpc/platforms/8xx/mpc86xads.h2
-rw-r--r--arch/powerpc/platforms/8xx/mpc86xads_setup.c4
-rw-r--r--arch/powerpc/platforms/8xx/mpc885ads.h2
-rw-r--r--arch/powerpc/platforms/8xx/mpc885ads_setup.c4
-rw-r--r--arch/powerpc/platforms/Kconfig259
-rw-r--r--arch/powerpc/platforms/cell/Kconfig24
-rw-r--r--arch/powerpc/platforms/cell/cbe_cpufreq.c112
-rw-r--r--arch/powerpc/platforms/cell/cbe_regs.c168
-rw-r--r--arch/powerpc/platforms/cell/cbe_regs.h5
-rw-r--r--arch/powerpc/platforms/cell/cbe_thermal.c181
-rw-r--r--arch/powerpc/platforms/cell/interrupt.c4
-rw-r--r--arch/powerpc/platforms/cell/io-workarounds.c2
-rw-r--r--arch/powerpc/platforms/cell/iommu.c16
-rw-r--r--arch/powerpc/platforms/cell/ras.c160
-rw-r--r--arch/powerpc/platforms/cell/setup.c12
-rw-r--r--arch/powerpc/platforms/cell/spider-pic.c8
-rw-r--r--arch/powerpc/platforms/cell/spu_base.c163
-rw-r--r--arch/powerpc/platforms/cell/spu_coredump.c34
-rw-r--r--arch/powerpc/platforms/cell/spu_manage.c18
-rw-r--r--arch/powerpc/platforms/cell/spufs/Makefile2
-rw-r--r--arch/powerpc/platforms/cell/spufs/backing_ops.c6
-rw-r--r--arch/powerpc/platforms/cell/spufs/context.c45
-rw-r--r--arch/powerpc/platforms/cell/spufs/coredump.c19
-rw-r--r--arch/powerpc/platforms/cell/spufs/fault.c211
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c152
-rw-r--r--arch/powerpc/platforms/cell/spufs/hw_ops.c9
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c44
-rw-r--r--arch/powerpc/platforms/cell/spufs/run.c123
-rw-r--r--arch/powerpc/platforms/cell/spufs/sched.c113
-rw-r--r--arch/powerpc/platforms/cell/spufs/spufs.h34
-rw-r--r--arch/powerpc/platforms/cell/spufs/switch.c8
-rw-r--r--arch/powerpc/platforms/celleb/Kconfig9
-rw-r--r--arch/powerpc/platforms/celleb/iommu.c6
-rw-r--r--arch/powerpc/platforms/celleb/pci.c18
-rw-r--r--arch/powerpc/platforms/celleb/setup.c12
-rw-r--r--arch/powerpc/platforms/chrp/Kconfig11
-rw-r--r--arch/powerpc/platforms/chrp/nvram.c2
-rw-r--r--arch/powerpc/platforms/chrp/pci.c25
-rw-r--r--arch/powerpc/platforms/chrp/setup.c52
-rw-r--r--arch/powerpc/platforms/chrp/time.c13
-rw-r--r--arch/powerpc/platforms/embedded6xx/Kconfig264
-rw-r--r--arch/powerpc/platforms/embedded6xx/linkstation.c8
-rw-r--r--arch/powerpc/platforms/embedded6xx/ls_uart.c4
-rw-r--r--arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c15
-rw-r--r--arch/powerpc/platforms/iseries/Kconfig4
-rw-r--r--arch/powerpc/platforms/iseries/iommu.c4
-rw-r--r--arch/powerpc/platforms/iseries/irq.c4
-rw-r--r--arch/powerpc/platforms/iseries/pci.c5
-rw-r--r--arch/powerpc/platforms/iseries/setup.c10
-rw-r--r--arch/powerpc/platforms/iseries/viopath.c2
-rw-r--r--arch/powerpc/platforms/maple/Kconfig17
-rw-r--r--arch/powerpc/platforms/maple/pci.c8
-rw-r--r--arch/powerpc/platforms/maple/setup.c17
-rw-r--r--arch/powerpc/platforms/pasemi/Kconfig19
-rw-r--r--arch/powerpc/platforms/pasemi/Makefile3
-rw-r--r--arch/powerpc/platforms/pasemi/cpufreq.c308
-rw-r--r--arch/powerpc/platforms/pasemi/gpio_mdio.c339
-rw-r--r--arch/powerpc/platforms/pasemi/idle.c9
-rw-r--r--arch/powerpc/platforms/pasemi/iommu.c6
-rw-r--r--arch/powerpc/platforms/pasemi/pasemi.h8
-rw-r--r--arch/powerpc/platforms/pasemi/pci.c16
-rw-r--r--arch/powerpc/platforms/pasemi/setup.c28
-rw-r--r--arch/powerpc/platforms/powermac/Kconfig20
-rw-r--r--arch/powerpc/platforms/powermac/backlight.c9
-rw-r--r--arch/powerpc/platforms/powermac/cpufreq_32.c24
-rw-r--r--arch/powerpc/platforms/powermac/cpufreq_64.c16
-rw-r--r--arch/powerpc/platforms/powermac/feature.c101
-rw-r--r--arch/powerpc/platforms/powermac/low_i2c.c15
-rw-r--r--arch/powerpc/platforms/powermac/pci.c41
-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/pic.c8
-rw-r--r--arch/powerpc/platforms/powermac/setup.c61
-rw-r--r--arch/powerpc/platforms/powermac/smp.c11
-rw-r--r--arch/powerpc/platforms/powermac/time.c38
-rw-r--r--arch/powerpc/platforms/powermac/udbg_scc.c6
-rw-r--r--arch/powerpc/platforms/prep/Kconfig9
-rw-r--r--arch/powerpc/platforms/ps3/Kconfig16
-rw-r--r--arch/powerpc/platforms/ps3/htab.c2
-rw-r--r--arch/powerpc/platforms/pseries/Kconfig10
-rw-r--r--arch/powerpc/platforms/pseries/Makefile5
-rw-r--r--arch/powerpc/platforms/pseries/eeh.c204
-rw-r--r--arch/powerpc/platforms/pseries/eeh_driver.c78
-rw-r--r--arch/powerpc/platforms/pseries/eeh_event.c8
-rw-r--r--arch/powerpc/platforms/pseries/firmware.c2
-rw-r--r--arch/powerpc/platforms/pseries/hotplug-cpu.c4
-rw-r--r--arch/powerpc/platforms/pseries/iommu.c67
-rw-r--r--arch/powerpc/platforms/pseries/lpar.c6
-rw-r--r--arch/powerpc/platforms/pseries/nvram.c2
-rw-r--r--arch/powerpc/platforms/pseries/pci.c3
-rw-r--r--arch/powerpc/platforms/pseries/pci_dlpar.c1
-rw-r--r--arch/powerpc/platforms/pseries/ras.c2
-rw-r--r--arch/powerpc/platforms/pseries/rtasd.c2
-rw-r--r--arch/powerpc/platforms/pseries/setup.c44
-rw-r--r--arch/powerpc/platforms/pseries/xics.c17
-rw-r--r--arch/powerpc/sysdev/Makefile5
-rw-r--r--arch/powerpc/sysdev/dart_iommu.c4
-rw-r--r--arch/powerpc/sysdev/dcr.c14
-rw-r--r--arch/powerpc/sysdev/fsl_pcie.c (renamed from arch/powerpc/platforms/86xx/mpc86xx_pcie.c)2
-rw-r--r--arch/powerpc/sysdev/fsl_pcie.h94
-rw-r--r--arch/powerpc/sysdev/fsl_soc.c90
-rw-r--r--arch/powerpc/sysdev/mpic.c32
-rw-r--r--arch/powerpc/sysdev/pmi.c29
-rw-r--r--arch/powerpc/sysdev/qe_lib/Kconfig10
-rw-r--r--arch/powerpc/sysdev/qe_lib/qe.c4
-rw-r--r--arch/powerpc/sysdev/qe_lib/qe_io.c6
-rw-r--r--arch/powerpc/sysdev/qe_lib/ucc_slow.c4
-rw-r--r--arch/powerpc/sysdev/timer.c71
-rw-r--r--arch/powerpc/sysdev/tsi108_dev.c16
-rw-r--r--arch/powerpc/sysdev/tsi108_pci.c2
-rw-r--r--arch/powerpc/sysdev/uic.c342
-rw-r--r--arch/powerpc/xmon/xmon.c11
-rw-r--r--arch/ppc/8xx_io/Kconfig4
-rw-r--r--arch/ppc/8xx_io/Makefile1
-rw-r--r--arch/ppc/8xx_io/cs4218.h166
-rw-r--r--arch/ppc/8xx_io/cs4218_tdm.c2833
-rw-r--r--arch/ppc/boot/common/misc-common.c15
-rw-r--r--arch/ppc/boot/simple/Makefile1
-rw-r--r--arch/ppc/boot/simple/uartlite_tty.c37
-rw-r--r--arch/ppc/kernel/asm-offsets.c1
-rw-r--r--arch/ppc/kernel/entry.S1
-rw-r--r--arch/ppc/platforms/4xx/Kconfig15
-rw-r--r--arch/ppc/platforms/4xx/Makefile1
-rw-r--r--arch/ppc/platforms/4xx/ocotea.c4
-rw-r--r--arch/ppc/platforms/4xx/taishan.c2
-rw-r--r--arch/ppc/platforms/4xx/virtex.c56
-rw-r--r--arch/ppc/platforms/4xx/virtex.h34
-rw-r--r--arch/ppc/platforms/4xx/xilinx_ml300.c65
-rw-r--r--arch/ppc/platforms/4xx/xilinx_ml300.h45
-rw-r--r--arch/ppc/platforms/4xx/xilinx_ml403.c66
-rw-r--r--arch/ppc/platforms/4xx/xilinx_ml403.h49
-rw-r--r--arch/ppc/platforms/4xx/xparameters/xparameters.h60
-rw-r--r--arch/ppc/platforms/rpxclassic.h4
-rw-r--r--arch/ppc/platforms/rpxhiox.h41
-rw-r--r--arch/ppc/platforms/rpxlite.h4
-rw-r--r--arch/ppc/syslib/Makefile3
-rw-r--r--arch/ppc/syslib/cpc710.h81
-rw-r--r--arch/ppc/syslib/m8xx_setup.c2
-rw-r--r--arch/ppc/syslib/ppc4xx_sgdma.c1
-rw-r--r--arch/ppc/syslib/virtex_devices.c233
-rw-r--r--arch/ppc/syslib/virtex_devices.h27
-rw-r--r--drivers/char/briq_panel.c7
-rw-r--r--drivers/char/hvc_console.c49
-rw-r--r--drivers/char/hvc_iseries.c2
-rw-r--r--drivers/char/hvc_vio.c2
-rw-r--r--drivers/char/hvsi.c4
-rw-r--r--drivers/char/tpm/tpm_atmel.h4
-rw-r--r--drivers/char/watchdog/Kconfig2
-rw-r--r--drivers/hwmon/ams/ams-core.c4
-rw-r--r--drivers/hwmon/ams/ams-i2c.c4
-rw-r--r--drivers/hwmon/ams/ams-pmu.c4
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c4
-rw-r--r--drivers/macintosh/adb.c42
-rw-r--r--drivers/macintosh/ans-lcd.c9
-rw-r--r--drivers/macintosh/apm_emu.c13
-rw-r--r--drivers/macintosh/mac_hid.c2
-rw-r--r--drivers/macintosh/macio-adb.c16
-rw-r--r--drivers/macintosh/macio_asic.c100
-rw-r--r--drivers/macintosh/macio_sysfs.c10
-rw-r--r--drivers/macintosh/rack-meter.c2
-rw-r--r--drivers/macintosh/smu.c8
-rw-r--r--drivers/macintosh/therm_adt746x.c8
-rw-r--r--drivers/macintosh/therm_pm72.c8
-rw-r--r--drivers/macintosh/therm_windtunnel.c2
-rw-r--r--drivers/macintosh/via-cuda.c2
-rw-r--r--drivers/macintosh/via-pmu-led.c10
-rw-r--r--drivers/macintosh/via-pmu.c55
-rw-r--r--drivers/macintosh/windfarm_lm75_sensor.c2
-rw-r--r--drivers/macintosh/windfarm_max6690_sensor.c2
-rw-r--r--drivers/macintosh/windfarm_smu_controls.c8
-rw-r--r--drivers/macintosh/windfarm_smu_sat.c8
-rw-r--r--drivers/macintosh/windfarm_smu_sensors.c6
-rw-r--r--drivers/media/video/planb.c5
-rw-r--r--drivers/net/Kconfig9
-rw-r--r--drivers/ps3/vuart.c8
-rw-r--r--drivers/scsi/ibmvscsi/ibmvstgt.c7
-rw-r--r--drivers/scsi/ibmvscsi/rpa_vscsi.c3
-rw-r--r--drivers/serial/pmac_zilog.c4
-rw-r--r--drivers/video/Kconfig2
-rw-r--r--drivers/video/aty/radeon_pm.c2
-rw-r--r--drivers/video/controlfb.c16
-rw-r--r--fs/proc/proc_devtree.c2
-rw-r--r--include/asm-powerpc/asm-compat.h10
-rw-r--r--include/asm-powerpc/cacheflush.h6
-rw-r--r--include/asm-powerpc/cell-pmu.h5
-rw-r--r--include/asm-powerpc/cputable.h11
-rw-r--r--include/asm-powerpc/current.h1
-rw-r--r--include/asm-powerpc/edac.h40
-rw-r--r--include/asm-powerpc/eeh_event.h6
-rw-r--r--include/asm-powerpc/ibmebus.h44
-rw-r--r--include/asm-powerpc/immap_86xx.h75
-rw-r--r--include/asm-powerpc/io.h7
-rw-r--r--include/asm-powerpc/kprobes.h5
-rw-r--r--include/asm-powerpc/machdep.h3
-rw-r--r--include/asm-powerpc/mmu-hash64.h400
-rw-r--r--include/asm-powerpc/mmu.h405
-rw-r--r--include/asm-powerpc/mpic.h12
-rw-r--r--include/asm-powerpc/of_device.h3
-rw-r--r--include/asm-powerpc/oprofile_impl.h2
-rw-r--r--include/asm-powerpc/paca.h4
-rw-r--r--include/asm-powerpc/parport.h6
-rw-r--r--include/asm-powerpc/pci.h14
-rw-r--r--include/asm-powerpc/pgtable-4k.h3
-rw-r--r--include/asm-powerpc/pgtable-64k.h5
-rw-r--r--include/asm-powerpc/pgtable.h60
-rw-r--r--include/asm-powerpc/pmc.h1
-rw-r--r--include/asm-powerpc/ppc-pci.h12
-rw-r--r--include/asm-powerpc/processor.h1
-rw-r--r--include/asm-powerpc/prom.h34
-rw-r--r--include/asm-powerpc/reg.h68
-rw-r--r--include/asm-powerpc/spu_csa.h1
-rw-r--r--include/asm-powerpc/system.h1
-rw-r--r--include/asm-powerpc/tlb.h1
-rw-r--r--include/asm-powerpc/tlbflush.h172
-rw-r--r--include/asm-powerpc/uaccess.h28
-rw-r--r--include/asm-powerpc/uic.h23
-rw-r--r--include/asm-ppc/ibm4xx.h8
-rw-r--r--include/asm-ppc/ppc_sys.h2
-rw-r--r--include/asm-ppc/prom.h3
-rw-r--r--include/linux/pmu.h12
-rw-r--r--sound/aoa/codecs/snd-aoa-codec-onyx.c4
-rw-r--r--sound/aoa/codecs/snd-aoa-codec-tas.c9
-rw-r--r--sound/aoa/core/snd-aoa-gpio-feature.c8
-rw-r--r--sound/aoa/fabrics/snd-aoa-fabric-layout.c8
-rw-r--r--sound/aoa/soundbus/core.c4
-rw-r--r--sound/aoa/soundbus/i2sbus/i2sbus-core.c8
-rw-r--r--sound/oss/dmasound/dmasound_awacs.c121
-rw-r--r--sound/oss/dmasound/tas_common.c9
-rw-r--r--sound/ppc/pmac.c41
-rw-r--r--sound/ppc/tumbler.c55
376 files changed, 11546 insertions, 7892 deletions
diff --git a/Documentation/powerpc/booting-without-of.txt b/Documentation/powerpc/booting-without-of.txt
index b41397d6430a..033a3f3b3ab7 100644
--- a/Documentation/powerpc/booting-without-of.txt
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -39,7 +39,7 @@
39 and property data. The old style variable 39 and property data. The old style variable
40 alignment would make it impossible to do 40 alignment would make it impossible to do
41 "simple" insertion of properties using 41 "simple" insertion of properties using
42 memove (thanks Milton for 42 memmove (thanks Milton for
43 noticing). Updated kernel patch as well 43 noticing). Updated kernel patch as well
44 - Correct a few more alignment constraints 44 - Correct a few more alignment constraints
45 - Add a chapter about the device-tree 45 - Add a chapter about the device-tree
@@ -55,7 +55,7 @@
55 55
56 ToDo: 56 ToDo:
57 - Add some definitions of interrupt tree (simple/complex) 57 - Add some definitions of interrupt tree (simple/complex)
58 - Add some definitions for pci host bridges 58 - Add some definitions for PCI host bridges
59 - Add some common address format examples 59 - Add some common address format examples
60 - Add definitions for standard properties and "compatible" 60 - Add definitions for standard properties and "compatible"
61 names for cells that are not already defined by the existing 61 names for cells that are not already defined by the existing
@@ -114,7 +114,7 @@ it with special cases.
114 forth words isn't required), you can enter the kernel with: 114 forth words isn't required), you can enter the kernel with:
115 115
116 r5 : OF callback pointer as defined by IEEE 1275 116 r5 : OF callback pointer as defined by IEEE 1275
117 bindings to powerpc. Only the 32 bit client interface 117 bindings to powerpc. Only the 32-bit client interface
118 is currently supported 118 is currently supported
119 119
120 r3, r4 : address & length of an initrd if any or 0 120 r3, r4 : address & length of an initrd if any or 0
@@ -194,7 +194,7 @@ it with special cases.
194 for this is to keep kernels on embedded systems small and efficient; 194 for this is to keep kernels on embedded systems small and efficient;
195 part of this is due to the fact the code is already that way. In the 195 part of this is due to the fact the code is already that way. In the
196 future, a kernel may support multiple platforms, but only if the 196 future, a kernel may support multiple platforms, but only if the
197 platforms feature the same core architectire. A single kernel build 197 platforms feature the same core architecture. A single kernel build
198 cannot support both configurations with Book E and configurations 198 cannot support both configurations with Book E and configurations
199 with classic Powerpc architectures. 199 with classic Powerpc architectures.
200 200
@@ -215,7 +215,7 @@ of the boot sequences.... someone speak up if this is wrong!
215 enable another config option to select the specific board 215 enable another config option to select the specific board
216 supported. 216 supported.
217 217
218NOTE: If ben doesn't merge the setup files, may need to change this to 218NOTE: If Ben doesn't merge the setup files, may need to change this to
219point to setup_32.c 219point to setup_32.c
220 220
221 221
@@ -256,7 +256,7 @@ struct boot_param_header {
256 u32 off_dt_struct; /* offset to structure */ 256 u32 off_dt_struct; /* offset to structure */
257 u32 off_dt_strings; /* offset to strings */ 257 u32 off_dt_strings; /* offset to strings */
258 u32 off_mem_rsvmap; /* offset to memory reserve map 258 u32 off_mem_rsvmap; /* offset to memory reserve map
259*/ 259 */
260 u32 version; /* format version */ 260 u32 version; /* format version */
261 u32 last_comp_version; /* last compatible version */ 261 u32 last_comp_version; /* last compatible version */
262 262
@@ -265,6 +265,9 @@ struct boot_param_header {
265 booting on */ 265 booting on */
266 /* version 3 fields below */ 266 /* version 3 fields below */
267 u32 size_dt_strings; /* size of the strings block */ 267 u32 size_dt_strings; /* size of the strings block */
268
269 /* version 17 fields below */
270 u32 size_dt_struct; /* size of the DT structure block */
268}; 271};
269 272
270 Along with the constants: 273 Along with the constants:
@@ -273,7 +276,7 @@ struct boot_param_header {
273#define OF_DT_HEADER 0xd00dfeed /* 4: version, 276#define OF_DT_HEADER 0xd00dfeed /* 4: version,
274 4: total size */ 277 4: total size */
275#define OF_DT_BEGIN_NODE 0x1 /* Start node: full name 278#define OF_DT_BEGIN_NODE 0x1 /* Start node: full name
276*/ 279 */
277#define OF_DT_END_NODE 0x2 /* End node */ 280#define OF_DT_END_NODE 0x2 /* End node */
278#define OF_DT_PROP 0x3 /* Property: name off, 281#define OF_DT_PROP 0x3 /* Property: name off,
279 size, content */ 282 size, content */
@@ -310,9 +313,8 @@ struct boot_param_header {
310 - off_mem_rsvmap 313 - off_mem_rsvmap
311 314
312 This is an offset from the beginning of the header to the start 315 This is an offset from the beginning of the header to the start
313 of the reserved memory map. This map is a list of pairs of 64 316 of the reserved memory map. This map is a list of pairs of 64-
314 bit integers. Each pair is a physical address and a size. The 317 bit integers. Each pair is a physical address and a size. The
315
316 list is terminated by an entry of size 0. This map provides the 318 list is terminated by an entry of size 0. This map provides the
317 kernel with a list of physical memory areas that are "reserved" 319 kernel with a list of physical memory areas that are "reserved"
318 and thus not to be used for memory allocations, especially during 320 and thus not to be used for memory allocations, especially during
@@ -325,7 +327,7 @@ struct boot_param_header {
325 contain _at least_ this DT block itself (header,total_size). If 327 contain _at least_ this DT block itself (header,total_size). If
326 you are passing an initrd to the kernel, you should reserve it as 328 you are passing an initrd to the kernel, you should reserve it as
327 well. You do not need to reserve the kernel image itself. The map 329 well. You do not need to reserve the kernel image itself. The map
328 should be 64 bit aligned. 330 should be 64-bit aligned.
329 331
330 - version 332 - version
331 333
@@ -335,10 +337,13 @@ struct boot_param_header {
335 to reallocate it easily at boot and free up the unused flattened 337 to reallocate it easily at boot and free up the unused flattened
336 structure after expansion. Version 16 introduces a new more 338 structure after expansion. Version 16 introduces a new more
337 "compact" format for the tree itself that is however not backward 339 "compact" format for the tree itself that is however not backward
338 compatible. You should always generate a structure of the highest 340 compatible. Version 17 adds an additional field, size_dt_struct,
339 version defined at the time of your implementation. Currently 341 allowing it to be reallocated or moved more easily (this is
340 that is version 16, unless you explicitly aim at being backward 342 particularly useful for bootloaders which need to make
341 compatible. 343 adjustments to a device tree based on probed information). You
344 should always generate a structure of the highest version defined
345 at the time of your implementation. Currently that is version 17,
346 unless you explicitly aim at being backward compatible.
342 347
343 - last_comp_version 348 - last_comp_version
344 349
@@ -347,7 +352,7 @@ struct boot_param_header {
347 is backward compatible with version 1 (that is, a kernel build 352 is backward compatible with version 1 (that is, a kernel build
348 for version 1 will be able to boot with a version 2 format). You 353 for version 1 will be able to boot with a version 2 format). You
349 should put a 1 in this field if you generate a device tree of 354 should put a 1 in this field if you generate a device tree of
350 version 1 to 3, or 0x10 if you generate a tree of version 0x10 355 version 1 to 3, or 16 if you generate a tree of version 16 or 17
351 using the new unit name format. 356 using the new unit name format.
352 357
353 - boot_cpuid_phys 358 - boot_cpuid_phys
@@ -360,6 +365,17 @@ struct boot_param_header {
360 point (see further chapters for more informations on the required 365 point (see further chapters for more informations on the required
361 device-tree contents) 366 device-tree contents)
362 367
368 - size_dt_strings
369
370 This field only exists on version 3 and later headers. It
371 gives the size of the "strings" section of the device tree (which
372 starts at the offset given by off_dt_strings).
373
374 - size_dt_struct
375
376 This field only exists on version 17 and later headers. It gives
377 the size of the "structure" section of the device tree (which
378 starts at the offset given by off_dt_struct).
363 379
364 So the typical layout of a DT block (though the various parts don't 380 So the typical layout of a DT block (though the various parts don't
365 need to be in that order) looks like this (addresses go from top to 381 need to be in that order) looks like this (addresses go from top to
@@ -417,7 +433,7 @@ root node who has no parent.
417A node has 2 names. The actual node name is generally contained in a 433A node has 2 names. The actual node name is generally contained in a
418property of type "name" in the node property list whose value is a 434property of type "name" in the node property list whose value is a
419zero terminated string and is mandatory for version 1 to 3 of the 435zero terminated string and is mandatory for version 1 to 3 of the
420format definition (as it is in Open Firmware). Version 0x10 makes it 436format definition (as it is in Open Firmware). Version 16 makes it
421optional as it can generate it from the unit name defined below. 437optional as it can generate it from the unit name defined below.
422 438
423There is also a "unit name" that is used to differentiate nodes with 439There is also a "unit name" that is used to differentiate nodes with
@@ -461,7 +477,7 @@ referencing another node via "phandle" is when laying out the
461interrupt tree which will be described in a further version of this 477interrupt tree which will be described in a further version of this
462document. 478document.
463 479
464This "linux, phandle" property is a 32 bit value that uniquely 480This "linux, phandle" property is a 32-bit value that uniquely
465identifies a node. You are free to use whatever values or system of 481identifies a node. You are free to use whatever values or system of
466values, internal pointers, or whatever to generate these, the only 482values, internal pointers, or whatever to generate these, the only
467requirement is that every node for which you provide that property has 483requirement is that every node for which you provide that property has
@@ -471,7 +487,7 @@ Here is an example of a simple device-tree. In this example, an "o"
471designates a node followed by the node unit name. Properties are 487designates a node followed by the node unit name. Properties are
472presented with their name followed by their content. "content" 488presented with their name followed by their content. "content"
473represents an ASCII string (zero terminated) value, while <content> 489represents an ASCII string (zero terminated) value, while <content>
474represents a 32 bit hexadecimal value. The various nodes in this 490represents a 32-bit hexadecimal value. The various nodes in this
475example will be discussed in a later chapter. At this point, it is 491example will be discussed in a later chapter. At this point, it is
476only meant to give you a idea of what a device-tree looks like. I have 492only meant to give you a idea of what a device-tree looks like. I have
477purposefully kept the "name" and "linux,phandle" properties which 493purposefully kept the "name" and "linux,phandle" properties which
@@ -543,15 +559,15 @@ Here's the basic structure of a single node:
543 * [align gap to next 4 bytes boundary] 559 * [align gap to next 4 bytes boundary]
544 * for each property: 560 * for each property:
545 * token OF_DT_PROP (that is 0x00000003) 561 * token OF_DT_PROP (that is 0x00000003)
546 * 32 bit value of property value size in bytes (or 0 of no 562 * 32-bit value of property value size in bytes (or 0 if no
547 * value) 563 value)
548 * 32 bit value of offset in string block of property name 564 * 32-bit value of offset in string block of property name
549 * property value data if any 565 * property value data if any
550 * [align gap to next 4 bytes boundary] 566 * [align gap to next 4 bytes boundary]
551 * [child nodes if any] 567 * [child nodes if any]
552 * token OF_DT_END_NODE (that is 0x00000002) 568 * token OF_DT_END_NODE (that is 0x00000002)
553 569
554So the node content can be summarised as a start token, a full path, 570So the node content can be summarized as a start token, a full path,
555a list of properties, a list of child nodes, and an end token. Every 571a list of properties, a list of child nodes, and an end token. Every
556child node is a full node structure itself as defined above. 572child node is a full node structure itself as defined above.
557 573
@@ -583,7 +599,7 @@ provide those properties yourself.
583---------------------------------------------- 599----------------------------------------------
584 600
585The general rule is documented in the various Open Firmware 601The general rule is documented in the various Open Firmware
586documentations. If you chose to describe a bus with the device-tree 602documentations. If you choose to describe a bus with the device-tree
587and there exist an OF bus binding, then you should follow the 603and there exist an OF bus binding, then you should follow the
588specification. However, the kernel does not require every single 604specification. However, the kernel does not require every single
589device or bus to be described by the device tree. 605device or bus to be described by the device tree.
@@ -596,9 +612,9 @@ those properties defining addresses format for devices directly mapped
596on the processor bus. 612on the processor bus.
597 613
598Those 2 properties define 'cells' for representing an address and a 614Those 2 properties define 'cells' for representing an address and a
599size. A "cell" is a 32 bit number. For example, if both contain 2 615size. A "cell" is a 32-bit number. For example, if both contain 2
600like the example tree given above, then an address and a size are both 616like the example tree given above, then an address and a size are both
601composed of 2 cells, and each is a 64 bit number (cells are 617composed of 2 cells, and each is a 64-bit number (cells are
602concatenated and expected to be in big endian format). Another example 618concatenated and expected to be in big endian format). Another example
603is the way Apple firmware defines them, with 2 cells for an address 619is the way Apple firmware defines them, with 2 cells for an address
604and one cell for a size. Most 32-bit implementations should define 620and one cell for a size. Most 32-bit implementations should define
@@ -632,7 +648,7 @@ prom_parse.c file of the recent kernels for your bus type.
632 648
633The "reg" property only defines addresses and sizes (if #size-cells 649The "reg" property only defines addresses and sizes (if #size-cells
634is non-0) within a given bus. In order to translate addresses upward 650is non-0) within a given bus. In order to translate addresses upward
635(that is into parent bus addresses, and possibly into cpu physical 651(that is into parent bus addresses, and possibly into CPU physical
636addresses), all busses must contain a "ranges" property. If the 652addresses), all busses must contain a "ranges" property. If the
637"ranges" property is missing at a given level, it's assumed that 653"ranges" property is missing at a given level, it's assumed that
638translation isn't possible. The format of the "ranges" property for a 654translation isn't possible. The format of the "ranges" property for a
@@ -648,9 +664,9 @@ example, for a PCI host controller, that would be a CPU address. For a
648PCI<->ISA bridge, that would be a PCI address. It defines the base 664PCI<->ISA bridge, that would be a PCI address. It defines the base
649address in the parent bus where the beginning of that range is mapped. 665address in the parent bus where the beginning of that range is mapped.
650 666
651For a new 64 bit powerpc board, I recommend either the 2/2 format or 667For a new 64-bit powerpc board, I recommend either the 2/2 format or
652Apple's 2/1 format which is slightly more compact since sizes usually 668Apple's 2/1 format which is slightly more compact since sizes usually
653fit in a single 32 bit word. New 32 bit powerpc boards should use a 669fit in a single 32-bit word. New 32-bit powerpc boards should use a
6541/1 format, unless the processor supports physical addresses greater 6701/1 format, unless the processor supports physical addresses greater
655than 32-bits, in which case a 2/1 format is recommended. 671than 32-bits, in which case a 2/1 format is recommended.
656 672
@@ -764,7 +780,7 @@ address which can extend beyond that limit.
764 Required properties: 780 Required properties:
765 781
766 - device_type : has to be "cpu" 782 - device_type : has to be "cpu"
767 - reg : This is the physical cpu number, it's a single 32 bit cell 783 - reg : This is the physical CPU number, it's a single 32-bit cell
768 and is also used as-is as the unit number for constructing the 784 and is also used as-is as the unit number for constructing the
769 unit name in the full path. For example, with 2 CPUs, you would 785 unit name in the full path. For example, with 2 CPUs, you would
770 have the full path: 786 have the full path:
@@ -785,7 +801,7 @@ address which can extend beyond that limit.
785 the kernel timebase/decrementer calibration based on this 801 the kernel timebase/decrementer calibration based on this
786 value. 802 value.
787 - clock-frequency : a cell indicating the CPU core clock frequency 803 - clock-frequency : a cell indicating the CPU core clock frequency
788 in Hz. A new property will be defined for 64 bit values, but if 804 in Hz. A new property will be defined for 64-bit values, but if
789 your frequency is < 4Ghz, one cell is enough. Here as well as 805 your frequency is < 4Ghz, one cell is enough. Here as well as
790 for the above, the common code doesn't use that property, but 806 for the above, the common code doesn't use that property, but
791 you are welcome to re-use the pSeries or Maple one. A future 807 you are welcome to re-use the pSeries or Maple one. A future
@@ -832,8 +848,7 @@ address which can extend beyond that limit.
832 848
833 This node is a bit "special". Normally, that's where open firmware 849 This node is a bit "special". Normally, that's where open firmware
834 puts some variable environment information, like the arguments, or 850 puts some variable environment information, like the arguments, or
835 phandle pointers to nodes like the main interrupt controller, or the 851 the default input/output devices.
836 default input/output devices.
837 852
838 This specification makes a few of these mandatory, but also defines 853 This specification makes a few of these mandatory, but also defines
839 some linux-specific properties that would be normally constructed by 854 some linux-specific properties that would be normally constructed by
@@ -853,14 +868,14 @@ address which can extend beyond that limit.
853 that the kernel tries to find out the default console and has 868 that the kernel tries to find out the default console and has
854 knowledge of various types like 8250 serial ports. You may want 869 knowledge of various types like 8250 serial ports. You may want
855 to extend this function to add your own. 870 to extend this function to add your own.
856 - interrupt-controller : This is one cell containing a phandle
857 value that matches the "linux,phandle" property of your main
858 interrupt controller node. May be used for interrupt routing.
859
860 871
861 Note that u-boot creates and fills in the chosen node for platforms 872 Note that u-boot creates and fills in the chosen node for platforms
862 that use it. 873 that use it.
863 874
875 (Note: a practice that is now obsolete was to include a property
876 under /chosen called interrupt-controller which had a phandle value
877 that pointed to the main interrupt controller)
878
864 f) the /soc<SOCname> node 879 f) the /soc<SOCname> node
865 880
866 This node is used to represent a system-on-a-chip (SOC) and must be 881 This node is used to represent a system-on-a-chip (SOC) and must be
@@ -908,8 +923,7 @@ address which can extend beyond that limit.
908 The SOC node may contain child nodes for each SOC device that the 923 The SOC node may contain child nodes for each SOC device that the
909 platform uses. Nodes should not be created for devices which exist 924 platform uses. Nodes should not be created for devices which exist
910 on the SOC but are not used by a particular platform. See chapter VI 925 on the SOC but are not used by a particular platform. See chapter VI
911 for more information on how to specify devices that are part of an 926 for more information on how to specify devices that are part of a SOC.
912SOC.
913 927
914 Example SOC node for the MPC8540: 928 Example SOC node for the MPC8540:
915 929
@@ -972,7 +986,7 @@ The syntax of the dtc tool is
972 [-o output-filename] [-V output_version] input_filename 986 [-o output-filename] [-V output_version] input_filename
973 987
974 988
975The "output_version" defines what versio of the "blob" format will be 989The "output_version" defines what version of the "blob" format will be
976generated. Supported versions are 1,2,3 and 16. The default is 990generated. Supported versions are 1,2,3 and 16. The default is
977currently version 3 but that may change in the future to version 16. 991currently version 3 but that may change in the future to version 16.
978 992
@@ -994,12 +1008,12 @@ supported currently at the toplevel.
994 */ 1008 */
995 1009
996 property2 = <1234abcd>; /* define a property containing a 1010 property2 = <1234abcd>; /* define a property containing a
997 * numerical 32 bits value (hexadecimal) 1011 * numerical 32-bit value (hexadecimal)
998 */ 1012 */
999 1013
1000 property3 = <12345678 12345678 deadbeef>; 1014 property3 = <12345678 12345678 deadbeef>;
1001 /* define a property containing 3 1015 /* define a property containing 3
1002 * numerical 32 bits values (cells) in 1016 * numerical 32-bit values (cells) in
1003 * hexadecimal 1017 * hexadecimal
1004 */ 1018 */
1005 property4 = [0a 0b 0c 0d de ea ad be ef]; 1019 property4 = [0a 0b 0c 0d de ea ad be ef];
@@ -1068,7 +1082,7 @@ while all this has been defined and implemented.
1068 its usage in early_init_devtree(), and the corresponding various 1082 its usage in early_init_devtree(), and the corresponding various
1069 early_init_dt_scan_*() callbacks. That code can be re-used in a 1083 early_init_dt_scan_*() callbacks. That code can be re-used in a
1070 GPL bootloader, and as the author of that code, I would be happy 1084 GPL bootloader, and as the author of that code, I would be happy
1071 to discuss possible free licencing to any vendor who wishes to 1085 to discuss possible free licensing to any vendor who wishes to
1072 integrate all or part of this code into a non-GPL bootloader. 1086 integrate all or part of this code into a non-GPL bootloader.
1073 1087
1074 1088
@@ -1077,7 +1091,7 @@ VI - System-on-a-chip devices and nodes
1077======================================= 1091=======================================
1078 1092
1079Many companies are now starting to develop system-on-a-chip 1093Many companies are now starting to develop system-on-a-chip
1080processors, where the processor core (cpu) and many peripheral devices 1094processors, where the processor core (CPU) and many peripheral devices
1081exist on a single piece of silicon. For these SOCs, an SOC node 1095exist on a single piece of silicon. For these SOCs, an SOC node
1082should be used that defines child nodes for the devices that make 1096should be used that defines child nodes for the devices that make
1083up the SOC. While platforms are not required to use this model in 1097up the SOC. While platforms are not required to use this model in
@@ -1109,42 +1123,7 @@ See appendix A for an example partial SOC node definition for the
1109MPC8540. 1123MPC8540.
1110 1124
1111 1125
11122) Specifying interrupt information for SOC devices 11262) Representing devices without a current OF specification
1113---------------------------------------------------
1114
1115Each device that is part of an SOC and which generates interrupts
1116should have the following properties:
1117
1118 - interrupt-parent : contains the phandle of the interrupt
1119 controller which handles interrupts for this device
1120 - interrupts : a list of tuples representing the interrupt
1121 number and the interrupt sense and level for each interrupt
1122 for this device.
1123
1124This information is used by the kernel to build the interrupt table
1125for the interrupt controllers in the system.
1126
1127Sense and level information should be encoded as follows:
1128
1129 Devices connected to openPIC-compatible controllers should encode
1130 sense and polarity as follows:
1131
1132 0 = low to high edge sensitive type enabled
1133 1 = active low level sensitive type enabled
1134 2 = active high level sensitive type enabled
1135 3 = high to low edge sensitive type enabled
1136
1137 ISA PIC interrupt controllers should adhere to the ISA PIC
1138 encodings listed below:
1139
1140 0 = active low level sensitive type enabled
1141 1 = active high level sensitive type enabled
1142 2 = high to low edge sensitive type enabled
1143 3 = low to high edge sensitive type enabled
1144
1145
1146
11473) Representing devices without a current OF specification
1148---------------------------------------------------------- 1127----------------------------------------------------------
1149 1128
1150Currently, there are many devices on SOCs that do not have a standard 1129Currently, there are many devices on SOCs that do not have a standard
@@ -1201,6 +1180,13 @@ platforms are moved over to use the flattened-device-tree model.
1201 - phy-handle : The phandle for the PHY connected to this ethernet 1180 - phy-handle : The phandle for the PHY connected to this ethernet
1202 controller. 1181 controller.
1203 1182
1183 Recommended properties:
1184
1185 - linux,network-index : This is the intended "index" of this
1186 network device. This is used by the bootwrapper to interpret
1187 MAC addresses passed by the firmware when no information other
1188 than indices is available to associate an address with a device.
1189
1204 Example: 1190 Example:
1205 1191
1206 ethernet@24000 { 1192 ethernet@24000 {
@@ -1312,10 +1298,10 @@ platforms are moved over to use the flattened-device-tree model.
1312 and additions : 1298 and additions :
1313 1299
1314 Required properties : 1300 Required properties :
1315 - compatible : Should be "fsl-usb2-mph" for multi port host usb 1301 - compatible : Should be "fsl-usb2-mph" for multi port host USB
1316 controllers, or "fsl-usb2-dr" for dual role usb controllers 1302 controllers, or "fsl-usb2-dr" for dual role USB controllers
1317 - phy_type : For multi port host usb controllers, should be one of 1303 - phy_type : For multi port host USB controllers, should be one of
1318 "ulpi", or "serial". For dual role usb controllers, should be 1304 "ulpi", or "serial". For dual role USB controllers, should be
1319 one of "ulpi", "utmi", "utmi_wide", or "serial". 1305 one of "ulpi", "utmi", "utmi_wide", or "serial".
1320 - reg : Offset and length of the register set for the device 1306 - reg : Offset and length of the register set for the device
1321 - port0 : boolean; if defined, indicates port0 is connected for 1307 - port0 : boolean; if defined, indicates port0 is connected for
@@ -1339,7 +1325,7 @@ platforms are moved over to use the flattened-device-tree model.
1339 - interrupt-parent : the phandle for the interrupt controller that 1325 - interrupt-parent : the phandle for the interrupt controller that
1340 services interrupts for this device. 1326 services interrupts for this device.
1341 1327
1342 Example multi port host usb controller device node : 1328 Example multi port host USB controller device node :
1343 usb@22000 { 1329 usb@22000 {
1344 device_type = "usb"; 1330 device_type = "usb";
1345 compatible = "fsl-usb2-mph"; 1331 compatible = "fsl-usb2-mph";
@@ -1353,7 +1339,7 @@ platforms are moved over to use the flattened-device-tree model.
1353 port1; 1339 port1;
1354 }; 1340 };
1355 1341
1356 Example dual role usb controller device node : 1342 Example dual role USB controller device node :
1357 usb@23000 { 1343 usb@23000 {
1358 device_type = "usb"; 1344 device_type = "usb";
1359 compatible = "fsl-usb2-dr"; 1345 compatible = "fsl-usb2-dr";
@@ -1387,7 +1373,7 @@ platforms are moved over to use the flattened-device-tree model.
1387 - channel-fifo-len : An integer representing the number of 1373 - channel-fifo-len : An integer representing the number of
1388 descriptor pointers each channel fetch fifo can hold. 1374 descriptor pointers each channel fetch fifo can hold.
1389 - exec-units-mask : The bitmask representing what execution units 1375 - exec-units-mask : The bitmask representing what execution units
1390 (EUs) are available. It's a single 32 bit cell. EU information 1376 (EUs) are available. It's a single 32-bit cell. EU information
1391 should be encoded following the SEC's Descriptor Header Dword 1377 should be encoded following the SEC's Descriptor Header Dword
1392 EU_SEL0 field documentation, i.e. as follows: 1378 EU_SEL0 field documentation, i.e. as follows:
1393 1379
@@ -1403,7 +1389,7 @@ platforms are moved over to use the flattened-device-tree model.
1403 bits 8 through 31 are reserved for future SEC EUs. 1389 bits 8 through 31 are reserved for future SEC EUs.
1404 1390
1405 - descriptor-types-mask : The bitmask representing what descriptors 1391 - descriptor-types-mask : The bitmask representing what descriptors
1406 are available. It's a single 32 bit cell. Descriptor type 1392 are available. It's a single 32-bit cell. Descriptor type
1407 information should be encoded following the SEC's Descriptor 1393 information should be encoded following the SEC's Descriptor
1408 Header Dword DESC_TYPE field documentation, i.e. as follows: 1394 Header Dword DESC_TYPE field documentation, i.e. as follows:
1409 1395
@@ -1492,7 +1478,7 @@ platforms are moved over to use the flattened-device-tree model.
1492 Required properties: 1478 Required properties:
1493 - device_type : should be "spi". 1479 - device_type : should be "spi".
1494 - compatible : should be "fsl_spi". 1480 - compatible : should be "fsl_spi".
1495 - mode : the spi operation mode, it can be "cpu" or "qe". 1481 - mode : the SPI operation mode, it can be "cpu" or "qe".
1496 - reg : Offset and length of the register set for the device 1482 - reg : Offset and length of the register set for the device
1497 - interrupts : <a b> where a is the interrupt number and b is a 1483 - interrupts : <a b> where a is the interrupt number and b is a
1498 field that represents an encoding of the sense and level 1484 field that represents an encoding of the sense and level
@@ -1569,6 +1555,12 @@ platforms are moved over to use the flattened-device-tree model.
1569 - mac-address : list of bytes representing the ethernet address. 1555 - mac-address : list of bytes representing the ethernet address.
1570 - phy-handle : The phandle for the PHY connected to this controller. 1556 - phy-handle : The phandle for the PHY connected to this controller.
1571 1557
1558 Recommended properties:
1559 - linux,network-index : This is the intended "index" of this
1560 network device. This is used by the bootwrapper to interpret
1561 MAC addresses passed by the firmware when no information other
1562 than indices is available to associate an address with a device.
1563
1572 Example: 1564 Example:
1573 ucc@2000 { 1565 ucc@2000 {
1574 device_type = "network"; 1566 device_type = "network";
@@ -1712,7 +1704,7 @@ platforms are moved over to use the flattened-device-tree model.
1712 - partitions : Several pairs of 32-bit values where the first value is 1704 - partitions : Several pairs of 32-bit values where the first value is
1713 partition's offset from the start of the device and the second one is 1705 partition's offset from the start of the device and the second one is
1714 partition size in bytes with LSB used to signify a read only 1706 partition size in bytes with LSB used to signify a read only
1715 partition (so, the parition size should always be an even number). 1707 partition (so, the partition size should always be an even number).
1716 - partition-names : The list of concatenated zero terminated strings 1708 - partition-names : The list of concatenated zero terminated strings
1717 representing the partition names. 1709 representing the partition names.
1718 - probe-type : The type of probe which should be done for the chip 1710 - probe-type : The type of probe which should be done for the chip
@@ -1733,6 +1725,92 @@ platforms are moved over to use the flattened-device-tree model.
1733 1725
1734 More devices will be defined as this spec matures. 1726 More devices will be defined as this spec matures.
1735 1727
1728VII - Specifying interrupt information for devices
1729===================================================
1730
1731The device tree represents the busses and devices of a hardware
1732system in a form similar to the physical bus topology of the
1733hardware.
1734
1735In addition, a logical 'interrupt tree' exists which represents the
1736hierarchy and routing of interrupts in the hardware.
1737
1738The interrupt tree model is fully described in the
1739document "Open Firmware Recommended Practice: Interrupt
1740Mapping Version 0.9". The document is available at:
1741<http://playground.sun.com/1275/practice>.
1742
17431) interrupts property
1744----------------------
1745
1746Devices that generate interrupts to a single interrupt controller
1747should use the conventional OF representation described in the
1748OF interrupt mapping documentation.
1749
1750Each device which generates interrupts must have an 'interrupt'
1751property. The interrupt property value is an arbitrary number of
1752of 'interrupt specifier' values which describe the interrupt or
1753interrupts for the device.
1754
1755The encoding of an interrupt specifier is determined by the
1756interrupt domain in which the device is located in the
1757interrupt tree. The root of an interrupt domain specifies in
1758its #interrupt-cells property the number of 32-bit cells
1759required to encode an interrupt specifier. See the OF interrupt
1760mapping documentation for a detailed description of domains.
1761
1762For example, the binding for the OpenPIC interrupt controller
1763specifies an #interrupt-cells value of 2 to encode the interrupt
1764number and level/sense information. All interrupt children in an
1765OpenPIC interrupt domain use 2 cells per interrupt in their interrupts
1766property.
1767
1768The PCI bus binding specifies a #interrupt-cell value of 1 to encode
1769which interrupt pin (INTA,INTB,INTC,INTD) is used.
1770
17712) interrupt-parent property
1772----------------------------
1773
1774The interrupt-parent property is specified to define an explicit
1775link between a device node and its interrupt parent in
1776the interrupt tree. The value of interrupt-parent is the
1777phandle of the parent node.
1778
1779If the interrupt-parent property is not defined for a node, it's
1780interrupt parent is assumed to be an ancestor in the node's
1781_device tree_ hierarchy.
1782
17833) OpenPIC Interrupt Controllers
1784--------------------------------
1785
1786OpenPIC interrupt controllers require 2 cells to encode
1787interrupt information. The first cell defines the interrupt
1788number. The second cell defines the sense and level
1789information.
1790
1791Sense and level information should be encoded as follows:
1792
1793 0 = low to high edge sensitive type enabled
1794 1 = active low level sensitive type enabled
1795 2 = active high level sensitive type enabled
1796 3 = high to low edge sensitive type enabled
1797
17984) ISA Interrupt Controllers
1799----------------------------
1800
1801ISA PIC interrupt controllers require 2 cells to encode
1802interrupt information. The first cell defines the interrupt
1803number. The second cell defines the sense and level
1804information.
1805
1806ISA PIC interrupt controllers should adhere to the ISA PIC
1807encodings listed below:
1808
1809 0 = active low level sensitive type enabled
1810 1 = active high level sensitive type enabled
1811 2 = high to low edge sensitive type enabled
1812 3 = low to high edge sensitive type enabled
1813
1736 1814
1737Appendix A - Sample SOC node for MPC8540 1815Appendix A - Sample SOC node for MPC8540
1738======================================== 1816========================================
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 6dfbd52694ab..a54a9a2e36f3 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -11,6 +11,11 @@ config PPC64
11 This option selects whether a 32-bit or a 64-bit kernel 11 This option selects whether a 32-bit or a 64-bit kernel
12 will be built. 12 will be built.
13 13
14config PPC_PM_NEEDS_RTC_LIB
15 bool
16 select RTC_LIB
17 default y if PM
18
14config PPC32 19config PPC32
15 bool 20 bool
16 default y if !PPC64 21 default y if !PPC64
@@ -89,7 +94,7 @@ config SCHED_NO_NO_OMIT_FRAME_POINTER
89 94
90config ARCH_MAY_HAVE_PC_FDC 95config ARCH_MAY_HAVE_PC_FDC
91 bool 96 bool
92 default y 97 default !PPC_PSERIES || PCI
93 98
94config PPC_OF 99config PPC_OF
95 def_bool y 100 def_bool y
@@ -157,17 +162,20 @@ config PPC_83xx
157 select FSL_SOC 162 select FSL_SOC
158 select 83xx 163 select 83xx
159 select PPC_FPU 164 select PPC_FPU
165 select WANT_DEVICE_TREE
160 166
161config PPC_85xx 167config PPC_85xx
162 bool "Freescale 85xx" 168 bool "Freescale 85xx"
163 select E500 169 select E500
164 select FSL_SOC 170 select FSL_SOC
165 select 85xx 171 select 85xx
172 select WANT_DEVICE_TREE
166 173
167config PPC_86xx 174config PPC_86xx
168 bool "Freescale 86xx" 175 bool "Freescale 86xx"
169 select 6xx 176 select 6xx
170 select FSL_SOC 177 select FSL_SOC
178 select FSL_PCIE
171 select PPC_FPU 179 select PPC_FPU
172 select ALTIVEC 180 select ALTIVEC
173 help 181 help
@@ -186,7 +194,6 @@ config 44x
186 bool "AMCC 44x" 194 bool "AMCC 44x"
187 select PPC_DCR_NATIVE 195 select PPC_DCR_NATIVE
188 196
189
190config E200 197config E200
191 bool "Freescale e200" 198 bool "Freescale e200"
192 199
@@ -367,394 +374,7 @@ endmenu
367 374
368source "init/Kconfig" 375source "init/Kconfig"
369 376
370menu "Platform support" 377source "arch/powerpc/platforms/Kconfig"
371 depends on PPC64 || CLASSIC32
372
373choice
374 prompt "Machine type"
375 default PPC_MULTIPLATFORM
376
377config PPC_MULTIPLATFORM
378 bool "Generic desktop/server/laptop"
379 help
380 Select this option if configuring for an IBM pSeries or
381 RS/6000 machine, an Apple machine, or a PReP, CHRP,
382 Maple or Cell-based machine.
383
384config EMBEDDED6xx
385 bool "Embedded 6xx/7xx/7xxx-based board"
386 depends on PPC32 && (BROKEN||BROKEN_ON_SMP)
387
388config APUS
389 bool "Amiga-APUS"
390 depends on PPC32 && BROKEN
391 help
392 Select APUS if configuring for a PowerUP Amiga.
393 More information is available at:
394 <http://linux-apus.sourceforge.net/>.
395endchoice
396
397config QUICC_ENGINE
398 bool
399 depends on PPC_MPC836x || PPC_MPC832x
400 default y
401 help
402 The QUICC Engine (QE) is a new generation of communications
403 coprocessors on Freescale embedded CPUs (akin to CPM in older chips).
404 Selecting this option means that you wish to build a kernel
405 for a machine with a QE coprocessor.
406
407config PPC_PSERIES
408 depends on PPC_MULTIPLATFORM && PPC64
409 bool "IBM pSeries & new (POWER5-based) iSeries"
410 select MPIC
411 select PPC_I8259
412 select PPC_RTAS
413 select RTAS_ERROR_LOGGING
414 select PPC_UDBG_16550
415 select PPC_NATIVE
416 default y
417
418config PPC_ISERIES
419 bool "IBM Legacy iSeries"
420 depends on PPC_MULTIPLATFORM && PPC64
421 select PPC_INDIRECT_IO
422
423config PPC_CHRP
424 bool "Common Hardware Reference Platform (CHRP) based machines"
425 depends on PPC_MULTIPLATFORM && PPC32
426 select MPIC
427 select PPC_I8259
428 select PPC_INDIRECT_PCI
429 select PPC_RTAS
430 select PPC_MPC106
431 select PPC_UDBG_16550
432 select PPC_NATIVE
433 default y
434
435config PPC_MPC52xx
436 bool
437 default n
438
439config PPC_MPC5200
440 bool
441 select PPC_MPC52xx
442 default n
443
444config PPC_MPC5200_BUGFIX
445 bool "MPC5200 (L25R) bugfix support"
446 depends on PPC_MPC5200
447 default n
448 help
449 Enable workarounds for original MPC5200 errata. This is not required
450 for MPC5200B based boards.
451
452 It is safe to say 'Y' here
453
454config PPC_EFIKA
455 bool "bPlan Efika 5k2. MPC5200B based computer"
456 depends on PPC_MULTIPLATFORM && PPC32
457 select PPC_RTAS
458 select RTAS_PROC
459 select PPC_MPC52xx
460 select PPC_NATIVE
461 default n
462
463config PPC_LITE5200
464 bool "Freescale Lite5200 Eval Board"
465 depends on PPC_MULTIPLATFORM && PPC32
466 select PPC_MPC5200
467 default n
468
469config PPC_PMAC
470 bool "Apple PowerMac based machines"
471 depends on PPC_MULTIPLATFORM
472 select MPIC
473 select PPC_INDIRECT_PCI if PPC32
474 select PPC_MPC106 if PPC32
475 select PPC_NATIVE
476 default y
477
478config PPC_PMAC64
479 bool
480 depends on PPC_PMAC && POWER4
481 select MPIC
482 select U3_DART
483 select MPIC_BROKEN_U3
484 select GENERIC_TBSYNC
485 select PPC_970_NAP
486 default y
487
488config PPC_PREP
489 bool "PowerPC Reference Platform (PReP) based machines"
490 depends on PPC_MULTIPLATFORM && PPC32 && BROKEN
491 select MPIC
492 select PPC_I8259
493 select PPC_INDIRECT_PCI
494 select PPC_UDBG_16550
495 select PPC_NATIVE
496 default n
497
498config PPC_MAPLE
499 depends on PPC_MULTIPLATFORM && PPC64
500 bool "Maple 970FX Evaluation Board"
501 select MPIC
502 select U3_DART
503 select MPIC_BROKEN_U3
504 select GENERIC_TBSYNC
505 select PPC_UDBG_16550
506 select PPC_970_NAP
507 select PPC_NATIVE
508 select PPC_RTAS
509 select MMIO_NVRAM
510 select ATA_NONSTANDARD if ATA
511 default n
512 help
513 This option enables support for the Maple 970FX Evaluation Board.
514 For more information, refer to <http://www.970eval.com>
515
516config PPC_PASEMI
517 depends on PPC_MULTIPLATFORM && PPC64
518 bool "PA Semi SoC-based platforms"
519 default n
520 select MPIC
521 select PPC_UDBG_16550
522 select GENERIC_TBSYNC
523 select PPC_NATIVE
524 help
525 This option enables support for PA Semi's PWRficient line
526 of SoC processors, including PA6T-1682M
527
528config PPC_CELL
529 bool
530 default n
531
532config PPC_CELL_NATIVE
533 bool
534 select PPC_CELL
535 select PPC_DCR_MMIO
536 select PPC_OF_PLATFORM_PCI
537 select PPC_INDIRECT_IO
538 select PPC_NATIVE
539 select MPIC
540 default n
541
542config PPC_IBM_CELL_BLADE
543 bool "IBM Cell Blade"
544 depends on PPC_MULTIPLATFORM && PPC64
545 select PPC_CELL_NATIVE
546 select PPC_RTAS
547 select MMIO_NVRAM
548 select PPC_UDBG_16550
549 select UDBG_RTAS_CONSOLE
550
551config PPC_PS3
552 bool "Sony PS3 (incomplete)"
553 depends on PPC_MULTIPLATFORM && PPC64
554 select PPC_CELL
555 select USB_ARCH_HAS_OHCI
556 select USB_OHCI_LITTLE_ENDIAN
557 select USB_OHCI_BIG_ENDIAN_MMIO
558 select USB_ARCH_HAS_EHCI
559 select USB_EHCI_BIG_ENDIAN_MMIO
560 help
561 This option enables support for the Sony PS3 game console
562 and other platforms using the PS3 hypervisor.
563 Support for this platform is not yet complete, so
564 enabling this will not result in a bootable kernel on a
565 PS3 system.
566
567config PPC_CELLEB
568 bool "Toshiba's Cell Reference Set 'Celleb' Architecture"
569 depends on PPC_MULTIPLATFORM && PPC64
570 select PPC_CELL
571 select PPC_OF_PLATFORM_PCI
572 select HAS_TXX9_SERIAL
573 select PPC_UDBG_BEAT
574 select USB_OHCI_BIG_ENDIAN_MMIO
575 select USB_EHCI_BIG_ENDIAN_MMIO
576
577config PPC_NATIVE
578 bool
579 depends on PPC_MULTIPLATFORM
580 help
581 Support for running natively on the hardware, i.e. without
582 a hypervisor. This option is not user-selectable but should
583 be selected by all platforms that need it.
584
585config UDBG_RTAS_CONSOLE
586 bool "RTAS based debug console"
587 depends on PPC_RTAS
588 default n
589
590config PPC_UDBG_BEAT
591 bool "BEAT based debug console"
592 depends on PPC_CELLEB
593 default n
594
595config XICS
596 depends on PPC_PSERIES
597 bool
598 default y
599
600config U3_DART
601 bool
602 depends on PPC_MULTIPLATFORM && PPC64
603 default n
604
605config PPC_RTAS
606 bool
607 default n
608
609config RTAS_ERROR_LOGGING
610 bool
611 depends on PPC_RTAS
612 default n
613
614config RTAS_PROC
615 bool "Proc interface to RTAS"
616 depends on PPC_RTAS
617 default y
618
619config RTAS_FLASH
620 tristate "Firmware flash interface"
621 depends on PPC64 && RTAS_PROC
622
623config PPC_PMI
624 tristate "Support for PMI"
625 depends PPC_IBM_CELL_BLADE
626 help
627 PMI (Platform Management Interrupt) is a way to
628 communicate with the BMC (Baseboard Mangement Controller).
629 It is used in some IBM Cell blades.
630 default m
631
632config MMIO_NVRAM
633 bool
634 default n
635
636config MPIC_BROKEN_U3
637 bool
638 depends on PPC_MAPLE
639 default y
640
641config IBMVIO
642 depends on PPC_PSERIES || PPC_ISERIES
643 bool
644 default y
645
646config IBMEBUS
647 depends on PPC_PSERIES
648 bool "Support for GX bus based adapters"
649 help
650 Bus device driver for GX bus based adapters.
651
652config PPC_MPC106
653 bool
654 default n
655
656config PPC_970_NAP
657 bool
658 default n
659
660config PPC_INDIRECT_IO
661 bool
662 select GENERIC_IOMAP
663 default n
664
665config GENERIC_IOMAP
666 bool
667 default n
668
669source "drivers/cpufreq/Kconfig"
670
671config CPU_FREQ_PMAC
672 bool "Support for Apple PowerBooks"
673 depends on CPU_FREQ && ADB_PMU && PPC32
674 select CPU_FREQ_TABLE
675 help
676 This adds support for frequency switching on Apple PowerBooks,
677 this currently includes some models of iBook & Titanium
678 PowerBook.
679
680config CPU_FREQ_PMAC64
681 bool "Support for some Apple G5s"
682 depends on CPU_FREQ && PPC64
683 select CPU_FREQ_TABLE
684 help
685 This adds support for frequency switching on Apple iMac G5,
686 and some of the more recent desktop G5 machines as well.
687
688config PPC601_SYNC_FIX
689 bool "Workarounds for PPC601 bugs"
690 depends on 6xx && (PPC_PREP || PPC_PMAC)
691 help
692 Some versions of the PPC601 (the first PowerPC chip) have bugs which
693 mean that extra synchronization instructions are required near
694 certain instructions, typically those that make major changes to the
695 CPU state. These extra instructions reduce performance slightly.
696 If you say N here, these extra instructions will not be included,
697 resulting in a kernel which will run faster but may not run at all
698 on some systems with the PPC601 chip.
699
700 If in doubt, say Y here.
701
702config TAU
703 bool "On-chip CPU temperature sensor support"
704 depends on 6xx
705 help
706 G3 and G4 processors have an on-chip temperature sensor called the
707 'Thermal Assist Unit (TAU)', which, in theory, can measure the on-die
708 temperature within 2-4 degrees Celsius. This option shows the current
709 on-die temperature in /proc/cpuinfo if the cpu supports it.
710
711 Unfortunately, on some chip revisions, this sensor is very inaccurate
712 and in many cases, does not work at all, so don't assume the cpu
713 temp is actually what /proc/cpuinfo says it is.
714
715config TAU_INT
716 bool "Interrupt driven TAU driver (DANGEROUS)"
717 depends on TAU
718 ---help---
719 The TAU supports an interrupt driven mode which causes an interrupt
720 whenever the temperature goes out of range. This is the fastest way
721 to get notified the temp has exceeded a range. With this option off,
722 a timer is used to re-check the temperature periodically.
723
724 However, on some cpus it appears that the TAU interrupt hardware
725 is buggy and can cause a situation which would lead unexplained hard
726 lockups.
727
728 Unless you are extending the TAU driver, or enjoy kernel/hardware
729 debugging, leave this option off.
730
731config TAU_AVERAGE
732 bool "Average high and low temp"
733 depends on TAU
734 ---help---
735 The TAU hardware can compare the temperature to an upper and lower
736 bound. The default behavior is to show both the upper and lower
737 bound in /proc/cpuinfo. If the range is large, the temperature is
738 either changing a lot, or the TAU hardware is broken (likely on some
739 G4's). If the range is small (around 4 degrees), the temperature is
740 relatively stable. If you say Y here, a single temperature value,
741 halfway between the upper and lower bounds, will be reported in
742 /proc/cpuinfo.
743
744 If in doubt, say N here.
745
746endmenu
747
748source arch/powerpc/platforms/embedded6xx/Kconfig
749source arch/powerpc/platforms/4xx/Kconfig
750source arch/powerpc/platforms/82xx/Kconfig
751source arch/powerpc/platforms/83xx/Kconfig
752source arch/powerpc/platforms/85xx/Kconfig
753source arch/powerpc/platforms/86xx/Kconfig
754source arch/powerpc/platforms/8xx/Kconfig
755source arch/powerpc/platforms/cell/Kconfig
756source arch/powerpc/platforms/ps3/Kconfig
757source arch/powerpc/platforms/pasemi/Kconfig
758 378
759menu "Kernel options" 379menu "Kernel options"
760 380
@@ -837,15 +457,6 @@ config CRASH_DUMP
837 457
838 Don't change this unless you know what you are doing. 458 Don't change this unless you know what you are doing.
839 459
840config EMBEDDEDBOOT
841 bool
842 depends on 8xx || 8260
843 default y
844
845config PC_KEYBOARD
846 bool "PC PS/2 style Keyboard"
847 depends on 4xx || CPM2
848
849config PPCBUG_NVRAM 460config PPCBUG_NVRAM
850 bool "Enable reading PPCBUG NVRAM during boot" if PPLUS || LOPEC 461 bool "Enable reading PPCBUG NVRAM during boot" if PPLUS || LOPEC
851 default y if PPC_PREP 462 default y if PPC_PREP
@@ -859,8 +470,6 @@ config IRQ_ALL_CPUS
859 CPU. Generally saying Y is safe, although some problems have been 470 CPU. Generally saying Y is safe, although some problems have been
860 reported with SMP Power Macintoshes with this option enabled. 471 reported with SMP Power Macintoshes with this option enabled.
861 472
862source "arch/powerpc/platforms/pseries/Kconfig"
863
864config NUMA 473config NUMA
865 bool "NUMA support" 474 bool "NUMA support"
866 depends on PPC64 475 depends on PPC64
@@ -910,10 +519,10 @@ config PPC_64K_PAGES
910 depends on PPC64 519 depends on PPC64
911 help 520 help
912 This option changes the kernel logical page size to 64k. On machines 521 This option changes the kernel logical page size to 64k. On machines
913 without processor support for 64k pages, the kernel will simulate 522 without processor support for 64k pages, the kernel will simulate
914 them by loading each individual 4k page on demand transparently, 523 them by loading each individual 4k page on demand transparently,
915 while on hardware with such support, it will be used to map 524 while on hardware with such support, it will be used to map
916 normal application pages. 525 normal application pages.
917 526
918config SCHED_SMT 527config SCHED_SMT
919 bool "SMT (Hyperthreading) scheduler support" 528 bool "SMT (Hyperthreading) scheduler support"
@@ -931,8 +540,6 @@ config PROC_DEVICETREE
931 an image of the device tree that the kernel copies from Open 540 an image of the device tree that the kernel copies from Open
932 Firmware or other boot firmware. If unsure, say Y here. 541 Firmware or other boot firmware. If unsure, say Y here.
933 542
934source "arch/powerpc/platforms/prep/Kconfig"
935
936config CMDLINE_BOOL 543config CMDLINE_BOOL
937 bool "Default bootloader kernel arguments" 544 bool "Default bootloader kernel arguments"
938 545
@@ -967,6 +574,29 @@ config SECCOMP
967 574
968 If unsure, say Y. Only embedded should say N here. 575 If unsure, say Y. Only embedded should say N here.
969 576
577config WANT_DEVICE_TREE
578 bool
579 default n
580
581config DEVICE_TREE
582 string "Static device tree source file"
583 depends on WANT_DEVICE_TREE
584 help
585 This specifies the device tree source (.dts) file to be
586 compiled and included when building the bootwrapper. If a
587 relative filename is given, then it will be relative to
588 arch/powerpc/boot/dts. If you are not using the bootwrapper,
589 or do not need to build a dts into the bootwrapper, this
590 field is ignored.
591
592 For example, this is required when building a cuImage target
593 for an older U-Boot, which cannot pass a device tree itself.
594 Such a kernel will not work with a newer U-Boot that tries to
595 pass a device tree (unless you tell it not to). If your U-Boot
596 does not mention a device tree in "help bootm", then use the
597 cuImage target and specify a device tree here. Otherwise, use
598 the uImage target and leave this field blank.
599
970endmenu 600endmenu
971 601
972config ISA_DMA_API 602config ISA_DMA_API
@@ -995,24 +625,17 @@ config GENERIC_ISA_DMA
995 depends on PPC64 || POWER4 || 6xx && !CPM2 625 depends on PPC64 || POWER4 || 6xx && !CPM2
996 default y 626 default y
997 627
998config MPIC
999 bool
1000 default n
1001
1002config MPIC_WEIRD
1003 bool
1004 default n
1005
1006config PPC_I8259
1007 bool
1008 default n
1009
1010config PPC_INDIRECT_PCI 628config PPC_INDIRECT_PCI
1011 bool 629 bool
1012 depends on PCI 630 depends on PCI
1013 default y if 40x || 44x 631 default y if 40x || 44x
1014 default n 632 default n
1015 633
634config PPC_INDIRECT_PCI_BE
635 bool
636 depends PPC_INDIRECT_PCI
637 default n
638
1016config EISA 639config EISA
1017 bool 640 bool
1018 641
@@ -1022,13 +645,18 @@ config SBUS
1022config FSL_SOC 645config FSL_SOC
1023 bool 646 bool
1024 647
648config FSL_PCIE
649 bool
650 depends on PPC_86xx
651
1025# Yes MCA RS/6000s exist but Linux-PPC does not currently support any 652# Yes MCA RS/6000s exist but Linux-PPC does not currently support any
1026config MCA 653config MCA
1027 bool 654 bool
1028 655
1029config PCI 656config PCI
1030 bool "PCI support" if 40x || CPM2 || PPC_83xx || PPC_85xx || PPC_86xx \ 657 bool "PCI support" if 40x || CPM2 || PPC_83xx || PPC_85xx || PPC_86xx \
1031 || PPC_MPC52xx || (EMBEDDED && PPC_ISERIES) || MPC7448HPC2 || PPC_PS3 658 || PPC_MPC52xx || (EMBEDDED && (PPC_PSERIES || PPC_ISERIES)) \
659 || MPC7448HPC2 || PPC_PS3
1032 default y if !40x && !CPM2 && !8xx && !APUS && !PPC_83xx \ 660 default y if !40x && !CPM2 && !8xx && !APUS && !PPC_83xx \
1033 && !PPC_85xx && !PPC_86xx 661 && !PPC_85xx && !PPC_86xx
1034 default PCI_PERMEDIA if !4xx && !CPM2 && !8xx && APUS 662 default PCI_PERMEDIA if !4xx && !CPM2 && !8xx && APUS
@@ -1228,12 +856,10 @@ source "fs/Kconfig"
1228 856
1229source "arch/powerpc/sysdev/qe_lib/Kconfig" 857source "arch/powerpc/sysdev/qe_lib/Kconfig"
1230 858
1231source "arch/powerpc/platforms/iseries/Kconfig"
1232
1233source "lib/Kconfig" 859source "lib/Kconfig"
1234 860
1235menu "Instrumentation Support" 861menu "Instrumentation Support"
1236 depends on EXPERIMENTAL 862 depends on EXPERIMENTAL
1237 863
1238source "arch/powerpc/oprofile/Kconfig" 864source "arch/powerpc/oprofile/Kconfig"
1239 865
diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
index d39d13327e6d..86aa3745af7f 100644
--- a/arch/powerpc/Kconfig.debug
+++ b/arch/powerpc/Kconfig.debug
@@ -18,6 +18,15 @@ 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 DEBUG_PAGEALLOC
22 bool "Debug page memory allocations"
23 depends on DEBUG_KERNEL && !SOFTWARE_SUSPEND
24 help
25 Unmap pages from the kernel linear mapping after free_pages().
26 This results in a large slowdown, but helps to find certain types
27 of memory corruptions.
28
29
21config HCALL_STATS 30config HCALL_STATS
22 bool "Hypervisor call instrumentation" 31 bool "Hypervisor call instrumentation"
23 depends on PPC_PSERIES && DEBUG_FS 32 depends on PPC_PSERIES && DEBUG_FS
@@ -132,8 +141,7 @@ config BOOTX_TEXT
132 141
133config SERIAL_TEXT_DEBUG 142config SERIAL_TEXT_DEBUG
134 bool "Support for early boot texts over serial port" 143 bool "Support for early boot texts over serial port"
135 depends on 4xx || LOPEC || MV64X60 || PPLUS || PRPMC800 || \ 144 depends on 4xx
136 PPC_GEN550 || PPC_MPC52xx
137 145
138config PPC_EARLY_DEBUG 146config PPC_EARLY_DEBUG
139 bool "Early debugging (dangerous)" 147 bool "Early debugging (dangerous)"
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index a00fe7236555..794992025d8d 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -102,9 +102,9 @@ CFLAGS += $(call cc-option,-mno-altivec)
102# kernel considerably. 102# kernel considerably.
103CFLAGS += $(call cc-option,-funit-at-a-time) 103CFLAGS += $(call cc-option,-funit-at-a-time)
104 104
105ifndef CONFIG_FSL_BOOKE 105# Never use string load/store instructions as they are
106CFLAGS += -mstring 106# often slow when they are implemented at all
107endif 107CFLAGS += -mno-string
108 108
109ifeq ($(CONFIG_6xx),y) 109ifeq ($(CONFIG_6xx),y)
110CFLAGS += -mcpu=powerpc 110CFLAGS += -mcpu=powerpc
@@ -148,7 +148,7 @@ all: $(KBUILD_IMAGE)
148 148
149CPPFLAGS_vmlinux.lds := -Upowerpc 149CPPFLAGS_vmlinux.lds := -Upowerpc
150 150
151BOOT_TARGETS = zImage zImage.initrd uImage 151BOOT_TARGETS = zImage zImage.initrd uImage cuImage
152 152
153PHONY += $(BOOT_TARGETS) 153PHONY += $(BOOT_TARGETS)
154 154
@@ -166,6 +166,9 @@ define archhelp
166 @echo ' *_defconfig - Select default config from arch/$(ARCH)/configs' 166 @echo ' *_defconfig - Select default config from arch/$(ARCH)/configs'
167endef 167endef
168 168
169install:
170 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) install
171
169archclean: 172archclean:
170 $(Q)$(MAKE) $(clean)=$(boot) 173 $(Q)$(MAKE) $(clean)=$(boot)
171 174
diff --git a/arch/powerpc/boot/.gitignore b/arch/powerpc/boot/.gitignore
index 0734b2fc1d95..eec7af7e5993 100644
--- a/arch/powerpc/boot/.gitignore
+++ b/arch/powerpc/boot/.gitignore
@@ -18,6 +18,9 @@ kernel-vmlinux.strip.c
18kernel-vmlinux.strip.gz 18kernel-vmlinux.strip.gz
19mktree 19mktree
20uImage 20uImage
21cuImage
22cuImage.bin.gz
23cuImage.elf
21zImage 24zImage
22zImage.chrp 25zImage.chrp
23zImage.coff 26zImage.coff
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index dc779407de14..3716594ea33e 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -40,10 +40,11 @@ zliblinuxheader := zlib.h zconf.h zutil.h
40$(addprefix $(obj)/,$(zlib) main.o): $(addprefix $(obj)/,$(zliblinuxheader)) \ 40$(addprefix $(obj)/,$(zlib) main.o): $(addprefix $(obj)/,$(zliblinuxheader)) \
41 $(addprefix $(obj)/,$(zlibheader)) 41 $(addprefix $(obj)/,$(zlibheader))
42 42
43src-wlib := string.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \ 43src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
44 ns16550.c serial.c simple_alloc.c div64.S util.S $(zlib) 44 ns16550.c serial.c simple_alloc.c div64.S util.S \
45src-plat := of.c 45 gunzip_util.c elf_util.c $(zlib) devtree.c
46src-boot := crt0.S $(src-wlib) $(src-plat) empty.c 46src-plat := of.c cuboot-83xx.c cuboot-85xx.c
47src-boot := $(src-wlib) $(src-plat) empty.c
47 48
48src-boot := $(addprefix $(obj)/, $(src-boot)) 49src-boot := $(addprefix $(obj)/, $(src-boot))
49obj-boot := $(addsuffix .o, $(basename $(src-boot))) 50obj-boot := $(addsuffix .o, $(basename $(src-boot)))
@@ -75,7 +76,7 @@ $(obj)/zImage.lds $(obj)/zImage.coff.lds: $(obj)/%: $(srctree)/$(src)/%.S
75 @cp $< $@ 76 @cp $< $@
76 77
77clean-files := $(zlib) $(zlibheader) $(zliblinuxheader) \ 78clean-files := $(zlib) $(zlibheader) $(zliblinuxheader) \
78 empty.c zImage zImage.coff.lds zImage.lds zImage.sandpoint 79 empty.c zImage.coff.lds zImage.lds
79 80
80quiet_cmd_bootcc = BOOTCC $@ 81quiet_cmd_bootcc = BOOTCC $@
81 cmd_bootcc = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $< 82 cmd_bootcc = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
@@ -84,23 +85,25 @@ quiet_cmd_bootas = BOOTAS $@
84 cmd_bootas = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $< 85 cmd_bootas = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
85 86
86quiet_cmd_bootar = BOOTAR $@ 87quiet_cmd_bootar = BOOTAR $@
87 cmd_bootar = $(CROSS32AR) -cr $@.$$$$ $^; mv $@.$$$$ $@ 88 cmd_bootar = $(CROSS32AR) -cr $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@
88 89
89$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c 90$(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c FORCE
90 $(call if_changed_dep,bootcc) 91 $(call if_changed_dep,bootcc)
91$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S 92$(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE
92 $(call if_changed_dep,bootas) 93 $(call if_changed_dep,bootas)
93 94
94$(obj)/wrapper.a: $(obj-wlib) 95$(obj)/wrapper.a: $(obj-wlib) FORCE
95 $(call cmd,bootar) 96 $(call if_changed,bootar)
96 97
97hostprogs-y := addnote addRamDisk hack-coff mktree 98hostprogs-y := addnote addRamDisk hack-coff mktree
98 99
99extra-y := $(obj)/crt0.o $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \ 100targets += $(patsubst $(obj)/%,%,$(obj-boot) wrapper.a)
101extra-y := $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \
100 $(obj)/zImage.lds $(obj)/zImage.coff.lds 102 $(obj)/zImage.lds $(obj)/zImage.coff.lds
101 103
102wrapper :=$(srctree)/$(src)/wrapper 104wrapper :=$(srctree)/$(src)/wrapper
103wrapperbits := $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree) 105wrapperbits := $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree) \
106 $(wrapper) FORCE
104 107
105############# 108#############
106# Bits for building various flavours of zImage 109# Bits for building various flavours of zImage
@@ -113,50 +116,10 @@ CROSSWRAP := -C "$(CROSS_COMPILE)"
113endif 116endif
114endif 117endif
115 118
119# args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd
116quiet_cmd_wrap = WRAP $@ 120quiet_cmd_wrap = WRAP $@
117 cmd_wrap =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) vmlinux 121 cmd_wrap =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \
118quiet_cmd_wrap_initrd = WRAP $@ 122 $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux
119 cmd_wrap_initrd =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \
120 -i $(obj)/ramdisk.image.gz vmlinux
121
122$(obj)/zImage.chrp: vmlinux $(wrapperbits)
123 $(call cmd,wrap,chrp)
124
125$(obj)/zImage.initrd.chrp: vmlinux $(wrapperbits)
126 $(call cmd,wrap_initrd,chrp)
127
128$(obj)/zImage.pseries: vmlinux $(wrapperbits)
129 $(call cmd,wrap,pseries)
130
131$(obj)/zImage.initrd.pseries: vmlinux $(wrapperbits)
132 $(call cmd,wrap_initrd,pseries)
133
134$(obj)/zImage.pmac: vmlinux $(wrapperbits)
135 $(call cmd,wrap,pmac)
136
137$(obj)/zImage.initrd.pmac: vmlinux $(wrapperbits)
138 $(call cmd,wrap_initrd,pmac)
139
140$(obj)/zImage.coff: vmlinux $(wrapperbits)
141 $(call cmd,wrap,pmaccoff)
142
143$(obj)/zImage.initrd.coff: vmlinux $(wrapperbits)
144 $(call cmd,wrap_initrd,pmaccoff)
145
146$(obj)/zImage.miboot: vmlinux $(wrapperbits)
147 $(call cmd,wrap,miboot)
148
149$(obj)/zImage.initrd.miboot: vmlinux $(wrapperbits)
150 $(call cmd,wrap_initrd,miboot)
151
152$(obj)/zImage.ps3: vmlinux
153 $(STRIP) -s -R .comment $< -o $@
154
155$(obj)/zImage.initrd.ps3: vmlinux
156 @echo " WARNING zImage.initrd.ps3 not supported (yet)"
157
158$(obj)/uImage: vmlinux $(wrapperbits)
159 $(call cmd,wrap,uboot)
160 123
161image-$(CONFIG_PPC_PSERIES) += zImage.pseries 124image-$(CONFIG_PPC_PSERIES) += zImage.pseries
162image-$(CONFIG_PPC_MAPLE) += zImage.pseries 125image-$(CONFIG_PPC_MAPLE) += zImage.pseries
@@ -166,7 +129,7 @@ image-$(CONFIG_PPC_CELLEB) += zImage.pseries
166image-$(CONFIG_PPC_CHRP) += zImage.chrp 129image-$(CONFIG_PPC_CHRP) += zImage.chrp
167image-$(CONFIG_PPC_EFIKA) += zImage.chrp 130image-$(CONFIG_PPC_EFIKA) += zImage.chrp
168image-$(CONFIG_PPC_PMAC) += zImage.pmac 131image-$(CONFIG_PPC_PMAC) += zImage.pmac
169image-$(CONFIG_DEFAULT_UIMAGE) += uImage 132image-$(CONFIG_DEFAULT_UIMAGE) += uImage cuImage
170 133
171# For 32-bit powermacs, build the COFF and miboot images 134# For 32-bit powermacs, build the COFF and miboot images
172# as well as the ELF images. 135# as well as the ELF images.
@@ -174,16 +137,55 @@ ifeq ($(CONFIG_PPC32),y)
174image-$(CONFIG_PPC_PMAC) += zImage.coff zImage.miboot 137image-$(CONFIG_PPC_PMAC) += zImage.coff zImage.miboot
175endif 138endif
176 139
140initrd- := $(patsubst zImage%, zImage.initrd%, $(image-n) $(image-))
177initrd-y := $(patsubst zImage%, zImage.initrd%, $(image-y)) 141initrd-y := $(patsubst zImage%, zImage.initrd%, $(image-y))
142initrd-y := $(filter-out $(image-y), $(initrd-y))
143targets += $(image-y) $(initrd-y)
144
145$(addprefix $(obj)/, $(initrd-y)): $(obj)/ramdisk.image.gz
146
147# Don't put the ramdisk on the pattern rule; when its missing make will try
148# the pattern rule with less dependencies that also matches (even with the
149# hard dependency listed).
150$(obj)/zImage.initrd.%: vmlinux $(wrapperbits)
151 $(call if_changed,wrap,$*,,,$(obj)/ramdisk.image.gz)
152
153$(obj)/zImage.%: vmlinux $(wrapperbits)
154 $(call if_changed,wrap,$*)
155
156$(obj)/zImage.ps3: vmlinux
157 $(STRIP) -s -R .comment $< -o $@
158
159$(obj)/zImage.initrd.ps3: vmlinux
160 @echo " WARNING zImage.initrd.ps3 not supported (yet)"
161
162$(obj)/uImage: vmlinux $(wrapperbits)
163 $(call if_changed,wrap,uboot)
164
165cuboot-plat-$(CONFIG_83xx) += 83xx
166cuboot-plat-$(CONFIG_85xx) += 85xx
167cuboot-plat-y += unknown-platform
168
169dts = $(if $(shell echo $(CONFIG_DEVICE_TREE) | grep '^/'),\
170 ,$(srctree)/$(src)/dts/)$(CONFIG_DEVICE_TREE)
171
172$(obj)/cuImage: vmlinux $(wrapperbits)
173 $(call if_changed,wrap,cuboot-$(word 1,$(cuboot-plat-y)),$(dts))
178 174
179$(obj)/zImage: $(addprefix $(obj)/, $(image-y)) 175$(obj)/zImage: $(addprefix $(obj)/, $(image-y))
180 @rm -f $@; ln $< $@ 176 @rm -f $@; ln $< $@
181$(obj)/zImage.initrd: $(addprefix $(obj)/, $(initrd-y)) 177$(obj)/zImage.initrd: $(addprefix $(obj)/, $(initrd-y))
182 @rm -f $@; ln $< $@ 178 @rm -f $@; ln $< $@
183 179
184install: $(CONFIGURE) $(image-y) 180install: $(CONFIGURE) $(addprefix $(obj)/, $(image-y))
185 sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $< 181 sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" $<
186 182
187clean-files += $(addprefix $(objtree)/, $(obj-boot) vmlinux.strip.gz) 183# anything not in $(targets)
188clean-files += $(addprefix $(objtree)/, $(obj-boot) vmlinux.bin.gz) 184clean-files += $(image-) $(initrd-) zImage zImage.initrd \
189clean-files += $(image-) 185 cuImage.elf cuImage.bin.gz
186
187# clean up files cached by wrapper
188clean-kernel := vmlinux.strip vmlinux.bin
189clean-kernel += $(addsuffix .gz,$(clean-kernel))
190# If not absolute clean-files are relative to $(obj).
191clean-files += $(addprefix $(objtree)/, $(clean-kernel))
diff --git a/arch/powerpc/boot/crt0.S b/arch/powerpc/boot/crt0.S
index 70e65b13e033..5a4215c4b014 100644
--- a/arch/powerpc/boot/crt0.S
+++ b/arch/powerpc/boot/crt0.S
@@ -16,8 +16,11 @@
16_zimage_start_opd: 16_zimage_start_opd:
17 .long _zimage_start, 0, 0, 0 17 .long _zimage_start, 0, 0, 0
18 18
19 .weak _zimage_start
19 .globl _zimage_start 20 .globl _zimage_start
20_zimage_start: 21_zimage_start:
22 .globl _zimage_start_lib
23_zimage_start_lib:
21 /* Work out the offset between the address we were linked at 24 /* Work out the offset between the address we were linked at
22 and the address where we're running. */ 25 and the address where we're running. */
23 bl 1f 26 bl 1f
@@ -44,7 +47,7 @@ _zimage_start:
44 addi r9,r9,4 47 addi r9,r9,4
45 bdnz 2b 48 bdnz 2b
46 49
47 /* Do a cache flush for our text, in case OF didn't */ 50 /* Do a cache flush for our text, in case the loader didn't */
483: lis r9,_start@ha 513: lis r9,_start@ha
49 addi r9,r9,_start@l 52 addi r9,r9,_start@l
50 add r9,r0,r9 53 add r9,r0,r9
@@ -59,6 +62,34 @@ _zimage_start:
59 sync 62 sync
60 isync 63 isync
61 64
62 mr r6,r1 65 /* Clear the BSS */
63 b start 66 lis r9,__bss_start@ha
67 addi r9,r9,__bss_start@l
68 add r9,r0,r9
69 lis r8,_end@ha
70 addi r8,r8,_end@l
71 add r8,r0,r8
72 li r10,0
735: stw r10,0(r9)
74 addi r9,r9,4
75 cmplw cr0,r9,r8
76 blt 5b
64 77
78 /* Possibly set up a custom stack */
79.weak _platform_stack_top
80 lis r8,_platform_stack_top@ha
81 addi r8,r8,_platform_stack_top@l
82 cmpwi r8,0
83 beq 6f
84 add r8,r0,r8
85 lwz r1,0(r8)
86 add r1,r0,r1
87 li r0,0
88 stwu r0,-16(r1) /* establish a stack frame */
896:
90
91 /* Call platform_init() */
92 bl platform_init
93
94 /* Call start */
95 b start
diff --git a/arch/powerpc/boot/cuboot-83xx.c b/arch/powerpc/boot/cuboot-83xx.c
new file mode 100644
index 000000000000..6cbc20afb4d8
--- /dev/null
+++ b/arch/powerpc/boot/cuboot-83xx.c
@@ -0,0 +1,68 @@
1/*
2 * Old U-boot compatibility for 83xx
3 *
4 * Author: Scott Wood <scottwood@freescale.com>
5 *
6 * Copyright (c) 2007 Freescale Semiconductor, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
11 */
12
13#include "ops.h"
14#include "stdio.h"
15
16#define TARGET_83xx
17#include "ppcboot.h"
18
19static bd_t bd;
20extern char _end[];
21extern char _dtb_start[], _dtb_end[];
22
23static void platform_fixups(void)
24{
25 void *soc;
26
27 dt_fixup_memory(bd.bi_memstart, bd.bi_memsize);
28 dt_fixup_mac_addresses(bd.bi_enetaddr, bd.bi_enet1addr);
29 dt_fixup_cpu_clocks(bd.bi_intfreq, bd.bi_busfreq / 4, bd.bi_busfreq);
30
31 /* Unfortunately, the specific model number is encoded in the
32 * soc node name in existing dts files -- once that is fixed,
33 * this can do a simple path lookup.
34 */
35 soc = find_node_by_devtype(NULL, "soc");
36 if (soc) {
37 void *serial = NULL;
38
39 setprop(soc, "bus-frequency", &bd.bi_busfreq,
40 sizeof(bd.bi_busfreq));
41
42 while ((serial = find_node_by_devtype(serial, "serial"))) {
43 if (get_parent(serial) != soc)
44 continue;
45
46 setprop(serial, "clock-frequency", &bd.bi_busfreq,
47 sizeof(bd.bi_busfreq));
48 }
49 }
50}
51
52void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
53 unsigned long r6, unsigned long r7)
54{
55 unsigned long end_of_ram = bd.bi_memstart + bd.bi_memsize;
56 unsigned long avail_ram = end_of_ram - (unsigned long)_end;
57
58 memcpy(&bd, (bd_t *)r3, sizeof(bd));
59 loader_info.initrd_addr = r4;
60 loader_info.initrd_size = r4 ? r5 : 0;
61 loader_info.cmdline = (char *)r6;
62 loader_info.cmdline_len = r7 - r6;
63
64 simple_alloc_init(_end, avail_ram - 1024*1024, 32, 64);
65 ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
66 serial_console_init();
67 platform_ops.fixups = platform_fixups;
68}
diff --git a/arch/powerpc/boot/cuboot-85xx.c b/arch/powerpc/boot/cuboot-85xx.c
new file mode 100644
index 000000000000..f88ba00ac122
--- /dev/null
+++ b/arch/powerpc/boot/cuboot-85xx.c
@@ -0,0 +1,69 @@
1/*
2 * Old U-boot compatibility for 85xx
3 *
4 * Author: Scott Wood <scottwood@freescale.com>
5 *
6 * Copyright (c) 2007 Freescale Semiconductor, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
11 */
12
13#include "ops.h"
14#include "stdio.h"
15
16#define TARGET_85xx
17#include "ppcboot.h"
18
19static bd_t bd;
20extern char _end[];
21extern char _dtb_start[], _dtb_end[];
22
23static void platform_fixups(void)
24{
25 void *soc;
26
27 dt_fixup_memory(bd.bi_memstart, bd.bi_memsize);
28 dt_fixup_mac_addresses(bd.bi_enetaddr, bd.bi_enet1addr,
29 bd.bi_enet2addr);
30 dt_fixup_cpu_clocks(bd.bi_intfreq, bd.bi_busfreq / 8, bd.bi_busfreq);
31
32 /* Unfortunately, the specific model number is encoded in the
33 * soc node name in existing dts files -- once that is fixed,
34 * this can do a simple path lookup.
35 */
36 soc = find_node_by_devtype(NULL, "soc");
37 if (soc) {
38 void *serial = NULL;
39
40 setprop(soc, "bus-frequency", &bd.bi_busfreq,
41 sizeof(bd.bi_busfreq));
42
43 while ((serial = find_node_by_devtype(serial, "serial"))) {
44 if (get_parent(serial) != soc)
45 continue;
46
47 setprop(serial, "clock-frequency", &bd.bi_busfreq,
48 sizeof(bd.bi_busfreq));
49 }
50 }
51}
52
53void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
54 unsigned long r6, unsigned long r7)
55{
56 unsigned long end_of_ram = bd.bi_memstart + bd.bi_memsize;
57 unsigned long avail_ram = end_of_ram - (unsigned long)_end;
58
59 memcpy(&bd, (bd_t *)r3, sizeof(bd));
60 loader_info.initrd_addr = r4;
61 loader_info.initrd_size = r4 ? r5 : 0;
62 loader_info.cmdline = (char *)r6;
63 loader_info.cmdline_len = r7 - r6;
64
65 simple_alloc_init(_end, avail_ram - 1024*1024, 32, 64);
66 ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
67 serial_console_init();
68 platform_ops.fixups = platform_fixups;
69}
diff --git a/arch/powerpc/boot/devtree.c b/arch/powerpc/boot/devtree.c
new file mode 100644
index 000000000000..c9951550ed2c
--- /dev/null
+++ b/arch/powerpc/boot/devtree.c
@@ -0,0 +1,307 @@
1/*
2 * devtree.c - convenience functions for device tree manipulation
3 * Copyright 2007 David Gibson, IBM Corporation.
4 * Copyright (c) 2007 Freescale Semiconductor, Inc.
5 *
6 * Authors: David Gibson <david@gibson.dropbear.id.au>
7 * Scott Wood <scottwood@freescale.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14#include <stdarg.h>
15#include <stddef.h>
16#include "types.h"
17#include "string.h"
18#include "stdio.h"
19#include "ops.h"
20
21void dt_fixup_memory(u64 start, u64 size)
22{
23 void *root, *memory;
24 int naddr, nsize, i;
25 u32 memreg[4];
26
27 root = finddevice("/");
28 if (getprop(root, "#address-cells", &naddr, sizeof(naddr)) < 0)
29 naddr = 2;
30 if (naddr < 1 || naddr > 2)
31 fatal("Can't cope with #address-cells == %d in /\n\r", naddr);
32
33 if (getprop(root, "#size-cells", &nsize, sizeof(nsize)) < 0)
34 nsize = 1;
35 if (nsize < 1 || nsize > 2)
36 fatal("Can't cope with #size-cells == %d in /\n\r", nsize);
37
38 i = 0;
39 if (naddr == 2)
40 memreg[i++] = start >> 32;
41 memreg[i++] = start & 0xffffffff;
42 if (nsize == 2)
43 memreg[i++] = size >> 32;
44 memreg[i++] = size & 0xffffffff;
45
46 memory = finddevice("/memory");
47 if (! memory) {
48 memory = create_node(NULL, "memory");
49 setprop_str(memory, "device_type", "memory");
50 }
51
52 printf("Memory <- <0x%x", memreg[0]);
53 for (i = 1; i < (naddr + nsize); i++)
54 printf(" 0x%x", memreg[i]);
55 printf("> (%ldMB)\n\r", (unsigned long)(size >> 20));
56
57 setprop(memory, "reg", memreg, (naddr + nsize)*sizeof(u32));
58}
59
60#define MHZ(x) ((x + 500000) / 1000000)
61
62void dt_fixup_cpu_clocks(u32 cpu, u32 tb, u32 bus)
63{
64 void *devp = NULL;
65
66 printf("CPU clock-frequency <- 0x%x (%dMHz)\n\r", cpu, MHZ(cpu));
67 printf("CPU timebase-frequency <- 0x%x (%dMHz)\n\r", tb, MHZ(tb));
68 if (bus > 0)
69 printf("CPU bus-frequency <- 0x%x (%dMHz)\n\r", bus, MHZ(bus));
70
71 while ((devp = find_node_by_devtype(devp, "cpu"))) {
72 setprop_val(devp, "clock-frequency", cpu);
73 setprop_val(devp, "timebase-frequency", tb);
74 if (bus > 0)
75 setprop_val(devp, "bus-frequency", bus);
76 }
77}
78
79void dt_fixup_clock(const char *path, u32 freq)
80{
81 void *devp = finddevice(path);
82
83 if (devp) {
84 printf("%s: clock-frequency <- %x (%dMHz)\n\r", path, freq, MHZ(freq));
85 setprop_val(devp, "clock-frequency", freq);
86 }
87}
88
89void __dt_fixup_mac_addresses(u32 startindex, ...)
90{
91 va_list ap;
92 u32 index = startindex;
93 void *devp;
94 const u8 *addr;
95
96 va_start(ap, startindex);
97 while ((addr = va_arg(ap, const u8 *))) {
98 devp = find_node_by_prop_value(NULL, "linux,network-index",
99 (void*)&index, sizeof(index));
100
101 printf("ENET%d: local-mac-address <-"
102 " %02x:%02x:%02x:%02x:%02x:%02x\n\r", index,
103 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
104
105 if (devp)
106 setprop(devp, "local-mac-address", addr, 6);
107
108 index++;
109 }
110 va_end(ap);
111}
112
113#define MAX_ADDR_CELLS 4
114#define MAX_RANGES 8
115
116static void get_reg_format(void *node, u32 *naddr, u32 *nsize)
117{
118 if (getprop(node, "#address-cells", naddr, 4) != 4)
119 *naddr = 2;
120 if (getprop(node, "#size-cells", nsize, 4) != 4)
121 *nsize = 1;
122}
123
124static void copy_val(u32 *dest, u32 *src, int naddr)
125{
126 int pad = MAX_ADDR_CELLS - naddr;
127
128 memset(dest, 0, pad * 4);
129 memcpy(dest + pad, src, naddr * 4);
130}
131
132static int sub_reg(u32 *reg, u32 *sub)
133{
134 int i, borrow = 0;
135
136 for (i = MAX_ADDR_CELLS - 1; i >= 0; i--) {
137 int prev_borrow = borrow;
138 borrow = reg[i] < sub[i] + prev_borrow;
139 reg[i] -= sub[i] + prev_borrow;
140 }
141
142 return !borrow;
143}
144
145static int add_reg(u32 *reg, u32 *add, int naddr)
146{
147 int i, carry = 0;
148
149 for (i = MAX_ADDR_CELLS - 1; i >= MAX_ADDR_CELLS - naddr; i--) {
150 u64 tmp = (u64)reg[i] + add[i] + carry;
151 carry = tmp >> 32;
152 reg[i] = (u32)tmp;
153 }
154
155 return !carry;
156}
157
158/* It is assumed that if the first byte of reg fits in a
159 * range, then the whole reg block fits.
160 */
161static int compare_reg(u32 *reg, u32 *range, u32 *rangesize)
162{
163 int i;
164 u32 end;
165
166 for (i = 0; i < MAX_ADDR_CELLS; i++) {
167 if (reg[i] < range[i])
168 return 0;
169 if (reg[i] > range[i])
170 break;
171 }
172
173 for (i = 0; i < MAX_ADDR_CELLS; i++) {
174 end = range[i] + rangesize[i];
175
176 if (reg[i] < end)
177 break;
178 if (reg[i] > end)
179 return 0;
180 }
181
182 return reg[i] != end;
183}
184
185/* reg must be MAX_ADDR_CELLS */
186static int find_range(u32 *reg, u32 *ranges, int nregaddr,
187 int naddr, int nsize, int buflen)
188{
189 int nrange = nregaddr + naddr + nsize;
190 int i;
191
192 for (i = 0; i + nrange <= buflen; i += nrange) {
193 u32 range_addr[MAX_ADDR_CELLS];
194 u32 range_size[MAX_ADDR_CELLS];
195
196 copy_val(range_addr, ranges + i, naddr);
197 copy_val(range_size, ranges + i + nregaddr + naddr, nsize);
198
199 if (compare_reg(reg, range_addr, range_size))
200 return i;
201 }
202
203 return -1;
204}
205
206/* Currently only generic buses without special encodings are supported.
207 * In particular, PCI is not supported. Also, only the beginning of the
208 * reg block is tracked; size is ignored except in ranges.
209 */
210static u32 dt_xlate_buf[MAX_ADDR_CELLS * MAX_RANGES * 3];
211
212static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
213 unsigned long *size)
214{
215 u32 last_addr[MAX_ADDR_CELLS];
216 u32 this_addr[MAX_ADDR_CELLS];
217 void *parent;
218 u64 ret_addr, ret_size;
219 u32 naddr, nsize, prev_naddr;
220 int buflen, offset;
221
222 parent = get_parent(node);
223 if (!parent)
224 return 0;
225
226 get_reg_format(parent, &naddr, &nsize);
227
228 if (nsize > 2)
229 return 0;
230
231 offset = (naddr + nsize) * res;
232
233 if (reglen < offset + naddr + nsize ||
234 sizeof(dt_xlate_buf) < offset + naddr + nsize)
235 return 0;
236
237 copy_val(last_addr, dt_xlate_buf + offset, naddr);
238
239 ret_size = dt_xlate_buf[offset + naddr];
240 if (nsize == 2) {
241 ret_size <<= 32;
242 ret_size |= dt_xlate_buf[offset + naddr + 1];
243 }
244
245 while ((node = get_parent(node))) {
246 prev_naddr = naddr;
247
248 get_reg_format(node, &naddr, &nsize);
249
250 buflen = getprop(node, "ranges", dt_xlate_buf,
251 sizeof(dt_xlate_buf));
252 if (buflen < 0)
253 continue;
254 if (buflen > sizeof(dt_xlate_buf))
255 return 0;
256
257 offset = find_range(last_addr, dt_xlate_buf, prev_naddr,
258 naddr, nsize, buflen / 4);
259
260 if (offset < 0)
261 return 0;
262
263 copy_val(this_addr, dt_xlate_buf + offset, prev_naddr);
264
265 if (!sub_reg(last_addr, this_addr))
266 return 0;
267
268 copy_val(this_addr, dt_xlate_buf + offset + prev_naddr, naddr);
269
270 if (!add_reg(last_addr, this_addr, naddr))
271 return 0;
272 }
273
274 if (naddr > 2)
275 return 0;
276
277 ret_addr = ((u64)last_addr[2] << 32) | last_addr[3];
278
279 if (sizeof(void *) == 4 &&
280 (ret_addr >= 0x100000000ULL || ret_size > 0x100000000ULL ||
281 ret_addr + ret_size > 0x100000000ULL))
282 return 0;
283
284 *addr = ret_addr;
285 if (size)
286 *size = ret_size;
287
288 return 1;
289}
290
291int dt_xlate_reg(void *node, int res, unsigned long *addr, unsigned long *size)
292{
293 int reglen;
294
295 reglen = getprop(node, "reg", dt_xlate_buf, sizeof(dt_xlate_buf)) / 4;
296 return dt_xlate(node, res, reglen, addr, size);
297}
298
299int dt_xlate_addr(void *node, u32 *buf, int buflen, unsigned long *xlated_addr)
300{
301
302 if (buflen > sizeof(dt_xlate_buf))
303 return 0;
304
305 memcpy(dt_xlate_buf, buf, buflen);
306 return dt_xlate(node, 0, buflen / 4, xlated_addr, NULL);
307}
diff --git a/arch/powerpc/boot/dts/kuroboxHD.dts b/arch/powerpc/boot/dts/kuroboxHD.dts
index b89791802e86..157dc98d3988 100644
--- a/arch/powerpc/boot/dts/kuroboxHD.dts
+++ b/arch/powerpc/boot/dts/kuroboxHD.dts
@@ -29,7 +29,6 @@ build with: "dtc -f -I dts -O dtb -o kuroboxHD.dtb -V 16 kuroboxHD.dts"
29 29
30 cpus { 30 cpus {
31 linux,phandle = <2000>; 31 linux,phandle = <2000>;
32 #cpus = <1>;
33 #address-cells = <1>; 32 #address-cells = <1>;
34 #size-cells = <0>; 33 #size-cells = <0>;
35 34
@@ -126,17 +125,17 @@ build with: "dtc -f -I dts -O dtb -o kuroboxHD.dtb -V 16 kuroboxHD.dts"
126 interrupt-parent = <4400>; 125 interrupt-parent = <4400>;
127 interrupt-map-mask = <f800 0 0 7>; 126 interrupt-map-mask = <f800 0 0 7>;
128 interrupt-map = < 127 interrupt-map = <
129 /* IDSEL 0x11 - IRQ0 ETH */ 128 /* IDSEL 11 - IRQ0 ETH */
130 5800 0 0 1 4400 0 1 129 5800 0 0 1 4400 0 1
131 5800 0 0 2 4400 1 1 130 5800 0 0 2 4400 1 1
132 5800 0 0 3 4400 2 1 131 5800 0 0 3 4400 2 1
133 5800 0 0 4 4400 3 1 132 5800 0 0 4 4400 3 1
134 /* IDSEL 0x12 - IRQ1 IDE0 */ 133 /* IDSEL 12 - IRQ1 IDE0 */
135 6000 0 0 1 4400 1 1 134 6000 0 0 1 4400 1 1
136 6000 0 0 2 4400 2 1 135 6000 0 0 2 4400 2 1
137 6000 0 0 3 4400 3 1 136 6000 0 0 3 4400 3 1
138 6000 0 0 4 4400 0 1 137 6000 0 0 4 4400 0 1
139 /* IDSEL 0x14 - IRQ3 USB2.0 */ 138 /* IDSEL 14 - IRQ3 USB2.0 */
140 7000 0 0 1 4400 3 1 139 7000 0 0 1 4400 3 1
141 7000 0 0 2 4400 3 1 140 7000 0 0 2 4400 3 1
142 7000 0 0 3 4400 3 1 141 7000 0 0 3 4400 3 1
diff --git a/arch/powerpc/boot/dts/kuroboxHG.dts b/arch/powerpc/boot/dts/kuroboxHG.dts
index 753102752d8b..919eb29097db 100644
--- a/arch/powerpc/boot/dts/kuroboxHG.dts
+++ b/arch/powerpc/boot/dts/kuroboxHG.dts
@@ -29,7 +29,6 @@ build with: "dtc -f -I dts -O dtb -o kuroboxHG.dtb -V 16 kuroboxHG.dts"
29 29
30 cpus { 30 cpus {
31 linux,phandle = <2000>; 31 linux,phandle = <2000>;
32 #cpus = <1>;
33 #address-cells = <1>; 32 #address-cells = <1>;
34 #size-cells = <0>; 33 #size-cells = <0>;
35 34
@@ -126,17 +125,17 @@ build with: "dtc -f -I dts -O dtb -o kuroboxHG.dtb -V 16 kuroboxHG.dts"
126 interrupt-parent = <4400>; 125 interrupt-parent = <4400>;
127 interrupt-map-mask = <f800 0 0 7>; 126 interrupt-map-mask = <f800 0 0 7>;
128 interrupt-map = < 127 interrupt-map = <
129 /* IDSEL 0x11 - IRQ0 ETH */ 128 /* IDSEL 11 - IRQ0 ETH */
130 5800 0 0 1 4400 0 1 129 5800 0 0 1 4400 0 1
131 5800 0 0 2 4400 1 1 130 5800 0 0 2 4400 1 1
132 5800 0 0 3 4400 2 1 131 5800 0 0 3 4400 2 1
133 5800 0 0 4 4400 3 1 132 5800 0 0 4 4400 3 1
134 /* IDSEL 0x12 - IRQ1 IDE0 */ 133 /* IDSEL 12 - IRQ1 IDE0 */
135 6000 0 0 1 4400 1 1 134 6000 0 0 1 4400 1 1
136 6000 0 0 2 4400 2 1 135 6000 0 0 2 4400 2 1
137 6000 0 0 3 4400 3 1 136 6000 0 0 3 4400 3 1
138 6000 0 0 4 4400 0 1 137 6000 0 0 4 4400 0 1
139 /* IDSEL 0x14 - IRQ3 USB2.0 */ 138 /* IDSEL 14 - IRQ3 USB2.0 */
140 7000 0 0 1 4400 3 1 139 7000 0 0 1 4400 3 1
141 7000 0 0 2 4400 3 1 140 7000 0 0 2 4400 3 1
142 7000 0 0 3 4400 3 1 141 7000 0 0 3 4400 3 1
diff --git a/arch/powerpc/boot/dts/lite5200.dts b/arch/powerpc/boot/dts/lite5200.dts
index c03103c63285..ba54c6b40a09 100644
--- a/arch/powerpc/boot/dts/lite5200.dts
+++ b/arch/powerpc/boot/dts/lite5200.dts
@@ -24,7 +24,6 @@
24 #size-cells = <1>; 24 #size-cells = <1>;
25 25
26 cpus { 26 cpus {
27 #cpus = <1>;
28 #address-cells = <1>; 27 #address-cells = <1>;
29 #size-cells = <0>; 28 #size-cells = <0>;
30 29
diff --git a/arch/powerpc/boot/dts/lite5200b.dts b/arch/powerpc/boot/dts/lite5200b.dts
index 3875ca9a9a62..2e003081b0d3 100644
--- a/arch/powerpc/boot/dts/lite5200b.dts
+++ b/arch/powerpc/boot/dts/lite5200b.dts
@@ -24,7 +24,6 @@
24 #size-cells = <1>; 24 #size-cells = <1>;
25 25
26 cpus { 26 cpus {
27 #cpus = <1>;
28 #address-cells = <1>; 27 #address-cells = <1>;
29 #size-cells = <0>; 28 #size-cells = <0>;
30 29
diff --git a/arch/powerpc/boot/dts/mpc7448hpc2.dts b/arch/powerpc/boot/dts/mpc7448hpc2.dts
index 41d0720c5900..6fa3754f293a 100644
--- a/arch/powerpc/boot/dts/mpc7448hpc2.dts
+++ b/arch/powerpc/boot/dts/mpc7448hpc2.dts
@@ -19,7 +19,6 @@
19 linux,phandle = <100>; 19 linux,phandle = <100>;
20 20
21 cpus { 21 cpus {
22 #cpus = <1>;
23 #address-cells = <1>; 22 #address-cells = <1>;
24 #size-cells =<0>; 23 #size-cells =<0>;
25 linux,phandle = <200>; 24 linux,phandle = <200>;
diff --git a/arch/powerpc/boot/dts/mpc8272ads.dts b/arch/powerpc/boot/dts/mpc8272ads.dts
index 260b2e447779..423eedcf634f 100644
--- a/arch/powerpc/boot/dts/mpc8272ads.dts
+++ b/arch/powerpc/boot/dts/mpc8272ads.dts
@@ -17,7 +17,6 @@
17 linux,phandle = <100>; 17 linux,phandle = <100>;
18 18
19 cpus { 19 cpus {
20 #cpus = <1>;
21 #address-cells = <1>; 20 #address-cells = <1>;
22 #size-cells = <0>; 21 #size-cells = <0>;
23 linux,phandle = <200>; 22 linux,phandle = <200>;
diff --git a/arch/powerpc/boot/dts/mpc8313erdb.dts b/arch/powerpc/boot/dts/mpc8313erdb.dts
index 6d721900d00e..a1533cc07d09 100644
--- a/arch/powerpc/boot/dts/mpc8313erdb.dts
+++ b/arch/powerpc/boot/dts/mpc8313erdb.dts
@@ -16,7 +16,6 @@
16 #size-cells = <1>; 16 #size-cells = <1>;
17 17
18 cpus { 18 cpus {
19 #cpus = <1>;
20 #address-cells = <1>; 19 #address-cells = <1>;
21 #size-cells = <0>; 20 #size-cells = <0>;
22 21
diff --git a/arch/powerpc/boot/dts/mpc832x_mds.dts b/arch/powerpc/boot/dts/mpc832x_mds.dts
index 06b310698a02..c798491f4cd0 100644
--- a/arch/powerpc/boot/dts/mpc832x_mds.dts
+++ b/arch/powerpc/boot/dts/mpc832x_mds.dts
@@ -16,7 +16,6 @@
16 #size-cells = <1>; 16 #size-cells = <1>;
17 17
18 cpus { 18 cpus {
19 #cpus = <1>;
20 #address-cells = <1>; 19 #address-cells = <1>;
21 #size-cells = <0>; 20 #size-cells = <0>;
22 21
diff --git a/arch/powerpc/boot/dts/mpc832x_rdb.dts b/arch/powerpc/boot/dts/mpc832x_rdb.dts
new file mode 100644
index 000000000000..b55bced1593d
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc832x_rdb.dts
@@ -0,0 +1,291 @@
1/*
2 * MPC832x RDB Device Tree Source
3 *
4 * Copyright 2007 Freescale Semiconductor Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12/ {
13 model = "MPC8323ERDB";
14 compatible = "MPC8323ERDB", "MPC832xRDB", "MPC83xxRDB";
15 #address-cells = <1>;
16 #size-cells = <1>;
17
18 cpus {
19 #address-cells = <1>;
20 #size-cells = <0>;
21
22 PowerPC,8323@0 {
23 device_type = "cpu";
24 reg = <0>;
25 d-cache-line-size = <20>; // 32 bytes
26 i-cache-line-size = <20>; // 32 bytes
27 d-cache-size = <4000>; // L1, 16K
28 i-cache-size = <4000>; // L1, 16K
29 timebase-frequency = <0>;
30 bus-frequency = <0>;
31 clock-frequency = <0>;
32 32-bit;
33 };
34 };
35
36 memory {
37 device_type = "memory";
38 reg = <00000000 04000000>;
39 };
40
41 soc8323@e0000000 {
42 #address-cells = <1>;
43 #size-cells = <1>;
44 #interrupt-cells = <2>;
45 device_type = "soc";
46 ranges = <0 e0000000 00100000>;
47 reg = <e0000000 00000200>;
48 bus-frequency = <0>;
49
50 wdt@200 {
51 device_type = "watchdog";
52 compatible = "mpc83xx_wdt";
53 reg = <200 100>;
54 };
55
56 i2c@3000 {
57 device_type = "i2c";
58 compatible = "fsl-i2c";
59 reg = <3000 100>;
60 interrupts = <e 8>;
61 interrupt-parent = <&pic>;
62 dfsrr;
63 };
64
65 serial@4500 {
66 device_type = "serial";
67 compatible = "ns16550";
68 reg = <4500 100>;
69 clock-frequency = <0>;
70 interrupts = <9 8>;
71 interrupt-parent = <&pic>;
72 };
73
74 serial@4600 {
75 device_type = "serial";
76 compatible = "ns16550";
77 reg = <4600 100>;
78 clock-frequency = <0>;
79 interrupts = <a 8>;
80 interrupt-parent = <&pic>;
81 };
82
83 crypto@30000 {
84 device_type = "crypto";
85 model = "SEC2";
86 compatible = "talitos";
87 reg = <30000 7000>;
88 interrupts = <b 8>;
89 interrupt-parent = <&pic>;
90 /* Rev. 2.2 */
91 num-channels = <1>;
92 channel-fifo-len = <18>;
93 exec-units-mask = <0000004c>;
94 descriptor-types-mask = <0122003f>;
95 };
96
97 pci@8500 {
98 interrupt-map-mask = <f800 0 0 7>;
99 interrupt-map = <
100 /* IDSEL 0x10 AD16 (USB) */
101 8000 0 0 1 &pic 11 8
102
103 /* IDSEL 0x11 AD17 (Mini1)*/
104 8800 0 0 1 &pic 12 8
105 8800 0 0 2 &pic 13 8
106 8800 0 0 3 &pic 14 8
107 8800 0 0 4 &pic 30 8
108
109 /* IDSEL 0x12 AD18 (PCI/Mini2) */
110 9000 0 0 1 &pic 13 8
111 9000 0 0 2 &pic 14 8
112 9000 0 0 3 &pic 30 8
113 9000 0 0 4 &pic 11 8>;
114
115 interrupt-parent = <&pic>;
116 interrupts = <42 8>;
117 bus-range = <0 0>;
118 ranges = <42000000 0 80000000 80000000 0 10000000
119 02000000 0 90000000 90000000 0 10000000
120 01000000 0 d0000000 d0000000 0 04000000>;
121 clock-frequency = <0>;
122 #interrupt-cells = <1>;
123 #size-cells = <2>;
124 #address-cells = <3>;
125 reg = <8500 100>;
126 compatible = "83xx";
127 device_type = "pci";
128 };
129
130 pic:pic@700 {
131 interrupt-controller;
132 #address-cells = <0>;
133 #interrupt-cells = <2>;
134 reg = <700 100>;
135 built-in;
136 device_type = "ipic";
137 };
138
139 par_io@1400 {
140 reg = <1400 100>;
141 device_type = "par_io";
142 num-ports = <7>;
143
144 ucc2pio:ucc_pin@02 {
145 pio-map = <
146 /* port pin dir open_drain assignment has_irq */
147 3 4 3 0 2 0 /* MDIO */
148 3 5 1 0 2 0 /* MDC */
149 3 15 2 0 1 0 /* RX_CLK (CLK16) */
150 3 17 2 0 1 0 /* TX_CLK (CLK3) */
151 0 12 1 0 1 0 /* TxD0 */
152 0 13 1 0 1 0 /* TxD1 */
153 0 14 1 0 1 0 /* TxD2 */
154 0 15 1 0 1 0 /* TxD3 */
155 0 16 2 0 1 0 /* RxD0 */
156 0 17 2 0 1 0 /* RxD1 */
157 0 18 2 0 1 0 /* RxD2 */
158 0 19 2 0 1 0 /* RxD3 */
159 0 1a 2 0 1 0 /* RX_ER */
160 0 1b 1 0 1 0 /* TX_ER */
161 0 1c 2 0 1 0 /* RX_DV */
162 0 1d 2 0 1 0 /* COL */
163 0 1e 1 0 1 0 /* TX_EN */
164 0 1f 2 0 1 0>; /* CRS */
165 };
166 ucc3pio:ucc_pin@03 {
167 pio-map = <
168 /* port pin dir open_drain assignment has_irq */
169 0 d 2 0 1 0 /* RX_CLK (CLK9) */
170 3 18 2 0 1 0 /* TX_CLK (CLK10) */
171 1 0 1 0 1 0 /* TxD0 */
172 1 1 1 0 1 0 /* TxD1 */
173 1 2 1 0 1 0 /* TxD2 */
174 1 3 1 0 1 0 /* TxD3 */
175 1 4 2 0 1 0 /* RxD0 */
176 1 5 2 0 1 0 /* RxD1 */
177 1 6 2 0 1 0 /* RxD2 */
178 1 7 2 0 1 0 /* RxD3 */
179 1 8 2 0 1 0 /* RX_ER */
180 1 9 1 0 1 0 /* TX_ER */
181 1 a 2 0 1 0 /* RX_DV */
182 1 b 2 0 1 0 /* COL */
183 1 c 1 0 1 0 /* TX_EN */
184 1 d 2 0 1 0>; /* CRS */
185 };
186 };
187 };
188
189 qe@e0100000 {
190 #address-cells = <1>;
191 #size-cells = <1>;
192 device_type = "qe";
193 model = "QE";
194 ranges = <0 e0100000 00100000>;
195 reg = <e0100000 480>;
196 brg-frequency = <0>;
197 bus-frequency = <BCD3D80>;
198
199 muram@10000 {
200 device_type = "muram";
201 ranges = <0 00010000 00004000>;
202
203 data-only@0 {
204 reg = <0 4000>;
205 };
206 };
207
208 spi@4c0 {
209 device_type = "spi";
210 compatible = "fsl_spi";
211 reg = <4c0 40>;
212 interrupts = <2>;
213 interrupt-parent = <&qeic>;
214 mode = "cpu";
215 };
216
217 spi@500 {
218 device_type = "spi";
219 compatible = "fsl_spi";
220 reg = <500 40>;
221 interrupts = <1>;
222 interrupt-parent = <&qeic>;
223 mode = "cpu";
224 };
225
226 ucc@3000 {
227 device_type = "network";
228 compatible = "ucc_geth";
229 model = "UCC";
230 device-id = <2>;
231 reg = <3000 200>;
232 interrupts = <21>;
233 interrupt-parent = <&qeic>;
234 mac-address = [ 00 04 9f ef 03 02 ];
235 rx-clock = <20>;
236 tx-clock = <13>;
237 phy-handle = <&phy00>;
238 pio-handle = <&ucc2pio>;
239 };
240
241 ucc@2200 {
242 device_type = "network";
243 compatible = "ucc_geth";
244 model = "UCC";
245 device-id = <3>;
246 reg = <2200 200>;
247 interrupts = <22>;
248 interrupt-parent = <&qeic>;
249 mac-address = [ 00 04 9f ef 03 01 ];
250 rx-clock = <19>;
251 tx-clock = <1a>;
252 phy-handle = <&phy04>;
253 pio-handle = <&ucc3pio>;
254 };
255
256 mdio@3120 {
257 #address-cells = <1>;
258 #size-cells = <0>;
259 reg = <3120 18>;
260 device_type = "mdio";
261 compatible = "ucc_geth_phy";
262
263 phy00:ethernet-phy@00 {
264 interrupt-parent = <&pic>;
265 interrupts = <0>;
266 reg = <0>;
267 device_type = "ethernet-phy";
268 interface = <3>; //ENET_100_MII
269 };
270 phy04:ethernet-phy@04 {
271 interrupt-parent = <&pic>;
272 interrupts = <0>;
273 reg = <4>;
274 device_type = "ethernet-phy";
275 interface = <3>;
276 };
277 };
278
279 qeic:qeic@80 {
280 interrupt-controller;
281 device_type = "qeic";
282 #address-cells = <0>;
283 #interrupt-cells = <1>;
284 reg = <80 80>;
285 built-in;
286 big-endian;
287 interrupts = <20 8 21 8>; //high:32 low:33
288 interrupt-parent = <&pic>;
289 };
290 };
291};
diff --git a/arch/powerpc/boot/dts/mpc8349emitx.dts b/arch/powerpc/boot/dts/mpc8349emitx.dts
index 61b550bf1645..db0d00303275 100644
--- a/arch/powerpc/boot/dts/mpc8349emitx.dts
+++ b/arch/powerpc/boot/dts/mpc8349emitx.dts
@@ -15,7 +15,6 @@
15 #size-cells = <1>; 15 #size-cells = <1>;
16 16
17 cpus { 17 cpus {
18 #cpus = <1>;
19 #address-cells = <1>; 18 #address-cells = <1>;
20 #size-cells = <0>; 19 #size-cells = <0>;
21 20
diff --git a/arch/powerpc/boot/dts/mpc8349emitxgp.dts b/arch/powerpc/boot/dts/mpc8349emitxgp.dts
index b2e1a5ec3779..f636528a3c72 100644
--- a/arch/powerpc/boot/dts/mpc8349emitxgp.dts
+++ b/arch/powerpc/boot/dts/mpc8349emitxgp.dts
@@ -15,7 +15,6 @@
15 #size-cells = <1>; 15 #size-cells = <1>;
16 16
17 cpus { 17 cpus {
18 #cpus = <1>;
19 #address-cells = <1>; 18 #address-cells = <1>;
20 #size-cells = <0>; 19 #size-cells = <0>;
21 20
diff --git a/arch/powerpc/boot/dts/mpc834x_mds.dts b/arch/powerpc/boot/dts/mpc834x_mds.dts
index e4b43c24bc0b..07bcc5194d2b 100644
--- a/arch/powerpc/boot/dts/mpc834x_mds.dts
+++ b/arch/powerpc/boot/dts/mpc834x_mds.dts
@@ -16,7 +16,6 @@
16 #size-cells = <1>; 16 #size-cells = <1>;
17 17
18 cpus { 18 cpus {
19 #cpus = <1>;
20 #address-cells = <1>; 19 #address-cells = <1>;
21 #size-cells = <0>; 20 #size-cells = <0>;
22 21
diff --git a/arch/powerpc/boot/dts/mpc836x_mds.dts b/arch/powerpc/boot/dts/mpc836x_mds.dts
index 4fe45c021848..7f578eb57082 100644
--- a/arch/powerpc/boot/dts/mpc836x_mds.dts
+++ b/arch/powerpc/boot/dts/mpc836x_mds.dts
@@ -21,7 +21,6 @@
21 #size-cells = <1>; 21 #size-cells = <1>;
22 22
23 cpus { 23 cpus {
24 #cpus = <1>;
25 #address-cells = <1>; 24 #address-cells = <1>;
26 #size-cells = <0>; 25 #size-cells = <0>;
27 26
diff --git a/arch/powerpc/boot/dts/mpc8540ads.dts b/arch/powerpc/boot/dts/mpc8540ads.dts
index 3c0917fa791c..f261d647ac85 100644
--- a/arch/powerpc/boot/dts/mpc8540ads.dts
+++ b/arch/powerpc/boot/dts/mpc8540ads.dts
@@ -17,7 +17,6 @@
17 #size-cells = <1>; 17 #size-cells = <1>;
18 18
19 cpus { 19 cpus {
20 #cpus = <1>;
21 #address-cells = <1>; 20 #address-cells = <1>;
22 #size-cells = <0>; 21 #size-cells = <0>;
23 22
diff --git a/arch/powerpc/boot/dts/mpc8541cds.dts b/arch/powerpc/boot/dts/mpc8541cds.dts
index 2a1ae760ab3a..5fdcb69554f2 100644
--- a/arch/powerpc/boot/dts/mpc8541cds.dts
+++ b/arch/powerpc/boot/dts/mpc8541cds.dts
@@ -17,7 +17,6 @@
17 #size-cells = <1>; 17 #size-cells = <1>;
18 18
19 cpus { 19 cpus {
20 #cpus = <1>;
21 #address-cells = <1>; 20 #address-cells = <1>;
22 #size-cells = <0>; 21 #size-cells = <0>;
23 22
diff --git a/arch/powerpc/boot/dts/mpc8544ds.dts b/arch/powerpc/boot/dts/mpc8544ds.dts
new file mode 100644
index 000000000000..6b084605bb4b
--- /dev/null
+++ b/arch/powerpc/boot/dts/mpc8544ds.dts
@@ -0,0 +1,136 @@
1/*
2 * MPC8544 DS Device Tree Source
3 *
4 * Copyright 2007 Freescale Semiconductor Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12/ {
13 model = "MPC8544DS";
14 compatible = "MPC8544DS", "MPC85xxDS";
15 #address-cells = <1>;
16 #size-cells = <1>;
17
18 cpus {
19 #cpus = <1>;
20 #address-cells = <1>;
21 #size-cells = <0>;
22
23 PowerPC,8544@0 {
24 device_type = "cpu";
25 reg = <0>;
26 d-cache-line-size = <20>; // 32 bytes
27 i-cache-line-size = <20>; // 32 bytes
28 d-cache-size = <8000>; // L1, 32K
29 i-cache-size = <8000>; // L1, 32K
30 timebase-frequency = <0>;
31 bus-frequency = <0>;
32 clock-frequency = <0>;
33 32-bit;
34 };
35 };
36
37 memory {
38 device_type = "memory";
39 reg = <00000000 00000000>; // Filled by U-Boot
40 };
41
42 soc8544@e0000000 {
43 #address-cells = <1>;
44 #size-cells = <1>;
45 #interrupt-cells = <2>;
46 device_type = "soc";
47 ranges = <0 e0000000 00100000>;
48 reg = <e0000000 00100000>; // CCSRBAR 1M
49 bus-frequency = <0>; // Filled out by uboot.
50
51 i2c@3000 {
52 device_type = "i2c";
53 compatible = "fsl-i2c";
54 reg = <3000 100>;
55 interrupts = <1b 2>;
56 interrupt-parent = <&mpic>;
57 dfsrr;
58 };
59
60 mdio@24520 {
61 #address-cells = <1>;
62 #size-cells = <0>;
63 device_type = "mdio";
64 compatible = "gianfar";
65 reg = <24520 20>;
66 phy0: ethernet-phy@0 {
67 interrupt-parent = <&mpic>;
68 interrupts = <3a 1>;
69 reg = <0>;
70 device_type = "ethernet-phy";
71 };
72 phy1: ethernet-phy@1 {
73 interrupt-parent = <&mpic>;
74 interrupts = <3a 1>;
75 reg = <1>;
76 device_type = "ethernet-phy";
77 };
78 };
79
80 ethernet@24000 {
81 #address-cells = <1>;
82 #size-cells = <0>;
83 device_type = "network";
84 model = "TSEC";
85 compatible = "gianfar";
86 reg = <24000 1000>;
87 local-mac-address = [ 00 00 00 00 00 00 ];
88 interrupts = <d 2 e 2 12 2>;
89 interrupt-parent = <&mpic>;
90 phy-handle = <&phy0>;
91 };
92
93 ethernet@26000 {
94 #address-cells = <1>;
95 #size-cells = <0>;
96 device_type = "network";
97 model = "TSEC";
98 compatible = "gianfar";
99 reg = <26000 1000>;
100 local-mac-address = [ 00 00 00 00 00 00 ];
101 interrupts = <f 2 10 2 11 2>;
102 interrupt-parent = <&mpic>;
103 phy-handle = <&phy1>;
104 };
105
106 serial@4500 {
107 device_type = "serial";
108 compatible = "ns16550";
109 reg = <4500 100>;
110 clock-frequency = <0>;
111 interrupts = <1a 2>;
112 interrupt-parent = <&mpic>;
113 };
114
115 serial@4600 {
116 device_type = "serial";
117 compatible = "ns16550";
118 reg = <4600 100>;
119 clock-frequency = <0>;
120 interrupts = <1a 2>;
121 interrupt-parent = <&mpic>;
122 };
123
124 mpic: pic@40000 {
125 clock-frequency = <0>;
126 interrupt-controller;
127 #address-cells = <0>;
128 #interrupt-cells = <2>;
129 reg = <40000 40000>;
130 built-in;
131 compatible = "chrp,open-pic";
132 device_type = "open-pic";
133 big-endian;
134 };
135 };
136};
diff --git a/arch/powerpc/boot/dts/mpc8548cds.dts b/arch/powerpc/boot/dts/mpc8548cds.dts
index 7eb5d81d5eec..b2b2200d0425 100644
--- a/arch/powerpc/boot/dts/mpc8548cds.dts
+++ b/arch/powerpc/boot/dts/mpc8548cds.dts
@@ -17,7 +17,6 @@
17 #size-cells = <1>; 17 #size-cells = <1>;
18 18
19 cpus { 19 cpus {
20 #cpus = <1>;
21 #address-cells = <1>; 20 #address-cells = <1>;
22 #size-cells = <0>; 21 #size-cells = <0>;
23 22
diff --git a/arch/powerpc/boot/dts/mpc8555cds.dts b/arch/powerpc/boot/dts/mpc8555cds.dts
index 5f9c102a0ab4..68a4795720dc 100644
--- a/arch/powerpc/boot/dts/mpc8555cds.dts
+++ b/arch/powerpc/boot/dts/mpc8555cds.dts
@@ -17,7 +17,6 @@
17 #size-cells = <1>; 17 #size-cells = <1>;
18 18
19 cpus { 19 cpus {
20 #cpus = <1>;
21 #address-cells = <1>; 20 #address-cells = <1>;
22 #size-cells = <0>; 21 #size-cells = <0>;
23 22
diff --git a/arch/powerpc/boot/dts/mpc8560ads.dts b/arch/powerpc/boot/dts/mpc8560ads.dts
index 10502638b0e9..1f2afe9291d2 100644
--- a/arch/powerpc/boot/dts/mpc8560ads.dts
+++ b/arch/powerpc/boot/dts/mpc8560ads.dts
@@ -17,7 +17,6 @@
17 #size-cells = <1>; 17 #size-cells = <1>;
18 18
19 cpus { 19 cpus {
20 #cpus = <1>;
21 #address-cells = <1>; 20 #address-cells = <1>;
22 #size-cells = <0>; 21 #size-cells = <0>;
23 22
diff --git a/arch/powerpc/boot/dts/mpc8568mds.dts b/arch/powerpc/boot/dts/mpc8568mds.dts
index bf49d8c997b9..7361b36749cb 100644
--- a/arch/powerpc/boot/dts/mpc8568mds.dts
+++ b/arch/powerpc/boot/dts/mpc8568mds.dts
@@ -21,7 +21,6 @@
21 #size-cells = <1>; 21 #size-cells = <1>;
22 22
23 cpus { 23 cpus {
24 #cpus = <1>;
25 #address-cells = <1>; 24 #address-cells = <1>;
26 #size-cells = <0>; 25 #size-cells = <0>;
27 26
diff --git a/arch/powerpc/boot/dts/mpc8641_hpcn.dts b/arch/powerpc/boot/dts/mpc8641_hpcn.dts
index 8a4995a85ba0..260b264c869e 100644
--- a/arch/powerpc/boot/dts/mpc8641_hpcn.dts
+++ b/arch/powerpc/boot/dts/mpc8641_hpcn.dts
@@ -17,7 +17,6 @@
17 #size-cells = <1>; 17 #size-cells = <1>;
18 18
19 cpus { 19 cpus {
20 #cpus = <2>;
21 #address-cells = <1>; 20 #address-cells = <1>;
22 #size-cells = <0>; 21 #size-cells = <0>;
23 22
@@ -300,6 +299,30 @@
300 }; 299 };
301 300
302 }; 301 };
302
303 pci@9000 {
304 compatible = "86xx";
305 device_type = "pci";
306 #interrupt-cells = <1>;
307 #size-cells = <2>;
308 #address-cells = <3>;
309 reg = <9000 1000>;
310 bus-range = <0 ff>;
311 ranges = <02000000 0 a0000000 a0000000 0 20000000
312 01000000 0 00000000 e3000000 0 00100000>;
313 clock-frequency = <1fca055>;
314 interrupt-parent = <&mpic>;
315 interrupts = <19 2>;
316 interrupt-map-mask = <f800 0 0 7>;
317 interrupt-map = <
318 /* IDSEL 0x0 */
319 0000 0 0 1 &mpic 44 1
320 0000 0 0 2 &mpic 45 1
321 0000 0 0 3 &mpic 46 1
322 0000 0 0 4 &mpic 47 1
323 >;
324 };
325
303 mpic: pic@40000 { 326 mpic: pic@40000 {
304 clock-frequency = <0>; 327 clock-frequency = <0>;
305 interrupt-controller; 328 interrupt-controller;
diff --git a/arch/powerpc/boot/dts/mpc866ads.dts b/arch/powerpc/boot/dts/mpc866ads.dts
index 2b56b5df451a..c0d06fd12927 100644
--- a/arch/powerpc/boot/dts/mpc866ads.dts
+++ b/arch/powerpc/boot/dts/mpc866ads.dts
@@ -18,7 +18,6 @@
18 linux,phandle = <100>; 18 linux,phandle = <100>;
19 19
20 cpus { 20 cpus {
21 #cpus = <1>;
22 #address-cells = <1>; 21 #address-cells = <1>;
23 #size-cells = <0>; 22 #size-cells = <0>;
24 linux,phandle = <200>; 23 linux,phandle = <200>;
diff --git a/arch/powerpc/boot/dts/mpc885ads.dts b/arch/powerpc/boot/dts/mpc885ads.dts
index faecd08c54da..110bf6170603 100644
--- a/arch/powerpc/boot/dts/mpc885ads.dts
+++ b/arch/powerpc/boot/dts/mpc885ads.dts
@@ -18,7 +18,6 @@
18 linux,phandle = <100>; 18 linux,phandle = <100>;
19 19
20 cpus { 20 cpus {
21 #cpus = <1>;
22 #address-cells = <1>; 21 #address-cells = <1>;
23 #size-cells = <0>; 22 #size-cells = <0>;
24 linux,phandle = <200>; 23 linux,phandle = <200>;
diff --git a/arch/powerpc/boot/elf.h b/arch/powerpc/boot/elf.h
index d4828fcf1cb9..1941bc50d4c5 100644
--- a/arch/powerpc/boot/elf.h
+++ b/arch/powerpc/boot/elf.h
@@ -146,4 +146,12 @@ typedef struct elf64_phdr {
146#define ELFOSABI_NONE 0 146#define ELFOSABI_NONE 0
147#define ELFOSABI_LINUX 3 147#define ELFOSABI_LINUX 3
148 148
149struct elf_info {
150 unsigned long loadsize;
151 unsigned long memsize;
152 unsigned long elfoffset;
153};
154int parse_elf64(void *hdr, struct elf_info *info);
155int parse_elf32(void *hdr, struct elf_info *info);
156
149#endif /* _PPC_BOOT_ELF_H_ */ 157#endif /* _PPC_BOOT_ELF_H_ */
diff --git a/arch/powerpc/boot/elf_util.c b/arch/powerpc/boot/elf_util.c
new file mode 100644
index 000000000000..7454aa4cc20c
--- /dev/null
+++ b/arch/powerpc/boot/elf_util.c
@@ -0,0 +1,76 @@
1/*
2 * Copyright (C) Paul Mackerras 1997.
3 *
4 * Updates for PPC64 by Todd Inglett, Dave Engebretsen & Peter Bergner.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#include <stdarg.h>
12#include <stddef.h>
13#include "elf.h"
14#include "page.h"
15#include "string.h"
16#include "stdio.h"
17
18int parse_elf64(void *hdr, struct elf_info *info)
19{
20 Elf64_Ehdr *elf64 = hdr;
21 Elf64_Phdr *elf64ph;
22 unsigned int i;
23
24 if (!(elf64->e_ident[EI_MAG0] == ELFMAG0 &&
25 elf64->e_ident[EI_MAG1] == ELFMAG1 &&
26 elf64->e_ident[EI_MAG2] == ELFMAG2 &&
27 elf64->e_ident[EI_MAG3] == ELFMAG3 &&
28 elf64->e_ident[EI_CLASS] == ELFCLASS64 &&
29 elf64->e_ident[EI_DATA] == ELFDATA2MSB &&
30 elf64->e_type == ET_EXEC &&
31 elf64->e_machine == EM_PPC64))
32 return 0;
33
34 elf64ph = (Elf64_Phdr *)((unsigned long)elf64 +
35 (unsigned long)elf64->e_phoff);
36 for (i = 0; i < (unsigned int)elf64->e_phnum; i++, elf64ph++)
37 if (elf64ph->p_type == PT_LOAD)
38 break;
39 if (i >= (unsigned int)elf64->e_phnum)
40 return 0;
41
42 info->loadsize = (unsigned long)elf64ph->p_filesz;
43 info->memsize = (unsigned long)elf64ph->p_memsz;
44 info->elfoffset = (unsigned long)elf64ph->p_offset;
45
46 return 1;
47}
48
49int parse_elf32(void *hdr, struct elf_info *info)
50{
51 Elf32_Ehdr *elf32 = hdr;
52 Elf32_Phdr *elf32ph;
53 unsigned int i;
54
55 if (!(elf32->e_ident[EI_MAG0] == ELFMAG0 &&
56 elf32->e_ident[EI_MAG1] == ELFMAG1 &&
57 elf32->e_ident[EI_MAG2] == ELFMAG2 &&
58 elf32->e_ident[EI_MAG3] == ELFMAG3 &&
59 elf32->e_ident[EI_CLASS] == ELFCLASS32 &&
60 elf32->e_ident[EI_DATA] == ELFDATA2MSB &&
61 elf32->e_type == ET_EXEC &&
62 elf32->e_machine == EM_PPC))
63 return 0;
64
65 elf32ph = (Elf32_Phdr *) ((unsigned long)elf32 + elf32->e_phoff);
66 for (i = 0; i < elf32->e_phnum; i++, elf32ph++)
67 if (elf32ph->p_type == PT_LOAD)
68 break;
69 if (i >= elf32->e_phnum)
70 return 0;
71
72 info->loadsize = elf32ph->p_filesz;
73 info->memsize = elf32ph->p_memsz;
74 info->elfoffset = elf32ph->p_offset;
75 return 1;
76}
diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index c76c194715b2..d00fbd92a458 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -29,12 +29,20 @@
29 29
30#define _ALIGN(x, al) (((x) + (al) - 1) & ~((al) - 1)) 30#define _ALIGN(x, al) (((x) + (al) - 1) & ~((al) - 1))
31 31
32static char *ft_root_node(struct ft_cxt *cxt)
33{
34 return cxt->rgn[FT_STRUCT].start;
35}
36
32/* Routines for keeping node ptrs returned by ft_find_device current */ 37/* Routines for keeping node ptrs returned by ft_find_device current */
33/* First entry not used b/c it would return 0 and be taken as NULL/error */ 38/* First entry not used b/c it would return 0 and be taken as NULL/error */
34static void *ft_node_add(struct ft_cxt *cxt, char *node) 39static void *ft_get_phandle(struct ft_cxt *cxt, char *node)
35{ 40{
36 unsigned int i; 41 unsigned int i;
37 42
43 if (!node)
44 return NULL;
45
38 for (i = 1; i < cxt->nodes_used; i++) /* already there? */ 46 for (i = 1; i < cxt->nodes_used; i++) /* already there? */
39 if (cxt->node_tbl[i] == node) 47 if (cxt->node_tbl[i] == node)
40 return (void *)i; 48 return (void *)i;
@@ -238,7 +246,7 @@ static int ft_shuffle(struct ft_cxt *cxt, char **pp, enum ft_rgn_id rgn,
238 if (rgn == FT_STRUCT) 246 if (rgn == FT_STRUCT)
239 ft_node_update_before(cxt, p, -nextra); 247 ft_node_update_before(cxt, p, -nextra);
240 } 248 }
241 *p -= nextra; 249 *pp -= nextra;
242 cxt->rgn[rgn].start -= nextra; 250 cxt->rgn[rgn].start -= nextra;
243 cxt->rgn[rgn].size += nextra; 251 cxt->rgn[rgn].size += nextra;
244 return 1; 252 return 1;
@@ -253,8 +261,14 @@ static int ft_make_space(struct ft_cxt *cxt, char **pp, enum ft_rgn_id rgn,
253 char *str, *next; 261 char *str, *next;
254 enum ft_rgn_id r; 262 enum ft_rgn_id r;
255 263
256 if (!cxt->isordered && !ft_reorder(cxt, nextra)) 264 if (!cxt->isordered) {
257 return 0; 265 unsigned long rgn_off = *pp - cxt->rgn[rgn].start;
266
267 if (!ft_reorder(cxt, nextra))
268 return 0;
269
270 *pp = cxt->rgn[rgn].start + rgn_off;
271 }
258 if (ft_shuffle(cxt, pp, rgn, nextra)) 272 if (ft_shuffle(cxt, pp, rgn, nextra))
259 return 1; 273 return 1;
260 274
@@ -415,7 +429,7 @@ int ft_prop(struct ft_cxt *cxt, const char *name, const void *data,
415{ 429{
416 int off, len; 430 int off, len;
417 431
418 off = lookup_string(cxt, name); 432 off = map_string(cxt, name);
419 if (off == NO_STRING) 433 if (off == NO_STRING)
420 return -1; 434 return -1;
421 435
@@ -590,7 +604,7 @@ int ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size)
590 604
591void ft_begin_tree(struct ft_cxt *cxt) 605void ft_begin_tree(struct ft_cxt *cxt)
592{ 606{
593 cxt->p = cxt->rgn[FT_STRUCT].start; 607 cxt->p = ft_root_node(cxt);
594} 608}
595 609
596void ft_end_tree(struct ft_cxt *cxt) 610void ft_end_tree(struct ft_cxt *cxt)
@@ -636,8 +650,21 @@ void *ft_find_device(struct ft_cxt *cxt, const char *srch_path)
636 /* require absolute path */ 650 /* require absolute path */
637 if (srch_path[0] != '/') 651 if (srch_path[0] != '/')
638 return NULL; 652 return NULL;
639 node = ft_find_descendent(cxt, cxt->rgn[FT_STRUCT].start, srch_path); 653 node = ft_find_descendent(cxt, ft_root_node(cxt), srch_path);
640 return ft_node_add(cxt, node); 654 return ft_get_phandle(cxt, node);
655}
656
657void *ft_find_device_rel(struct ft_cxt *cxt, const void *top,
658 const char *srch_path)
659{
660 char *node;
661
662 node = ft_node_ph2node(cxt, top);
663 if (node == NULL)
664 return NULL;
665
666 node = ft_find_descendent(cxt, node, srch_path);
667 return ft_get_phandle(cxt, node);
641} 668}
642 669
643void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path) 670void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path)
@@ -701,23 +728,18 @@ void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path)
701 return NULL; 728 return NULL;
702} 729}
703 730
704void *ft_get_parent(struct ft_cxt *cxt, const void *phandle) 731void *__ft_get_parent(struct ft_cxt *cxt, void *node)
705{ 732{
706 void *node;
707 int d; 733 int d;
708 struct ft_atom atom; 734 struct ft_atom atom;
709 char *p; 735 char *p;
710 736
711 node = ft_node_ph2node(cxt, phandle);
712 if (node == NULL)
713 return NULL;
714
715 for (d = 0; cxt->genealogy[d] != NULL; ++d) 737 for (d = 0; cxt->genealogy[d] != NULL; ++d)
716 if (cxt->genealogy[d] == node) 738 if (cxt->genealogy[d] == node)
717 return cxt->genealogy[d > 0 ? d - 1 : 0]; 739 return d > 0 ? cxt->genealogy[d - 1] : NULL;
718 740
719 /* have to do it the hard way... */ 741 /* have to do it the hard way... */
720 p = cxt->rgn[FT_STRUCT].start; 742 p = ft_root_node(cxt);
721 d = 0; 743 d = 0;
722 while ((p = ft_next(cxt, p, &atom)) != NULL) { 744 while ((p = ft_next(cxt, p, &atom)) != NULL) {
723 switch (atom.tag) { 745 switch (atom.tag) {
@@ -726,7 +748,7 @@ void *ft_get_parent(struct ft_cxt *cxt, const void *phandle)
726 if (node == atom.data) { 748 if (node == atom.data) {
727 /* found it */ 749 /* found it */
728 cxt->genealogy[d + 1] = NULL; 750 cxt->genealogy[d + 1] = NULL;
729 return d > 0 ? cxt->genealogy[d - 1] : node; 751 return d > 0 ? cxt->genealogy[d - 1] : NULL;
730 } 752 }
731 ++d; 753 ++d;
732 break; 754 break;
@@ -738,41 +760,131 @@ void *ft_get_parent(struct ft_cxt *cxt, const void *phandle)
738 return NULL; 760 return NULL;
739} 761}
740 762
741int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname, 763void *ft_get_parent(struct ft_cxt *cxt, const void *phandle)
742 void *buf, const unsigned int buflen)
743{ 764{
744 struct ft_atom atom; 765 void *node = ft_node_ph2node(cxt, phandle);
745 void *node;
746 char *p;
747 int depth;
748 unsigned int size;
749
750 node = ft_node_ph2node(cxt, phandle);
751 if (node == NULL) 766 if (node == NULL)
752 return -1; 767 return NULL;
753 768
754 depth = 0; 769 node = __ft_get_parent(cxt, node);
755 p = (char *)node; 770 return ft_get_phandle(cxt, node);
771}
756 772
757 while ((p = ft_next(cxt, p, &atom)) != NULL) { 773static const void *__ft_get_prop(struct ft_cxt *cxt, void *node,
774 const char *propname, unsigned int *len)
775{
776 struct ft_atom atom;
777 int depth = 0;
778
779 while ((node = ft_next(cxt, node, &atom)) != NULL) {
758 switch (atom.tag) { 780 switch (atom.tag) {
759 case OF_DT_BEGIN_NODE: 781 case OF_DT_BEGIN_NODE:
760 ++depth; 782 ++depth;
761 break; 783 break;
784
762 case OF_DT_PROP: 785 case OF_DT_PROP:
763 if ((depth != 1) || strcmp(atom.name, propname)) 786 if (depth != 1 || strcmp(atom.name, propname))
764 break; 787 break;
765 size = min(atom.size, buflen); 788
766 memcpy(buf, atom.data, size); 789 if (len)
767 return atom.size; 790 *len = atom.size;
791
792 return atom.data;
793
768 case OF_DT_END_NODE: 794 case OF_DT_END_NODE:
769 if (--depth <= 0) 795 if (--depth <= 0)
770 return -1; 796 return NULL;
771 } 797 }
772 } 798 }
799
800 return NULL;
801}
802
803int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
804 void *buf, const unsigned int buflen)
805{
806 const void *data;
807 unsigned int size;
808
809 void *node = ft_node_ph2node(cxt, phandle);
810 if (!node)
811 return -1;
812
813 data = __ft_get_prop(cxt, node, propname, &size);
814 if (data) {
815 unsigned int clipped_size = min(size, buflen);
816 memcpy(buf, data, clipped_size);
817 return size;
818 }
819
773 return -1; 820 return -1;
774} 821}
775 822
823void *__ft_find_node_by_prop_value(struct ft_cxt *cxt, void *prev,
824 const char *propname, const char *propval,
825 unsigned int proplen)
826{
827 struct ft_atom atom;
828 char *p = ft_root_node(cxt);
829 char *next;
830 int past_prev = prev ? 0 : 1;
831 int depth = -1;
832
833 while ((next = ft_next(cxt, p, &atom)) != NULL) {
834 const void *data;
835 unsigned int size;
836
837 switch (atom.tag) {
838 case OF_DT_BEGIN_NODE:
839 depth++;
840
841 if (prev == p) {
842 past_prev = 1;
843 break;
844 }
845
846 if (!past_prev || depth < 1)
847 break;
848
849 data = __ft_get_prop(cxt, p, propname, &size);
850 if (!data || size != proplen)
851 break;
852 if (memcmp(data, propval, size))
853 break;
854
855 return p;
856
857 case OF_DT_END_NODE:
858 if (depth-- == 0)
859 return NULL;
860
861 break;
862 }
863
864 p = next;
865 }
866
867 return NULL;
868}
869
870void *ft_find_node_by_prop_value(struct ft_cxt *cxt, const void *prev,
871 const char *propname, const char *propval,
872 int proplen)
873{
874 void *node = NULL;
875
876 if (prev) {
877 node = ft_node_ph2node(cxt, prev);
878
879 if (!node)
880 return NULL;
881 }
882
883 node = __ft_find_node_by_prop_value(cxt, node, propname,
884 propval, proplen);
885 return ft_get_phandle(cxt, node);
886}
887
776int ft_set_prop(struct ft_cxt *cxt, const void *phandle, const char *propname, 888int ft_set_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
777 const void *buf, const unsigned int buflen) 889 const void *buf, const unsigned int buflen)
778{ 890{
@@ -849,19 +961,26 @@ int ft_del_prop(struct ft_cxt *cxt, const void *phandle, const char *propname)
849 return -1; 961 return -1;
850} 962}
851 963
852void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *path) 964void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *name)
853{ 965{
854 struct ft_atom atom; 966 struct ft_atom atom;
855 char *p, *next; 967 char *p, *next;
856 int depth = 0; 968 int depth = 0;
857 969
858 p = cxt->rgn[FT_STRUCT].start; 970 if (parent) {
971 p = ft_node_ph2node(cxt, parent);
972 if (!p)
973 return NULL;
974 } else {
975 p = ft_root_node(cxt);
976 }
977
859 while ((next = ft_next(cxt, p, &atom)) != NULL) { 978 while ((next = ft_next(cxt, p, &atom)) != NULL) {
860 switch (atom.tag) { 979 switch (atom.tag) {
861 case OF_DT_BEGIN_NODE: 980 case OF_DT_BEGIN_NODE:
862 ++depth; 981 ++depth;
863 if (depth == 1 && strcmp(atom.name, path) == 0) 982 if (depth == 1 && strcmp(atom.name, name) == 0)
864 /* duplicate node path, return error */ 983 /* duplicate node name, return error */
865 return NULL; 984 return NULL;
866 break; 985 break;
867 case OF_DT_END_NODE: 986 case OF_DT_END_NODE:
@@ -870,7 +989,7 @@ void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *path)
870 break; 989 break;
871 /* end of node, insert here */ 990 /* end of node, insert here */
872 cxt->p = p; 991 cxt->p = p;
873 ft_begin_node(cxt, path); 992 ft_begin_node(cxt, name);
874 ft_end_node(cxt); 993 ft_end_node(cxt);
875 return p; 994 return p;
876 } 995 }
diff --git a/arch/powerpc/boot/flatdevtree.h b/arch/powerpc/boot/flatdevtree.h
index b9cd9f61f351..cb26325d72db 100644
--- a/arch/powerpc/boot/flatdevtree.h
+++ b/arch/powerpc/boot/flatdevtree.h
@@ -97,10 +97,17 @@ int ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size);
97void ft_dump_blob(const void *bphp); 97void ft_dump_blob(const void *bphp);
98void ft_merge_blob(struct ft_cxt *cxt, void *blob); 98void ft_merge_blob(struct ft_cxt *cxt, void *blob);
99void *ft_find_device(struct ft_cxt *cxt, const char *srch_path); 99void *ft_find_device(struct ft_cxt *cxt, const char *srch_path);
100void *ft_find_device_rel(struct ft_cxt *cxt, const void *top,
101 const char *srch_path);
100void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path); 102void *ft_find_descendent(struct ft_cxt *cxt, void *top, const char *srch_path);
101int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname, 103int ft_get_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
102 void *buf, const unsigned int buflen); 104 void *buf, const unsigned int buflen);
103int ft_set_prop(struct ft_cxt *cxt, const void *phandle, const char *propname, 105int ft_set_prop(struct ft_cxt *cxt, const void *phandle, const char *propname,
104 const void *buf, const unsigned int buflen); 106 const void *buf, const unsigned int buflen);
107void *ft_get_parent(struct ft_cxt *cxt, const void *phandle);
108void *ft_find_node_by_prop_value(struct ft_cxt *cxt, const void *prev,
109 const char *propname, const char *propval,
110 int proplen);
111void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *name);
105 112
106#endif /* FLATDEVTREE_H */ 113#endif /* FLATDEVTREE_H */
diff --git a/arch/powerpc/boot/flatdevtree_misc.c b/arch/powerpc/boot/flatdevtree_misc.c
index 04da38fa477f..4341e6558c1a 100644
--- a/arch/powerpc/boot/flatdevtree_misc.c
+++ b/arch/powerpc/boot/flatdevtree_misc.c
@@ -16,24 +16,43 @@
16 16
17static struct ft_cxt cxt; 17static struct ft_cxt cxt;
18 18
19static void *ft_finddevice(const char *name) 19static void *fdtm_finddevice(const char *name)
20{ 20{
21 return ft_find_device(&cxt, name); 21 return ft_find_device(&cxt, name);
22} 22}
23 23
24static int ft_getprop(const void *phandle, const char *propname, void *buf, 24static int fdtm_getprop(const void *phandle, const char *propname,
25 const int buflen) 25 void *buf, const int buflen)
26{ 26{
27 return ft_get_prop(&cxt, phandle, propname, buf, buflen); 27 return ft_get_prop(&cxt, phandle, propname, buf, buflen);
28} 28}
29 29
30static int ft_setprop(const void *phandle, const char *propname, 30static int fdtm_setprop(const void *phandle, const char *propname,
31 const void *buf, const int buflen) 31 const void *buf, const int buflen)
32{ 32{
33 return ft_set_prop(&cxt, phandle, propname, buf, buflen); 33 return ft_set_prop(&cxt, phandle, propname, buf, buflen);
34} 34}
35 35
36static unsigned long ft_finalize(void) 36static void *fdtm_get_parent(const void *phandle)
37{
38 return ft_get_parent(&cxt, phandle);
39}
40
41static void *fdtm_create_node(const void *phandle, const char *name)
42{
43 return ft_create_node(&cxt, phandle, name);
44}
45
46static void *fdtm_find_node_by_prop_value(const void *prev,
47 const char *propname,
48 const char *propval,
49 int proplen)
50{
51 return ft_find_node_by_prop_value(&cxt, prev, propname,
52 propval, proplen);
53}
54
55static unsigned long fdtm_finalize(void)
37{ 56{
38 ft_end_tree(&cxt); 57 ft_end_tree(&cxt);
39 return (unsigned long)cxt.bph; 58 return (unsigned long)cxt.bph;
@@ -41,10 +60,13 @@ static unsigned long ft_finalize(void)
41 60
42int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device) 61int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device)
43{ 62{
44 dt_ops.finddevice = ft_finddevice; 63 dt_ops.finddevice = fdtm_finddevice;
45 dt_ops.getprop = ft_getprop; 64 dt_ops.getprop = fdtm_getprop;
46 dt_ops.setprop = ft_setprop; 65 dt_ops.setprop = fdtm_setprop;
47 dt_ops.finalize = ft_finalize; 66 dt_ops.get_parent = fdtm_get_parent;
67 dt_ops.create_node = fdtm_create_node;
68 dt_ops.find_node_by_prop_value = fdtm_find_node_by_prop_value;
69 dt_ops.finalize = fdtm_finalize;
48 70
49 return ft_open(&cxt, dt_blob, max_size, max_find_device, 71 return ft_open(&cxt, dt_blob, max_size, max_find_device,
50 platform_ops.realloc); 72 platform_ops.realloc);
diff --git a/arch/powerpc/boot/gunzip_util.c b/arch/powerpc/boot/gunzip_util.c
new file mode 100644
index 000000000000..df8ab07e9ff4
--- /dev/null
+++ b/arch/powerpc/boot/gunzip_util.c
@@ -0,0 +1,206 @@
1/*
2 * Copyright 2007 David Gibson, IBM Corporation.
3 * Based on earlier work, Copyright (C) Paul Mackerras 1997.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
10
11#include <stddef.h>
12#include "string.h"
13#include "stdio.h"
14#include "ops.h"
15#include "gunzip_util.h"
16
17#define HEAD_CRC 2
18#define EXTRA_FIELD 4
19#define ORIG_NAME 8
20#define COMMENT 0x10
21#define RESERVED 0xe0
22
23/**
24 * gunzip_start - prepare to decompress gzip data
25 * @state: decompressor state structure to be initialized
26 * @src: buffer containing gzip compressed or uncompressed data
27 * @srclen: size in bytes of the buffer at src
28 *
29 * If the buffer at @src contains a gzip header, this function
30 * initializes zlib to decompress the data, storing the decompression
31 * state in @state. The other functions in this file can then be used
32 * to decompress data from the gzipped stream.
33 *
34 * If the buffer at @src does not contain a gzip header, it is assumed
35 * to contain uncompressed data. The buffer information is recorded
36 * in @state and the other functions in this file will simply copy
37 * data from the uncompressed data stream at @src.
38 *
39 * Any errors, such as bad compressed data, cause an error to be
40 * printed an the platform's exit() function to be called.
41 */
42void gunzip_start(struct gunzip_state *state, void *src, int srclen)
43{
44 char *hdr = src;
45 int hdrlen = 0;
46
47 memset(state, 0, sizeof(*state));
48
49 /* Check for gzip magic number */
50 if ((hdr[0] == 0x1f) && (hdr[1] == 0x8b)) {
51 /* gzip data, initialize zlib parameters */
52 int r, flags;
53
54 state->s.workspace = state->scratch;
55 if (zlib_inflate_workspacesize() > sizeof(state->scratch))
56 fatal("insufficient scratch space for gunzip\n\r");
57
58 /* skip header */
59 hdrlen = 10;
60 flags = hdr[3];
61 if (hdr[2] != Z_DEFLATED || (flags & RESERVED) != 0)
62 fatal("bad gzipped data\n\r");
63 if ((flags & EXTRA_FIELD) != 0)
64 hdrlen = 12 + hdr[10] + (hdr[11] << 8);
65 if ((flags & ORIG_NAME) != 0)
66 while (hdr[hdrlen++] != 0)
67 ;
68 if ((flags & COMMENT) != 0)
69 while (hdr[hdrlen++] != 0)
70 ;
71 if ((flags & HEAD_CRC) != 0)
72 hdrlen += 2;
73 if (hdrlen >= srclen)
74 fatal("gunzip_start: ran out of data in header\n\r");
75
76 r = zlib_inflateInit2(&state->s, -MAX_WBITS);
77 if (r != Z_OK)
78 fatal("inflateInit2 returned %d\n\r", r);
79 }
80
81 state->s.next_in = src + hdrlen;
82 state->s.avail_in = srclen - hdrlen;
83}
84
85/**
86 * gunzip_partial - extract bytes from a gzip data stream
87 * @state: gzip state structure previously initialized by gunzip_start()
88 * @dst: buffer to store extracted data
89 * @dstlen: maximum number of bytes to extract
90 *
91 * This function extracts at most @dstlen bytes from the data stream
92 * previously associated with @state by gunzip_start(), decompressing
93 * if necessary. Exactly @dstlen bytes are extracted unless the data
94 * stream doesn't contain enough bytes, in which case the entire
95 * remainder of the stream is decompressed.
96 *
97 * Returns the actual number of bytes extracted. If any errors occur,
98 * such as a corrupted compressed stream, an error is printed an the
99 * platform's exit() function is called.
100 */
101int gunzip_partial(struct gunzip_state *state, void *dst, int dstlen)
102{
103 int len;
104
105 if (state->s.workspace) {
106 /* gunzipping */
107 int r;
108
109 state->s.next_out = dst;
110 state->s.avail_out = dstlen;
111 r = zlib_inflate(&state->s, Z_FULL_FLUSH);
112 if (r != Z_OK && r != Z_STREAM_END)
113 fatal("inflate returned %d msg: %s\n\r", r, state->s.msg);
114 len = state->s.next_out - (unsigned char *)dst;
115 } else {
116 /* uncompressed image */
117 len = min(state->s.avail_in, (unsigned)dstlen);
118 memcpy(dst, state->s.next_in, len);
119 state->s.next_in += len;
120 state->s.avail_in -= len;
121 }
122 return len;
123}
124
125/**
126 * gunzip_exactly - extract a fixed number of bytes from a gzip data stream
127 * @state: gzip state structure previously initialized by gunzip_start()
128 * @dst: buffer to store extracted data
129 * @dstlen: number of bytes to extract
130 *
131 * This function extracts exactly @dstlen bytes from the data stream
132 * previously associated with @state by gunzip_start(), decompressing
133 * if necessary.
134 *
135 * If there are less @dstlen bytes available in the data stream, or if
136 * any other errors occur, such as a corrupted compressed stream, an
137 * error is printed an the platform's exit() function is called.
138 */
139void gunzip_exactly(struct gunzip_state *state, void *dst, int dstlen)
140{
141 int len;
142
143 len = gunzip_partial(state, dst, dstlen);
144 if (len < dstlen)
145 fatal("\n\rgunzip_exactly: ran out of data!"
146 " Wanted %d, got %d.\n\r", dstlen, len);
147}
148
149/**
150 * gunzip_discard - discard bytes from a gzip data stream
151 * @state: gzip state structure previously initialized by gunzip_start()
152 * @len: number of bytes to discard
153 *
154 * This function extracts, then discards exactly @len bytes from the
155 * data stream previously associated with @state by gunzip_start().
156 * Subsequent gunzip_partial(), gunzip_exactly() or gunzip_finish()
157 * calls will extract the data following the discarded bytes in the
158 * data stream.
159 *
160 * If there are less @len bytes available in the data stream, or if
161 * any other errors occur, such as a corrupted compressed stream, an
162 * error is printed an the platform's exit() function is called.
163 */
164void gunzip_discard(struct gunzip_state *state, int len)
165{
166 static char discard_buf[128];
167
168 while (len > sizeof(discard_buf)) {
169 gunzip_exactly(state, discard_buf, sizeof(discard_buf));
170 len -= sizeof(discard_buf);
171 }
172
173 if (len > 0)
174 gunzip_exactly(state, discard_buf, len);
175}
176
177/**
178 * gunzip_finish - extract all remaining bytes from a gzip data stream
179 * @state: gzip state structure previously initialized by gunzip_start()
180 * @dst: buffer to store extracted data
181 * @dstlen: maximum number of bytes to extract
182 *
183 * This function extracts all remaining data, or at most @dstlen
184 * bytes, from the stream previously associated with @state by
185 * gunzip_start(). zlib is then shut down, so it is an error to use
186 * any of the functions in this file on @state until it is
187 * re-initialized with another call to gunzip_start().
188 *
189 * If any errors occur, such as a corrupted compressed stream, an
190 * error is printed an the platform's exit() function is called.
191 */
192int gunzip_finish(struct gunzip_state *state, void *dst, int dstlen)
193{
194 int len;
195
196 if (state->s.workspace) {
197 len = gunzip_partial(state, dst, dstlen);
198 zlib_inflateEnd(&state->s);
199 } else {
200 /* uncompressed image */
201 len = min(state->s.avail_in, (unsigned)dstlen);
202 memcpy(dst, state->s.next_in, len);
203 }
204
205 return len;
206}
diff --git a/arch/powerpc/boot/gunzip_util.h b/arch/powerpc/boot/gunzip_util.h
new file mode 100644
index 000000000000..b3dfa6e87b3a
--- /dev/null
+++ b/arch/powerpc/boot/gunzip_util.h
@@ -0,0 +1,45 @@
1/*
2 * Decompression convenience functions
3 *
4 * Copyright 2007 David Gibson, IBM Corporation.
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10#ifndef _PPC_BOOT_GUNZIP_UTIL_H_
11#define _PPC_BOOT_GUNZIP_UTIL_H_
12
13#include "zlib.h"
14
15/*
16 * These functions are designed to make life easy for decompressing
17 * kernel images, initrd images or any other gzip compressed image,
18 * particularly if its useful to decompress part of the image (e.g. to
19 * examine headers) before decompressing the remainder.
20 *
21 * To use:
22 * - declare a gunzip_state structure
23 * - use gunzip_start() to initialize the state, associating it
24 * with a stream of compressed data
25 * - use gunzip_partial(), gunzip_exactly() and gunzip_discard()
26 * in any combination to extract pieces of data from the stream
27 * - Finally use gunzip_finish() to extract the tail of the
28 * compressed stream and wind up zlib
29 */
30
31/* scratch space for gunzip; 46912 is from zlib_inflate_workspacesize() */
32#define GUNZIP_SCRATCH_SIZE 46912
33
34struct gunzip_state {
35 z_stream s;
36 char scratch[46912];
37};
38
39void gunzip_start(struct gunzip_state *state, void *src, int srclen);
40int gunzip_partial(struct gunzip_state *state, void *dst, int dstlen);
41void gunzip_exactly(struct gunzip_state *state, void *dst, int len);
42void gunzip_discard(struct gunzip_state *state, int len);
43int gunzip_finish(struct gunzip_state *state, void *dst, int len);
44
45#endif /* _PPC_BOOT_GUNZIP_UTIL_H_ */
diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index 6f6b50d238b6..56b56a8d4b23 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -14,11 +14,10 @@
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 "zlib.h"
18#include "ops.h" 17#include "ops.h"
18#include "gunzip_util.h"
19#include "flatdevtree.h" 19#include "flatdevtree.h"
20 20#include "reg.h"
21extern void flush_cache(void *, unsigned long);
22 21
23extern char _start[]; 22extern char _start[];
24extern char __bss_start[]; 23extern char __bss_start[];
@@ -30,304 +29,173 @@ extern char _initrd_end[];
30extern char _dtb_start[]; 29extern char _dtb_start[];
31extern char _dtb_end[]; 30extern char _dtb_end[];
32 31
32static struct gunzip_state gzstate;
33
33struct addr_range { 34struct addr_range {
34 unsigned long addr; 35 void *addr;
35 unsigned long size; 36 unsigned long size;
36 unsigned long memsize;
37}; 37};
38static struct addr_range vmlinux;
39static struct addr_range vmlinuz;
40static struct addr_range initrd;
41
42static unsigned long elfoffset;
43static int is_64bit;
44
45/* scratch space for gunzip; 46912 is from zlib_inflate_workspacesize() */
46static char scratch[46912];
47static char elfheader[256];
48 38
49typedef void (*kernel_entry_t)(unsigned long, unsigned long, void *); 39typedef void (*kernel_entry_t)(unsigned long, unsigned long, void *);
50 40
51#undef DEBUG 41#undef DEBUG
52 42
53#define HEAD_CRC 2 43static struct addr_range prep_kernel(void)
54#define EXTRA_FIELD 4
55#define ORIG_NAME 8
56#define COMMENT 0x10
57#define RESERVED 0xe0
58
59static void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp)
60{ 44{
61 z_stream s; 45 char elfheader[256];
62 int r, i, flags; 46 void *vmlinuz_addr = _vmlinux_start;
63 47 unsigned long vmlinuz_size = _vmlinux_end - _vmlinux_start;
64 /* skip header */ 48 void *addr = 0;
65 i = 10; 49 struct elf_info ei;
66 flags = src[3]; 50 int len;
67 if (src[2] != Z_DEFLATED || (flags & RESERVED) != 0) {
68 printf("bad gzipped data\n\r");
69 exit();
70 }
71 if ((flags & EXTRA_FIELD) != 0)
72 i = 12 + src[10] + (src[11] << 8);
73 if ((flags & ORIG_NAME) != 0)
74 while (src[i++] != 0)
75 ;
76 if ((flags & COMMENT) != 0)
77 while (src[i++] != 0)
78 ;
79 if ((flags & HEAD_CRC) != 0)
80 i += 2;
81 if (i >= *lenp) {
82 printf("gunzip: ran out of data in header\n\r");
83 exit();
84 }
85 51
86 if (zlib_inflate_workspacesize() > sizeof(scratch)) { 52 /* gunzip the ELF header of the kernel */
87 printf("gunzip needs more mem\n"); 53 gunzip_start(&gzstate, vmlinuz_addr, vmlinuz_size);
88 exit(); 54 gunzip_exactly(&gzstate, elfheader, sizeof(elfheader));
89 } 55
90 memset(&s, 0, sizeof(s)); 56 if (!parse_elf64(elfheader, &ei) && !parse_elf32(elfheader, &ei))
91 s.workspace = scratch; 57 fatal("Error: not a valid PPC32 or PPC64 ELF file!\n\r");
92 r = zlib_inflateInit2(&s, -MAX_WBITS); 58
93 if (r != Z_OK) { 59 if (platform_ops.image_hdr)
94 printf("inflateInit2 returned %d\n\r", r); 60 platform_ops.image_hdr(elfheader);
95 exit(); 61
96 } 62 /* We need to alloc the memsize: gzip will expand the kernel
97 s.next_in = src + i; 63 * text/data, then possible rubbish we don't care about. But
98 s.avail_in = *lenp - i; 64 * the kernel bss must be claimed (it will be zero'd by the
99 s.next_out = dst; 65 * kernel itself)
100 s.avail_out = dstlen; 66 */
101 r = zlib_inflate(&s, Z_FULL_FLUSH); 67 printf("Allocating 0x%lx bytes for kernel ...\n\r", ei.memsize);
102 if (r != Z_OK && r != Z_STREAM_END) { 68
103 printf("inflate returned %d msg: %s\n\r", r, s.msg); 69 if (platform_ops.vmlinux_alloc) {
104 exit(); 70 addr = platform_ops.vmlinux_alloc(ei.memsize);
71 } else {
72 if ((unsigned long)_start < ei.memsize)
73 fatal("Insufficient memory for kernel at address 0!"
74 " (_start=%p)\n\r", _start);
105 } 75 }
106 *lenp = s.next_out - (unsigned char *) dst;
107 zlib_inflateEnd(&s);
108}
109 76
110static int is_elf64(void *hdr) 77 /* Finally, gunzip the kernel */
111{ 78 printf("gunzipping (0x%p <- 0x%p:0x%p)...", addr,
112 Elf64_Ehdr *elf64 = hdr; 79 vmlinuz_addr, vmlinuz_addr+vmlinuz_size);
113 Elf64_Phdr *elf64ph; 80 /* discard up to the actual load data */
114 unsigned int i; 81 gunzip_discard(&gzstate, ei.elfoffset - sizeof(elfheader));
115 82 len = gunzip_finish(&gzstate, addr, ei.loadsize);
116 if (!(elf64->e_ident[EI_MAG0] == ELFMAG0 && 83 if (len != ei.loadsize)
117 elf64->e_ident[EI_MAG1] == ELFMAG1 && 84 fatal("ran out of data! only got 0x%x of 0x%lx bytes.\n\r",
118 elf64->e_ident[EI_MAG2] == ELFMAG2 && 85 len, ei.loadsize);
119 elf64->e_ident[EI_MAG3] == ELFMAG3 && 86 printf("done 0x%x bytes\n\r", len);
120 elf64->e_ident[EI_CLASS] == ELFCLASS64 &&
121 elf64->e_ident[EI_DATA] == ELFDATA2MSB &&
122 elf64->e_type == ET_EXEC &&
123 elf64->e_machine == EM_PPC64))
124 return 0;
125
126 elf64ph = (Elf64_Phdr *)((unsigned long)elf64 +
127 (unsigned long)elf64->e_phoff);
128 for (i = 0; i < (unsigned int)elf64->e_phnum; i++, elf64ph++)
129 if (elf64ph->p_type == PT_LOAD)
130 break;
131 if (i >= (unsigned int)elf64->e_phnum)
132 return 0;
133
134 elfoffset = (unsigned long)elf64ph->p_offset;
135 vmlinux.size = (unsigned long)elf64ph->p_filesz + elfoffset;
136 vmlinux.memsize = (unsigned long)elf64ph->p_memsz + elfoffset;
137
138 is_64bit = 1;
139 return 1;
140}
141 87
142static int is_elf32(void *hdr) 88 flush_cache(addr, ei.loadsize);
143{ 89
144 Elf32_Ehdr *elf32 = hdr; 90 return (struct addr_range){addr, ei.memsize};
145 Elf32_Phdr *elf32ph;
146 unsigned int i;
147
148 if (!(elf32->e_ident[EI_MAG0] == ELFMAG0 &&
149 elf32->e_ident[EI_MAG1] == ELFMAG1 &&
150 elf32->e_ident[EI_MAG2] == ELFMAG2 &&
151 elf32->e_ident[EI_MAG3] == ELFMAG3 &&
152 elf32->e_ident[EI_CLASS] == ELFCLASS32 &&
153 elf32->e_ident[EI_DATA] == ELFDATA2MSB &&
154 elf32->e_type == ET_EXEC &&
155 elf32->e_machine == EM_PPC))
156 return 0;
157
158 elf32 = (Elf32_Ehdr *)elfheader;
159 elf32ph = (Elf32_Phdr *) ((unsigned long)elf32 + elf32->e_phoff);
160 for (i = 0; i < elf32->e_phnum; i++, elf32ph++)
161 if (elf32ph->p_type == PT_LOAD)
162 break;
163 if (i >= elf32->e_phnum)
164 return 0;
165
166 elfoffset = elf32ph->p_offset;
167 vmlinux.size = elf32ph->p_filesz + elf32ph->p_offset;
168 vmlinux.memsize = elf32ph->p_memsz + elf32ph->p_offset;
169 return 1;
170} 91}
171 92
172static void prep_kernel(unsigned long a1, unsigned long a2) 93static struct addr_range prep_initrd(struct addr_range vmlinux, void *chosen,
94 unsigned long initrd_addr,
95 unsigned long initrd_size)
173{ 96{
174 int len; 97 /* If we have an image attached to us, it overrides anything
175 98 * supplied by the loader. */
176 vmlinuz.addr = (unsigned long)_vmlinux_start; 99 if (_initrd_end > _initrd_start) {
177 vmlinuz.size = (unsigned long)(_vmlinux_end - _vmlinux_start); 100 printf("Attached initrd image at 0x%p-0x%p\n\r",
178 101 _initrd_start, _initrd_end);
179 /* gunzip the ELF header of the kernel */ 102 initrd_addr = (unsigned long)_initrd_start;
180 if (*(unsigned short *)vmlinuz.addr == 0x1f8b) { 103 initrd_size = _initrd_end - _initrd_start;
181 len = vmlinuz.size; 104 } else if (initrd_size > 0) {
182 gunzip(elfheader, sizeof(elfheader), 105 printf("Using loader supplied ramdisk at 0x%lx-0x%lx\n\r",
183 (unsigned char *)vmlinuz.addr, &len); 106 initrd_addr, initrd_addr + initrd_size);
184 } else
185 memcpy(elfheader, (const void *)vmlinuz.addr,
186 sizeof(elfheader));
187
188 if (!is_elf64(elfheader) && !is_elf32(elfheader)) {
189 printf("Error: not a valid PPC32 or PPC64 ELF file!\n\r");
190 exit();
191 } 107 }
192 if (platform_ops.image_hdr)
193 platform_ops.image_hdr(elfheader);
194 108
195 /* We need to alloc the memsize plus the file offset since gzip 109 /* If there's no initrd at all, we're done */
196 * will expand the header (file offset), then the kernel, then 110 if (! initrd_size)
197 * possible rubbish we don't care about. But the kernel bss must 111 return (struct addr_range){0, 0};
198 * be claimed (it will be zero'd by the kernel itself)
199 */
200 printf("Allocating 0x%lx bytes for kernel ...\n\r", vmlinux.memsize);
201 vmlinux.addr = (unsigned long)malloc(vmlinux.memsize);
202 if (vmlinux.addr == 0) {
203 printf("Can't allocate memory for kernel image !\n\r");
204 exit();
205 }
206 112
207 /* 113 /*
208 * Now find the initrd 114 * If the initrd is too low it will be clobbered when the
209 * 115 * kernel relocates to its final location. In this case,
210 * First see if we have an image attached to us. If so 116 * allocate a safer place and move it.
211 * allocate memory for it and copy it there.
212 */ 117 */
213 initrd.size = (unsigned long)(_initrd_end - _initrd_start); 118 if (initrd_addr < vmlinux.size) {
214 initrd.memsize = initrd.size; 119 void *old_addr = (void *)initrd_addr;
215 if (initrd.size > 0) { 120
216 printf("Allocating 0x%lx bytes for initrd ...\n\r", 121 printf("Allocating 0x%lx bytes for initrd ...\n\r",
217 initrd.size); 122 initrd_size);
218 initrd.addr = (unsigned long)malloc((u32)initrd.size); 123 initrd_addr = (unsigned long)malloc(initrd_size);
219 if (initrd.addr == 0) { 124 if (! initrd_addr)
220 printf("Can't allocate memory for initial " 125 fatal("Can't allocate memory for initial "
221 "ramdisk !\n\r"); 126 "ramdisk !\n\r");
222 exit(); 127 printf("Relocating initrd 0x%lx <- 0x%p (0x%lx bytes)\n\r",
223 } 128 initrd_addr, old_addr, initrd_size);
224 printf("initial ramdisk moving 0x%lx <- 0x%lx " 129 memmove((void *)initrd_addr, old_addr, initrd_size);
225 "(0x%lx bytes)\n\r", initrd.addr,
226 (unsigned long)_initrd_start, initrd.size);
227 memmove((void *)initrd.addr, (void *)_initrd_start,
228 initrd.size);
229 printf("initrd head: 0x%lx\n\r",
230 *((unsigned long *)initrd.addr));
231 } else if (a2 != 0) {
232 /* Otherwise, see if yaboot or another loader gave us an initrd */
233 initrd.addr = a1;
234 initrd.memsize = initrd.size = a2;
235 printf("Using loader supplied initrd at 0x%lx (0x%lx bytes)\n\r",
236 initrd.addr, initrd.size);
237 } 130 }
238 131
239 /* Eventually gunzip the kernel */ 132 printf("initrd head: 0x%lx\n\r", *((unsigned long *)initrd_addr));
240 if (*(unsigned short *)vmlinuz.addr == 0x1f8b) {
241 printf("gunzipping (0x%lx <- 0x%lx:0x%0lx)...",
242 vmlinux.addr, vmlinuz.addr, vmlinuz.addr+vmlinuz.size);
243 len = vmlinuz.size;
244 gunzip((void *)vmlinux.addr, vmlinux.memsize,
245 (unsigned char *)vmlinuz.addr, &len);
246 printf("done 0x%lx bytes\n\r", len);
247 } else {
248 memmove((void *)vmlinux.addr,(void *)vmlinuz.addr,
249 vmlinuz.size);
250 }
251 133
252 /* Skip over the ELF header */ 134 /* Tell the kernel initrd address via device tree */
253#ifdef DEBUG 135 setprop_val(chosen, "linux,initrd-start", (u32)(initrd_addr));
254 printf("... skipping 0x%lx bytes of ELF header\n\r", 136 setprop_val(chosen, "linux,initrd-end", (u32)(initrd_addr+initrd_size));
255 elfoffset);
256#endif
257 vmlinux.addr += elfoffset;
258 137
259 flush_cache((void *)vmlinux.addr, vmlinux.size); 138 return (struct addr_range){(void *)initrd_addr, initrd_size};
260} 139}
261 140
262/* A buffer that may be edited by tools operating on a zImage binary so as to 141/* A buffer that may be edited by tools operating on a zImage binary so as to
263 * edit the command line passed to vmlinux (by setting /chosen/bootargs). 142 * edit the command line passed to vmlinux (by setting /chosen/bootargs).
264 * The buffer is put in it's own section so that tools may locate it easier. 143 * The buffer is put in it's own section so that tools may locate it easier.
265 */ 144 */
266static char builtin_cmdline[COMMAND_LINE_SIZE] 145static char cmdline[COMMAND_LINE_SIZE]
267 __attribute__((__section__("__builtin_cmdline"))); 146 __attribute__((__section__("__builtin_cmdline")));
268 147
269static void get_cmdline(char *buf, int size) 148static void prep_cmdline(void *chosen)
270{ 149{
271 void *devp; 150 if (cmdline[0] == '\0')
272 int len = strlen(builtin_cmdline); 151 getprop(chosen, "bootargs", cmdline, COMMAND_LINE_SIZE-1);
273
274 buf[0] = '\0';
275
276 if (len > 0) { /* builtin_cmdline overrides dt's /chosen/bootargs */
277 len = min(len, size-1);
278 strncpy(buf, builtin_cmdline, len);
279 buf[len] = '\0';
280 }
281 else if ((devp = finddevice("/chosen")))
282 getprop(devp, "bootargs", buf, size);
283}
284 152
285static void set_cmdline(char *buf) 153 printf("\n\rLinux/PowerPC load: %s", cmdline);
286{ 154 /* If possible, edit the command line */
287 void *devp; 155 if (console_ops.edit_cmdline)
156 console_ops.edit_cmdline(cmdline, COMMAND_LINE_SIZE);
157 printf("\n\r");
288 158
289 if ((devp = finddevice("/chosen"))) 159 /* Put the command line back into the devtree for the kernel */
290 setprop(devp, "bootargs", buf, strlen(buf) + 1); 160 setprop_str(chosen, "bootargs", cmdline);
291} 161}
292 162
293struct platform_ops platform_ops; 163struct platform_ops platform_ops;
294struct dt_ops dt_ops; 164struct dt_ops dt_ops;
295struct console_ops console_ops; 165struct console_ops console_ops;
166struct loader_info loader_info;
296 167
297void start(unsigned long a1, unsigned long a2, void *promptr, void *sp) 168void start(void)
298{ 169{
170 struct addr_range vmlinux, initrd;
299 kernel_entry_t kentry; 171 kernel_entry_t kentry;
300 char cmdline[COMMAND_LINE_SIZE];
301 unsigned long ft_addr = 0; 172 unsigned long ft_addr = 0;
173 void *chosen;
302 174
303 memset(__bss_start, 0, _end - __bss_start); 175 /* Do this first, because malloc() could clobber the loader's
304 memset(&platform_ops, 0, sizeof(platform_ops)); 176 * command line. Only use the loader command line if a
305 memset(&dt_ops, 0, sizeof(dt_ops)); 177 * built-in command line wasn't set by an external tool */
306 memset(&console_ops, 0, sizeof(console_ops)); 178 if ((loader_info.cmdline_len > 0) && (cmdline[0] == '\0'))
179 memmove(cmdline, loader_info.cmdline,
180 min(loader_info.cmdline_len, COMMAND_LINE_SIZE-1));
307 181
308 if (platform_init(promptr, _dtb_start, _dtb_end))
309 exit();
310 if (console_ops.open && (console_ops.open() < 0)) 182 if (console_ops.open && (console_ops.open() < 0))
311 exit(); 183 exit();
312 if (platform_ops.fixups) 184 if (platform_ops.fixups)
313 platform_ops.fixups(); 185 platform_ops.fixups();
314 186
315 printf("\n\rzImage starting: loaded at 0x%p (sp: 0x%p)\n\r", 187 printf("\n\rzImage starting: loaded at 0x%p (sp: 0x%p)\n\r",
316 _start, sp); 188 _start, get_sp());
317 189
318 prep_kernel(a1, a2); 190 /* Ensure that the device tree has a /chosen node */
191 chosen = finddevice("/chosen");
192 if (!chosen)
193 chosen = create_node(NULL, "chosen");
319 194
320 /* If cmdline came from zimage wrapper or if we can edit the one 195 vmlinux = prep_kernel();
321 * in the dt, print it out and edit it, if possible. 196 initrd = prep_initrd(vmlinux, chosen,
322 */ 197 loader_info.initrd_addr, loader_info.initrd_size);
323 if ((strlen(builtin_cmdline) > 0) || console_ops.edit_cmdline) { 198 prep_cmdline(chosen);
324 get_cmdline(cmdline, COMMAND_LINE_SIZE);
325 printf("\n\rLinux/PowerPC load: %s", cmdline);
326 if (console_ops.edit_cmdline)
327 console_ops.edit_cmdline(cmdline, COMMAND_LINE_SIZE);
328 printf("\n\r");
329 set_cmdline(cmdline);
330 }
331 199
332 printf("Finalizing device tree..."); 200 printf("Finalizing device tree...");
333 if (dt_ops.finalize) 201 if (dt_ops.finalize)
@@ -335,7 +203,7 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
335 if (ft_addr) 203 if (ft_addr)
336 printf(" flat tree at 0x%lx\n\r", ft_addr); 204 printf(" flat tree at 0x%lx\n\r", ft_addr);
337 else 205 else
338 printf(" using OF tree (promptr=%p)\n\r", promptr); 206 printf(" using OF tree (promptr=%p)\n\r", loader_info.promptr);
339 207
340 if (console_ops.close) 208 if (console_ops.close)
341 console_ops.close(); 209 console_ops.close();
@@ -344,10 +212,9 @@ void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
344 if (ft_addr) 212 if (ft_addr)
345 kentry(ft_addr, 0, NULL); 213 kentry(ft_addr, 0, NULL);
346 else 214 else
347 /* XXX initrd addr/size should be passed in properties */ 215 kentry((unsigned long)initrd.addr, initrd.size,
348 kentry(initrd.addr, initrd.size, promptr); 216 loader_info.promptr);
349 217
350 /* console closed so printf below may not work */ 218 /* console closed so printf in fatal below may not work */
351 printf("Error: Linux kernel returned to zImage boot wrapper!\n\r"); 219 fatal("Error: Linux kernel returned to zImage boot wrapper!\n\r");
352 exit();
353} 220}
diff --git a/arch/powerpc/boot/ns16550.c b/arch/powerpc/boot/ns16550.c
index 1ffe72e35cdc..f8f1b2f31412 100644
--- a/arch/powerpc/boot/ns16550.c
+++ b/arch/powerpc/boot/ns16550.c
@@ -55,10 +55,15 @@ static u8 ns16550_tstc(void)
55int ns16550_console_init(void *devp, struct serial_console_data *scdp) 55int ns16550_console_init(void *devp, struct serial_console_data *scdp)
56{ 56{
57 int n; 57 int n;
58 unsigned long reg_phys;
58 59
59 n = getprop(devp, "virtual-reg", &reg_base, sizeof(reg_base)); 60 n = getprop(devp, "virtual-reg", &reg_base, sizeof(reg_base));
60 if (n != sizeof(reg_base)) 61 if (n != sizeof(reg_base)) {
61 return -1; 62 if (!dt_xlate_reg(devp, 0, &reg_phys, NULL))
63 return -1;
64
65 reg_base = (void *)reg_phys;
66 }
62 67
63 n = getprop(devp, "reg-shift", &reg_shift, sizeof(reg_shift)); 68 n = getprop(devp, "reg-shift", &reg_shift, sizeof(reg_shift));
64 if (n != sizeof(reg_shift)) 69 if (n != sizeof(reg_shift))
diff --git a/arch/powerpc/boot/of.c b/arch/powerpc/boot/of.c
index 0182f384f3e6..d16ee3e3f868 100644
--- a/arch/powerpc/boot/of.c
+++ b/arch/powerpc/boot/of.c
@@ -173,7 +173,7 @@ static void *claim(unsigned long virt, unsigned long size, unsigned long align)
173 return (void *) virt; 173 return (void *) virt;
174} 174}
175 175
176static void *of_try_claim(u32 size) 176static void *of_try_claim(unsigned long size)
177{ 177{
178 unsigned long addr = 0; 178 unsigned long addr = 0;
179 179
@@ -208,6 +208,16 @@ static void of_image_hdr(const void *hdr)
208 } 208 }
209} 209}
210 210
211static void *of_vmlinux_alloc(unsigned long size)
212{
213 void *p = malloc(size);
214
215 if (!p)
216 fatal("Can't allocate memory for kernel image!\n\r");
217
218 return p;
219}
220
211static void of_exit(void) 221static void of_exit(void)
212{ 222{
213 call_prom("exit", 0, 0); 223 call_prom("exit", 0, 0);
@@ -256,11 +266,12 @@ static void of_console_write(char *buf, int len)
256 call_prom("write", 3, 1, of_stdout_handle, buf, len); 266 call_prom("write", 3, 1, of_stdout_handle, buf, len);
257} 267}
258 268
259int platform_init(void *promptr, char *dt_blob_start, char *dt_blob_end) 269void platform_init(unsigned long a1, unsigned long a2, void *promptr)
260{ 270{
261 platform_ops.image_hdr = of_image_hdr; 271 platform_ops.image_hdr = of_image_hdr;
262 platform_ops.malloc = of_try_claim; 272 platform_ops.malloc = of_try_claim;
263 platform_ops.exit = of_exit; 273 platform_ops.exit = of_exit;
274 platform_ops.vmlinux_alloc = of_vmlinux_alloc;
264 275
265 dt_ops.finddevice = of_finddevice; 276 dt_ops.finddevice = of_finddevice;
266 dt_ops.getprop = of_getprop; 277 dt_ops.getprop = of_getprop;
@@ -270,5 +281,9 @@ int platform_init(void *promptr, char *dt_blob_start, char *dt_blob_end)
270 console_ops.write = of_console_write; 281 console_ops.write = of_console_write;
271 282
272 prom = (int (*)(void *))promptr; 283 prom = (int (*)(void *))promptr;
273 return 0; 284 loader_info.promptr = promptr;
285 if (a1 && a2 && a2 != 0xdeadbeef) {
286 loader_info.initrd_addr = a1;
287 loader_info.initrd_size = a2;
288 }
274} 289}
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 8abb6516bb7c..73bd47a3a079 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -11,7 +11,9 @@
11#ifndef _PPC_BOOT_OPS_H_ 11#ifndef _PPC_BOOT_OPS_H_
12#define _PPC_BOOT_OPS_H_ 12#define _PPC_BOOT_OPS_H_
13 13
14#include <stddef.h>
14#include "types.h" 15#include "types.h"
16#include "string.h"
15 17
16#define COMMAND_LINE_SIZE 512 18#define COMMAND_LINE_SIZE 512
17#define MAX_PATH_LEN 256 19#define MAX_PATH_LEN 256
@@ -21,10 +23,11 @@
21struct platform_ops { 23struct platform_ops {
22 void (*fixups)(void); 24 void (*fixups)(void);
23 void (*image_hdr)(const void *); 25 void (*image_hdr)(const void *);
24 void * (*malloc)(u32 size); 26 void * (*malloc)(unsigned long size);
25 void (*free)(void *ptr); 27 void (*free)(void *ptr);
26 void * (*realloc)(void *ptr, unsigned long size); 28 void * (*realloc)(void *ptr, unsigned long size);
27 void (*exit)(void); 29 void (*exit)(void);
30 void * (*vmlinux_alloc)(unsigned long size);
28}; 31};
29extern struct platform_ops platform_ops; 32extern struct platform_ops platform_ops;
30 33
@@ -35,6 +38,12 @@ struct dt_ops {
35 const int buflen); 38 const int buflen);
36 int (*setprop)(const void *phandle, const char *name, 39 int (*setprop)(const void *phandle, const char *name,
37 const void *buf, const int buflen); 40 const void *buf, const int buflen);
41 void *(*get_parent)(const void *phandle);
42 /* The node must not already exist. */
43 void *(*create_node)(const void *parent, const char *name);
44 void *(*find_node_by_prop_value)(const void *prev,
45 const char *propname,
46 const char *propval, int proplen);
38 unsigned long (*finalize)(void); 47 unsigned long (*finalize)(void);
39}; 48};
40extern struct dt_ops dt_ops; 49extern struct dt_ops dt_ops;
@@ -58,13 +67,23 @@ struct serial_console_data {
58 void (*close)(void); 67 void (*close)(void);
59}; 68};
60 69
61int platform_init(void *promptr, char *dt_blob_start, char *dt_blob_end); 70struct loader_info {
71 void *promptr;
72 unsigned long initrd_addr, initrd_size;
73 char *cmdline;
74 int cmdline_len;
75};
76extern struct loader_info loader_info;
77
78void start(void);
62int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device); 79int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device);
63int serial_console_init(void); 80int serial_console_init(void);
64int ns16550_console_init(void *devp, struct serial_console_data *scdp); 81int ns16550_console_init(void *devp, struct serial_console_data *scdp);
65void *simple_alloc_init(char *base, u32 heap_size, u32 granularity, 82void *simple_alloc_init(char *base, unsigned long heap_size,
66 u32 max_allocs); 83 unsigned long granularity, unsigned long max_allocs);
67 84extern void flush_cache(void *, unsigned long);
85int dt_xlate_reg(void *node, int res, unsigned long *addr, unsigned long *size);
86int dt_xlate_addr(void *node, u32 *buf, int buflen, unsigned long *xlated_addr);
68 87
69static inline void *finddevice(const char *name) 88static inline void *finddevice(const char *name)
70{ 89{
@@ -76,12 +95,76 @@ static inline int getprop(void *devp, const char *name, void *buf, int buflen)
76 return (dt_ops.getprop) ? dt_ops.getprop(devp, name, buf, buflen) : -1; 95 return (dt_ops.getprop) ? dt_ops.getprop(devp, name, buf, buflen) : -1;
77} 96}
78 97
79static inline int setprop(void *devp, const char *name, void *buf, int buflen) 98static inline int setprop(void *devp, const char *name,
99 const void *buf, int buflen)
80{ 100{
81 return (dt_ops.setprop) ? dt_ops.setprop(devp, name, buf, buflen) : -1; 101 return (dt_ops.setprop) ? dt_ops.setprop(devp, name, buf, buflen) : -1;
82} 102}
103#define setprop_val(devp, name, val) \
104 do { \
105 typeof(val) x = (val); \
106 setprop((devp), (name), &x, sizeof(x)); \
107 } while (0)
108
109static inline int setprop_str(void *devp, const char *name, const char *buf)
110{
111 if (dt_ops.setprop)
112 return dt_ops.setprop(devp, name, buf, strlen(buf) + 1);
113
114 return -1;
115}
116
117static inline void *get_parent(const char *devp)
118{
119 return dt_ops.get_parent ? dt_ops.get_parent(devp) : NULL;
120}
121
122static inline void *create_node(const void *parent, const char *name)
123{
124 return dt_ops.create_node ? dt_ops.create_node(parent, name) : NULL;
125}
126
83 127
84static inline void *malloc(u32 size) 128static inline void *find_node_by_prop_value(const void *prev,
129 const char *propname,
130 const char *propval, int proplen)
131{
132 if (dt_ops.find_node_by_prop_value)
133 return dt_ops.find_node_by_prop_value(prev, propname,
134 propval, proplen);
135
136 return NULL;
137}
138
139static inline void *find_node_by_prop_value_str(const void *prev,
140 const char *propname,
141 const char *propval)
142{
143 return find_node_by_prop_value(prev, propname, propval,
144 strlen(propval) + 1);
145}
146
147static inline void *find_node_by_devtype(const void *prev,
148 const char *type)
149{
150 return find_node_by_prop_value_str(prev, "device_type", type);
151}
152
153void dt_fixup_memory(u64 start, u64 size);
154void dt_fixup_cpu_clocks(u32 cpufreq, u32 tbfreq, u32 busfreq);
155void dt_fixup_clock(const char *path, u32 freq);
156void __dt_fixup_mac_addresses(u32 startindex, ...);
157#define dt_fixup_mac_addresses(...) \
158 __dt_fixup_mac_addresses(0, __VA_ARGS__, NULL)
159
160
161static inline void *find_node_by_linuxphandle(const u32 linuxphandle)
162{
163 return find_node_by_prop_value(NULL, "linux,phandle",
164 (char *)&linuxphandle, sizeof(u32));
165}
166
167static inline void *malloc(unsigned long size)
85{ 168{
86 return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL; 169 return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL;
87} 170}
@@ -98,5 +181,11 @@ static inline void exit(void)
98 platform_ops.exit(); 181 platform_ops.exit();
99 for(;;); 182 for(;;);
100} 183}
184#define fatal(args...) { printf(args); exit(); }
185
186
187#define BSS_STACK(size) \
188 static char _bss_stack[size]; \
189 void *_platform_stack_top = _bss_stack + sizeof(_bss_stack);
101 190
102#endif /* _PPC_BOOT_OPS_H_ */ 191#endif /* _PPC_BOOT_OPS_H_ */
diff --git a/arch/powerpc/boot/ppcboot.h b/arch/powerpc/boot/ppcboot.h
new file mode 100644
index 000000000000..5290ff2c2b2b
--- /dev/null
+++ b/arch/powerpc/boot/ppcboot.h
@@ -0,0 +1,108 @@
1/*
2 * This interface is used for compatibility with old U-boots *ONLY*.
3 * Please do not imitate or extend this.
4 */
5
6/*
7 * (C) Copyright 2000, 2001
8 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
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,
23 * MA 02111-1307 USA
24 */
25
26#ifndef __PPCBOOT_H__
27#define __PPCBOOT_H__
28
29/*
30 * Board information passed to kernel from PPCBoot
31 *
32 * include/asm-ppc/ppcboot.h
33 */
34
35#include "types.h"
36
37typedef struct bd_info {
38 unsigned long bi_memstart; /* start of DRAM memory */
39 unsigned long bi_memsize; /* size of DRAM memory in bytes */
40 unsigned long bi_flashstart; /* start of FLASH memory */
41 unsigned long bi_flashsize; /* size of FLASH memory */
42 unsigned long bi_flashoffset; /* reserved area for startup monitor */
43 unsigned long bi_sramstart; /* start of SRAM memory */
44 unsigned long bi_sramsize; /* size of SRAM memory */
45#if defined(TARGET_8xx) || defined(TARGET_CPM2) || defined(TARGET_85xx) ||\
46 defined(TARGET_83xx)
47 unsigned long bi_immr_base; /* base of IMMR register */
48#endif
49#if defined(TARGET_PPC_MPC52xx)
50 unsigned long bi_mbar_base; /* base of internal registers */
51#endif
52 unsigned long bi_bootflags; /* boot / reboot flag (for LynxOS) */
53 unsigned long bi_ip_addr; /* IP Address */
54 unsigned char bi_enetaddr[6]; /* Ethernet address */
55 unsigned short bi_ethspeed; /* Ethernet speed in Mbps */
56 unsigned long bi_intfreq; /* Internal Freq, in MHz */
57 unsigned long bi_busfreq; /* Bus Freq, in MHz */
58#if defined(TARGET_CPM2)
59 unsigned long bi_cpmfreq; /* CPM_CLK Freq, in MHz */
60 unsigned long bi_brgfreq; /* BRG_CLK Freq, in MHz */
61 unsigned long bi_sccfreq; /* SCC_CLK Freq, in MHz */
62 unsigned long bi_vco; /* VCO Out from PLL, in MHz */
63#endif
64#if defined(TARGET_PPC_MPC52xx)
65 unsigned long bi_ipbfreq; /* IPB Bus Freq, in MHz */
66 unsigned long bi_pcifreq; /* PCI Bus Freq, in MHz */
67#endif
68 unsigned long bi_baudrate; /* Console Baudrate */
69#if defined(TARGET_4xx)
70 unsigned char bi_s_version[4]; /* Version of this structure */
71 unsigned char bi_r_version[32]; /* Version of the ROM (IBM) */
72 unsigned int bi_procfreq; /* CPU (Internal) Freq, in Hz */
73 unsigned int bi_plb_busfreq; /* PLB Bus speed, in Hz */
74 unsigned int bi_pci_busfreq; /* PCI Bus speed, in Hz */
75 unsigned char bi_pci_enetaddr[6]; /* PCI Ethernet MAC address */
76#endif
77#if defined(TARGET_HYMOD)
78 hymod_conf_t bi_hymod_conf; /* hymod configuration information */
79#endif
80#if defined(TARGET_EVB64260) || defined(TARGET_405EP) || defined(TARGET_44x) || \
81 defined(TARGET_85xx) || defined(TARGET_83xx)
82 /* second onboard ethernet port */
83 unsigned char bi_enet1addr[6];
84#define HAVE_ENET1ADDR
85#endif
86#if defined(TARGET_EVB64260) || defined(TARGET_440GX) || defined(TARGET_85xx)
87 /* third onboard ethernet ports */
88 unsigned char bi_enet2addr[6];
89#define HAVE_ENET2ADDR
90#endif
91#if defined(TARGET_440GX)
92 /* fourth onboard ethernet ports */
93 unsigned char bi_enet3addr[6];
94#define HAVE_ENET3ADDR
95#endif
96#if defined(TARGET_4xx)
97 unsigned int bi_opbfreq; /* OB clock in Hz */
98 int bi_iic_fast[2]; /* Use fast i2c mode */
99#endif
100#if defined(TARGET_440GX)
101 int bi_phynum[4]; /* phy mapping */
102 int bi_phymode[4]; /* phy mode */
103#endif
104} bd_t;
105
106#define bi_tbfreq bi_intfreq
107
108#endif /* __PPCBOOT_H__ */
diff --git a/arch/powerpc/boot/reg.h b/arch/powerpc/boot/reg.h
new file mode 100644
index 000000000000..d3cd9ee98afb
--- /dev/null
+++ b/arch/powerpc/boot/reg.h
@@ -0,0 +1,22 @@
1#ifndef _PPC_BOOT_REG_H
2#define _PPC_BOOT_REG_H
3/*
4 * Copyright 2007 Davud Gibson, IBM Corporation.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12static inline u32 mfpvr(void)
13{
14 u32 pvr;
15 asm volatile ("mfpvr %0" : "=r"(pvr));
16 return pvr;
17}
18
19register void *__stack_pointer asm("r1");
20#define get_sp() (__stack_pointer)
21
22#endif /* _PPC_BOOT_REG_H */
diff --git a/arch/powerpc/boot/simple_alloc.c b/arch/powerpc/boot/simple_alloc.c
index cfe3a7505ba0..65ec135d0157 100644
--- a/arch/powerpc/boot/simple_alloc.c
+++ b/arch/powerpc/boot/simple_alloc.c
@@ -19,24 +19,24 @@
19#define ENTRY_IN_USE 0x02 19#define ENTRY_IN_USE 0x02
20 20
21static struct alloc_info { 21static struct alloc_info {
22 u32 flags; 22 unsigned long flags;
23 u32 base; 23 unsigned long base;
24 u32 size; 24 unsigned long size;
25} *alloc_tbl; 25} *alloc_tbl;
26 26
27static u32 tbl_entries; 27static unsigned long tbl_entries;
28static u32 alloc_min; 28static unsigned long alloc_min;
29static u32 next_base; 29static unsigned long next_base;
30static u32 space_left; 30static unsigned long space_left;
31 31
32/* 32/*
33 * First time an entry is used, its base and size are set. 33 * First time an entry is used, its base and size are set.
34 * An entry can be freed and re-malloc'd but its base & size don't change. 34 * An entry can be freed and re-malloc'd but its base & size don't change.
35 * Should be smart enough for needs of bootwrapper. 35 * Should be smart enough for needs of bootwrapper.
36 */ 36 */
37static void *simple_malloc(u32 size) 37static void *simple_malloc(unsigned long size)
38{ 38{
39 u32 i; 39 unsigned long i;
40 struct alloc_info *p = alloc_tbl; 40 struct alloc_info *p = alloc_tbl;
41 41
42 if (size == 0) 42 if (size == 0)
@@ -67,13 +67,14 @@ err_out:
67 67
68static struct alloc_info *simple_find_entry(void *ptr) 68static struct alloc_info *simple_find_entry(void *ptr)
69{ 69{
70 u32 i; 70 unsigned long i;
71 struct alloc_info *p = alloc_tbl; 71 struct alloc_info *p = alloc_tbl;
72 72
73 for (i=0; i<tbl_entries; i++,p++) { 73 for (i=0; i<tbl_entries; i++,p++) {
74 if (!(p->flags & ENTRY_BEEN_USED)) 74 if (!(p->flags & ENTRY_BEEN_USED))
75 break; 75 break;
76 if ((p->flags & ENTRY_IN_USE) && (p->base == (u32)ptr)) 76 if ((p->flags & ENTRY_IN_USE) &&
77 (p->base == (unsigned long)ptr))
77 return p; 78 return p;
78 } 79 }
79 return NULL; 80 return NULL;
@@ -122,10 +123,10 @@ static void *simple_realloc(void *ptr, unsigned long size)
122 * Returns addr of first byte after heap so caller can see if it took 123 * Returns addr of first byte after heap so caller can see if it took
123 * too much space. If so, change args & try again. 124 * too much space. If so, change args & try again.
124 */ 125 */
125void *simple_alloc_init(char *base, u32 heap_size, u32 granularity, 126void *simple_alloc_init(char *base, unsigned long heap_size,
126 u32 max_allocs) 127 unsigned long granularity, unsigned long max_allocs)
127{ 128{
128 u32 heap_base, tbl_size; 129 unsigned long heap_base, tbl_size;
129 130
130 heap_size = _ALIGN_UP(heap_size, granularity); 131 heap_size = _ALIGN_UP(heap_size, granularity);
131 alloc_min = granularity; 132 alloc_min = granularity;
@@ -136,7 +137,7 @@ void *simple_alloc_init(char *base, u32 heap_size, u32 granularity,
136 alloc_tbl = (struct alloc_info *)_ALIGN_UP((unsigned long)base, 8); 137 alloc_tbl = (struct alloc_info *)_ALIGN_UP((unsigned long)base, 8);
137 memset(alloc_tbl, 0, tbl_size); 138 memset(alloc_tbl, 0, tbl_size);
138 139
139 heap_base = _ALIGN_UP((u32)alloc_tbl + tbl_size, alloc_min); 140 heap_base = _ALIGN_UP((unsigned long)alloc_tbl + tbl_size, alloc_min);
140 141
141 next_base = heap_base; 142 next_base = heap_base;
142 space_left = heap_size; 143 space_left = heap_size;
diff --git a/arch/powerpc/boot/stdio.h b/arch/powerpc/boot/stdio.h
index 73b8a91bfb34..adffc58412d4 100644
--- a/arch/powerpc/boot/stdio.h
+++ b/arch/powerpc/boot/stdio.h
@@ -7,11 +7,12 @@
7#define EINVAL 22 /* Invalid argument */ 7#define EINVAL 22 /* Invalid argument */
8#define ENOSPC 28 /* No space left on device */ 8#define ENOSPC 28 /* No space left on device */
9 9
10extern int printf(const char *fmt, ...); 10extern int printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
11 11
12#define fprintf(fmt, args...) printf(args) 12#define fprintf(fmt, args...) printf(args)
13 13
14extern int sprintf(char *buf, const char *fmt, ...); 14extern int sprintf(char *buf, const char *fmt, ...)
15 __attribute__((format(printf, 2, 3)));
15 16
16extern int vsprintf(char *buf, const char *fmt, va_list args); 17extern int vsprintf(char *buf, const char *fmt, va_list args);
17 18
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index 024e4d425c59..5cedd901201f 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -29,6 +29,7 @@ initrd=
29dtb= 29dtb=
30dts= 30dts=
31cacheit= 31cacheit=
32gzip=.gz
32 33
33# cross-compilation prefix 34# cross-compilation prefix
34CROSS= 35CROSS=
@@ -42,7 +43,7 @@ tmpdir=.
42usage() { 43usage() {
43 echo 'Usage: wrapper [-o output] [-p platform] [-i initrd]' >&2 44 echo 'Usage: wrapper [-o output] [-p platform] [-i initrd]' >&2
44 echo ' [-d devtree] [-s tree.dts] [-c] [-C cross-prefix]' >&2 45 echo ' [-d devtree] [-s tree.dts] [-c] [-C cross-prefix]' >&2
45 echo ' [-D datadir] [-W workingdir] [vmlinux]' >&2 46 echo ' [-D datadir] [-W workingdir] [--no-gzip] [vmlinux]' >&2
46 exit 1 47 exit 1
47} 48}
48 49
@@ -91,6 +92,9 @@ while [ "$#" -gt 0 ]; do
91 [ "$#" -gt 0 ] || usage 92 [ "$#" -gt 0 ] || usage
92 tmpdir="$1" 93 tmpdir="$1"
93 ;; 94 ;;
95 --no-gzip)
96 gzip=
97 ;;
94 -?) 98 -?)
95 usage 99 usage
96 ;; 100 ;;
@@ -137,31 +141,44 @@ miboot|uboot)
137 ksection=image 141 ksection=image
138 isection=initrd 142 isection=initrd
139 ;; 143 ;;
144cuboot*)
145 gzip=
146 ;;
140esac 147esac
141 148
142vmz="$tmpdir/`basename \"$kernel\"`.$ext" 149vmz="$tmpdir/`basename \"$kernel\"`.$ext"
143if [ -z "$cacheit" -o ! -f "$vmz.gz" -o "$vmz.gz" -ot "$kernel" ]; then 150if [ -z "$cacheit" -o ! -f "$vmz$gzip" -o "$vmz$gzip" -ot "$kernel" ]; then
144 ${CROSS}objcopy $objflags "$kernel" "$vmz.$$" 151 ${CROSS}objcopy $objflags "$kernel" "$vmz.$$"
145 gzip -f -9 "$vmz.$$" 152
153 if [ -n "$gzip" ]; then
154 gzip -f -9 "$vmz.$$"
155 fi
156
146 if [ -n "$cacheit" ]; then 157 if [ -n "$cacheit" ]; then
147 mv -f "$vmz.$$.gz" "$vmz.gz" 158 mv -f "$vmz.$$$gzip" "$vmz$gzip"
148 else 159 else
149 vmz="$vmz.$$" 160 vmz="$vmz.$$"
150 fi 161 fi
151fi 162fi
152 163
164vmz="$vmz$gzip"
165
153case "$platform" in 166case "$platform" in
154uboot) 167uboot|cuboot*)
155 rm -f "$ofile"
156 version=`${CROSS}strings "$kernel" | grep '^Linux version [-0-9.]' | \ 168 version=`${CROSS}strings "$kernel" | grep '^Linux version [-0-9.]' | \
157 cut -d' ' -f3` 169 cut -d' ' -f3`
158 if [ -n "$version" ]; then 170 if [ -n "$version" ]; then
159 version="-n Linux-$version" 171 version="-n Linux-$version"
160 fi 172 fi
173esac
174
175case "$platform" in
176uboot)
177 rm -f "$ofile"
161 mkimage -A ppc -O linux -T kernel -C gzip -a 00000000 -e 00000000 \ 178 mkimage -A ppc -O linux -T kernel -C gzip -a 00000000 -e 00000000 \
162 $version -d "$vmz.gz" "$ofile" 179 $version -d "$vmz" "$ofile"
163 if [ -z "$cacheit" ]; then 180 if [ -z "$cacheit" ]; then
164 rm -f $vmz.gz 181 rm -f "$vmz"
165 fi 182 fi
166 exit 0 183 exit 0
167 ;; 184 ;;
@@ -173,9 +190,9 @@ addsec() {
173 --set-section-flags=$3=contents,alloc,load,readonly,data 190 --set-section-flags=$3=contents,alloc,load,readonly,data
174} 191}
175 192
176addsec $tmp "$vmz.gz" $ksection $object/empty.o 193addsec $tmp "$vmz" $ksection $object/empty.o
177if [ -z "$cacheit" ]; then 194if [ -z "$cacheit" ]; then
178 rm -f "$vmz.gz" 195 rm -f "$vmz"
179fi 196fi
180 197
181if [ -n "$initrd" ]; then 198if [ -n "$initrd" ]; then
@@ -191,7 +208,7 @@ fi
191 208
192if [ "$platform" != "miboot" ]; then 209if [ "$platform" != "miboot" ]; then
193 ${CROSS}ld -m elf32ppc -T $lds -o "$ofile" \ 210 ${CROSS}ld -m elf32ppc -T $lds -o "$ofile" \
194 $object/crt0.o $platformo $tmp $object/wrapper.a 211 $platformo $tmp $object/wrapper.a
195 rm $tmp 212 rm $tmp
196fi 213fi
197 214
@@ -201,7 +218,19 @@ pseries|chrp)
201 $object/addnote "$ofile" 218 $object/addnote "$ofile"
202 ;; 219 ;;
203pmaccoff) 220pmaccoff)
204 ${CROSS}objcopy -O aixcoff-rs6000 --set-start 0x500000 "$ofile" 221 entry=`objdump -f "$ofile" | grep '^start address ' | \
222 cut -d' ' -f3`
223 ${CROSS}objcopy -O aixcoff-rs6000 --set-start "$entry" "$ofile"
205 $object/hack-coff "$ofile" 224 $object/hack-coff "$ofile"
206 ;; 225 ;;
226cuboot*)
227 base=`${CROSS}nm "$ofile" | grep ' _start$' | cut -d' ' -f1`
228 entry=`${CROSS}objdump -f "$ofile" | grep '^start address ' | \
229 cut -d' ' -f3`
230 mv "$ofile" "$ofile".elf
231 ${CROSS}objcopy -O binary "$ofile".elf "$ofile".bin
232 gzip -f -9 "$ofile".bin
233 mkimage -A ppc -O linux -T kernel -C gzip -a "$base" -e "$entry" \
234 $version -d "$ofile".bin.gz "$ofile"
235 ;;
207esac 236esac
diff --git a/arch/powerpc/boot/zImage.coff.lds.S b/arch/powerpc/boot/zImage.coff.lds.S
index a360905e5428..fe87a90ce7f1 100644
--- a/arch/powerpc/boot/zImage.coff.lds.S
+++ b/arch/powerpc/boot/zImage.coff.lds.S
@@ -1,5 +1,6 @@
1OUTPUT_ARCH(powerpc:common) 1OUTPUT_ARCH(powerpc:common)
2ENTRY(_start) 2ENTRY(_zimage_start_opd)
3EXTERN(_zimage_start_opd)
3SECTIONS 4SECTIONS
4{ 5{
5 . = (5*1024*1024); 6 . = (5*1024*1024);
diff --git a/arch/powerpc/boot/zImage.lds.S b/arch/powerpc/boot/zImage.lds.S
index 4be3c6414b04..f6e380fdb388 100644
--- a/arch/powerpc/boot/zImage.lds.S
+++ b/arch/powerpc/boot/zImage.lds.S
@@ -1,5 +1,6 @@
1OUTPUT_ARCH(powerpc:common) 1OUTPUT_ARCH(powerpc:common)
2ENTRY(_zimage_start) 2ENTRY(_zimage_start)
3EXTERN(_zimage_start)
3SECTIONS 4SECTIONS
4{ 5{
5 . = (4*1024*1024); 6 . = (4*1024*1024);
diff --git a/arch/powerpc/configs/cell_defconfig b/arch/powerpc/configs/cell_defconfig
index cf7e316ad4f6..6061e5f7696e 100644
--- a/arch/powerpc/configs/cell_defconfig
+++ b/arch/powerpc/configs/cell_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.21-rc3 3# Linux kernel version: 2.6.21-rc6
4# Fri Mar 9 23:34:53 2007 4# Mon Apr 23 20:46:48 2007
5# 5#
6CONFIG_PPC64=y 6CONFIG_PPC64=y
7CONFIG_64BIT=y 7CONFIG_64BIT=y
@@ -139,11 +139,31 @@ CONFIG_PPC_MULTIPLATFORM=y
139# CONFIG_PPC_PMAC is not set 139# CONFIG_PPC_PMAC is not set
140# CONFIG_PPC_MAPLE is not set 140# CONFIG_PPC_MAPLE is not set
141# CONFIG_PPC_PASEMI is not set 141# CONFIG_PPC_PASEMI is not set
142CONFIG_PPC_CELLEB=y
143CONFIG_PPC_PS3=y
144
145#
146# PS3 Platform Options
147#
148# CONFIG_PS3_ADVANCED is not set
149CONFIG_PS3_HTAB_SIZE=20
150# CONFIG_PS3_DYNAMIC_DMA is not set
151CONFIG_PS3_USE_LPAR_ADDR=y
152CONFIG_PS3_VUART=y
153CONFIG_PS3_PS3AV=y
154CONFIG_PS3_SYS_MANAGER=y
142CONFIG_PPC_CELL=y 155CONFIG_PPC_CELL=y
143CONFIG_PPC_CELL_NATIVE=y 156CONFIG_PPC_CELL_NATIVE=y
144CONFIG_PPC_IBM_CELL_BLADE=y 157CONFIG_PPC_IBM_CELL_BLADE=y
145CONFIG_PPC_PS3=y 158
146CONFIG_PPC_CELLEB=y 159#
160# Cell Broadband Engine options
161#
162CONFIG_SPU_FS=m
163CONFIG_SPU_BASE=y
164CONFIG_CBE_RAS=y
165CONFIG_CBE_THERM=m
166CONFIG_CBE_CPUFREQ=m
147CONFIG_PPC_NATIVE=y 167CONFIG_PPC_NATIVE=y
148CONFIG_UDBG_RTAS_CONSOLE=y 168CONFIG_UDBG_RTAS_CONSOLE=y
149CONFIG_PPC_UDBG_BEAT=y 169CONFIG_PPC_UDBG_BEAT=y
@@ -175,26 +195,6 @@ CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
175CONFIG_MPIC=y 195CONFIG_MPIC=y
176 196
177# 197#
178# Cell Broadband Engine options
179#
180CONFIG_SPU_FS=m
181CONFIG_SPU_BASE=y
182CONFIG_CBE_RAS=y
183CONFIG_CBE_THERM=m
184CONFIG_CBE_CPUFREQ=m
185
186#
187# PS3 Platform Options
188#
189# CONFIG_PS3_ADVANCED is not set
190CONFIG_PS3_HTAB_SIZE=20
191# CONFIG_PS3_DYNAMIC_DMA is not set
192CONFIG_PS3_USE_LPAR_ADDR=y
193CONFIG_PS3_VUART=y
194CONFIG_PS3_PS3AV=y
195CONFIG_PS3_SYS_MANAGER=y
196
197#
198# Kernel options 198# Kernel options
199# 199#
200# CONFIG_HZ_100 is not set 200# CONFIG_HZ_100 is not set
@@ -534,7 +534,6 @@ CONFIG_BLK_DEV_GENERIC=y
534# CONFIG_BLK_DEV_OPTI621 is not set 534# CONFIG_BLK_DEV_OPTI621 is not set
535CONFIG_BLK_DEV_IDEDMA_PCI=y 535CONFIG_BLK_DEV_IDEDMA_PCI=y
536# CONFIG_BLK_DEV_IDEDMA_FORCED is not set 536# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
537CONFIG_IDEDMA_PCI_AUTO=y
538# CONFIG_IDEDMA_ONLYDISK is not set 537# CONFIG_IDEDMA_ONLYDISK is not set
539CONFIG_BLK_DEV_AEC62XX=y 538CONFIG_BLK_DEV_AEC62XX=y
540# CONFIG_BLK_DEV_ALI15X3 is not set 539# CONFIG_BLK_DEV_ALI15X3 is not set
@@ -561,11 +560,10 @@ CONFIG_BLK_DEV_SIIMAGE=y
561# CONFIG_BLK_DEV_TRM290 is not set 560# CONFIG_BLK_DEV_TRM290 is not set
562# CONFIG_BLK_DEV_VIA82CXXX is not set 561# CONFIG_BLK_DEV_VIA82CXXX is not set
563# CONFIG_BLK_DEV_TC86C001 is not set 562# CONFIG_BLK_DEV_TC86C001 is not set
564CONFIG_BLK_DEV_IDE_CELLEB=y 563CONFIG_BLK_DEV_CELLEB=y
565# CONFIG_IDE_ARM is not set 564# CONFIG_IDE_ARM is not set
566CONFIG_BLK_DEV_IDEDMA=y 565CONFIG_BLK_DEV_IDEDMA=y
567# CONFIG_IDEDMA_IVB is not set 566# CONFIG_IDEDMA_IVB is not set
568CONFIG_IDEDMA_AUTO=y
569# CONFIG_BLK_DEV_HD is not set 567# CONFIG_BLK_DEV_HD is not set
570 568
571# 569#
@@ -937,7 +935,7 @@ CONFIG_UNIX98_PTYS=y
937# CONFIG_LEGACY_PTYS is not set 935# CONFIG_LEGACY_PTYS is not set
938CONFIG_HVC_DRIVER=y 936CONFIG_HVC_DRIVER=y
939CONFIG_HVC_RTAS=y 937CONFIG_HVC_RTAS=y
940# CONFIG_HVC_BEAT is not set 938CONFIG_HVC_BEAT=y
941 939
942# 940#
943# IPMI 941# IPMI
@@ -1482,6 +1480,8 @@ CONFIG_NLS_ISO8859_15=m
1482# Distributed Lock Manager 1480# Distributed Lock Manager
1483# 1481#
1484# CONFIG_DLM is not set 1482# CONFIG_DLM is not set
1483# CONFIG_UCC_SLOW is not set
1484# CONFIG_UCC_FAST is not set
1485 1485
1486# 1486#
1487# Library routines 1487# Library routines
@@ -1540,6 +1540,7 @@ CONFIG_DEBUG_BUGVERBOSE=y
1540# CONFIG_FAULT_INJECTION is not set 1540# CONFIG_FAULT_INJECTION is not set
1541# CONFIG_DEBUG_STACKOVERFLOW is not set 1541# CONFIG_DEBUG_STACKOVERFLOW is not set
1542# CONFIG_DEBUG_STACK_USAGE is not set 1542# CONFIG_DEBUG_STACK_USAGE is not set
1543# CONFIG_DEBUG_PAGEALLOC is not set
1543CONFIG_DEBUGGER=y 1544CONFIG_DEBUGGER=y
1544CONFIG_XMON=y 1545CONFIG_XMON=y
1545CONFIG_XMON_DEFAULT=y 1546CONFIG_XMON_DEFAULT=y
diff --git a/arch/powerpc/configs/g5_defconfig b/arch/powerpc/configs/g5_defconfig
index 7724847f702a..3ccf19d8da38 100644
--- a/arch/powerpc/configs/g5_defconfig
+++ b/arch/powerpc/configs/g5_defconfig
@@ -143,7 +143,7 @@ CONFIG_PPC_NATIVE=y
143CONFIG_U3_DART=y 143CONFIG_U3_DART=y
144# CONFIG_PPC_RTAS is not set 144# CONFIG_PPC_RTAS is not set
145# CONFIG_MMIO_NVRAM is not set 145# CONFIG_MMIO_NVRAM is not set
146CONFIG_MPIC_BROKEN_U3=y 146CONFIG_MPIC_U3_HT_IRQS=y
147# CONFIG_PPC_MPC106 is not set 147# CONFIG_PPC_MPC106 is not set
148CONFIG_PPC_970_NAP=y 148CONFIG_PPC_970_NAP=y
149# CONFIG_PPC_INDIRECT_IO is not set 149# CONFIG_PPC_INDIRECT_IO is not set
diff --git a/arch/powerpc/configs/maple_defconfig b/arch/powerpc/configs/maple_defconfig
index de97f2f0ae96..15366f0e489f 100644
--- a/arch/powerpc/configs/maple_defconfig
+++ b/arch/powerpc/configs/maple_defconfig
@@ -146,7 +146,7 @@ CONFIG_PPC_RTAS=y
146CONFIG_RTAS_PROC=y 146CONFIG_RTAS_PROC=y
147# CONFIG_RTAS_FLASH is not set 147# CONFIG_RTAS_FLASH is not set
148# CONFIG_MMIO_NVRAM is not set 148# CONFIG_MMIO_NVRAM is not set
149CONFIG_MPIC_BROKEN_U3=y 149CONFIG_MPIC_U3_HT_IRQS=y
150# CONFIG_PPC_MPC106 is not set 150# CONFIG_PPC_MPC106 is not set
151CONFIG_PPC_970_NAP=y 151CONFIG_PPC_970_NAP=y
152# CONFIG_PPC_INDIRECT_IO is not set 152# CONFIG_PPC_INDIRECT_IO is not set
diff --git a/arch/powerpc/configs/mpc832x_rdb_defconfig b/arch/powerpc/configs/mpc832x_rdb_defconfig
new file mode 100644
index 000000000000..56fc0a824458
--- /dev/null
+++ b/arch/powerpc/configs/mpc832x_rdb_defconfig
@@ -0,0 +1,1292 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.21-rc3
4# Mon Mar 12 17:32:19 2007
5#
6# CONFIG_PPC64 is not set
7CONFIG_PPC32=y
8CONFIG_PPC_MERGE=y
9CONFIG_MMU=y
10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_IRQ_PER_CPU=y
12CONFIG_RWSEM_XCHGADD_ALGORITHM=y
13CONFIG_ARCH_HAS_ILOG2_U32=y
14CONFIG_GENERIC_HWEIGHT=y
15CONFIG_GENERIC_CALIBRATE_DELAY=y
16CONFIG_GENERIC_FIND_NEXT_BIT=y
17CONFIG_PPC=y
18CONFIG_EARLY_PRINTK=y
19CONFIG_GENERIC_NVRAM=y
20CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
21CONFIG_ARCH_MAY_HAVE_PC_FDC=y
22CONFIG_PPC_OF=y
23CONFIG_PPC_UDBG_16550=y
24# CONFIG_GENERIC_TBSYNC is not set
25CONFIG_AUDIT_ARCH=y
26CONFIG_GENERIC_BUG=y
27CONFIG_DEFAULT_UIMAGE=y
28
29#
30# Processor support
31#
32# CONFIG_CLASSIC32 is not set
33# CONFIG_PPC_82xx is not set
34CONFIG_PPC_83xx=y
35# CONFIG_PPC_85xx is not set
36# CONFIG_PPC_86xx is not set
37# CONFIG_PPC_8xx is not set
38# CONFIG_40x is not set
39# CONFIG_44x is not set
40# CONFIG_E200 is not set
41CONFIG_6xx=y
42CONFIG_83xx=y
43CONFIG_PPC_FPU=y
44# CONFIG_PPC_DCR_NATIVE is not set
45# CONFIG_PPC_DCR_MMIO is not set
46CONFIG_PPC_STD_MMU=y
47CONFIG_PPC_STD_MMU_32=y
48# CONFIG_SMP is not set
49CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
50
51#
52# Code maturity level options
53#
54CONFIG_EXPERIMENTAL=y
55CONFIG_BROKEN_ON_SMP=y
56CONFIG_INIT_ENV_ARG_LIMIT=32
57
58#
59# General setup
60#
61CONFIG_LOCALVERSION=""
62CONFIG_LOCALVERSION_AUTO=y
63CONFIG_SWAP=y
64CONFIG_SYSVIPC=y
65# CONFIG_IPC_NS is not set
66CONFIG_SYSVIPC_SYSCTL=y
67# CONFIG_POSIX_MQUEUE is not set
68# CONFIG_BSD_PROCESS_ACCT is not set
69# CONFIG_TASKSTATS is not set
70# CONFIG_UTS_NS is not set
71# CONFIG_AUDIT is not set
72# CONFIG_IKCONFIG is not set
73CONFIG_SYSFS_DEPRECATED=y
74# CONFIG_RELAY is not set
75CONFIG_BLK_DEV_INITRD=y
76CONFIG_INITRAMFS_SOURCE=""
77# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
78CONFIG_SYSCTL=y
79CONFIG_EMBEDDED=y
80CONFIG_SYSCTL_SYSCALL=y
81# CONFIG_KALLSYMS is not set
82CONFIG_HOTPLUG=y
83CONFIG_PRINTK=y
84CONFIG_BUG=y
85CONFIG_ELF_CORE=y
86CONFIG_BASE_FULL=y
87CONFIG_FUTEX=y
88# CONFIG_EPOLL is not set
89CONFIG_SHMEM=y
90CONFIG_SLAB=y
91CONFIG_VM_EVENT_COUNTERS=y
92CONFIG_RT_MUTEXES=y
93# CONFIG_TINY_SHMEM is not set
94CONFIG_BASE_SMALL=0
95# CONFIG_SLOB is not set
96
97#
98# Loadable module support
99#
100CONFIG_MODULES=y
101CONFIG_MODULE_UNLOAD=y
102# CONFIG_MODULE_FORCE_UNLOAD is not set
103# CONFIG_MODVERSIONS is not set
104# CONFIG_MODULE_SRCVERSION_ALL is not set
105# CONFIG_KMOD is not set
106
107#
108# Block layer
109#
110CONFIG_BLOCK=y
111# CONFIG_LBD is not set
112# CONFIG_BLK_DEV_IO_TRACE is not set
113# CONFIG_LSF is not set
114
115#
116# IO Schedulers
117#
118CONFIG_IOSCHED_NOOP=y
119CONFIG_IOSCHED_AS=y
120CONFIG_IOSCHED_DEADLINE=y
121CONFIG_IOSCHED_CFQ=y
122CONFIG_DEFAULT_AS=y
123# CONFIG_DEFAULT_DEADLINE is not set
124# CONFIG_DEFAULT_CFQ is not set
125# CONFIG_DEFAULT_NOOP is not set
126CONFIG_DEFAULT_IOSCHED="anticipatory"
127CONFIG_QUICC_ENGINE=y
128CONFIG_PPC_GEN550=y
129# CONFIG_WANT_EARLY_SERIAL is not set
130
131#
132# Platform support
133#
134# CONFIG_MPC8313_RDB is not set
135# CONFIG_MPC832x_MDS is not set
136CONFIG_MPC832x_RDB=y
137# CONFIG_MPC834x_MDS is not set
138# CONFIG_MPC834x_ITX is not set
139# CONFIG_MPC836x_MDS is not set
140CONFIG_PPC_MPC832x=y
141# CONFIG_MPIC is not set
142
143#
144# Kernel options
145#
146# CONFIG_HIGHMEM is not set
147# CONFIG_HZ_100 is not set
148CONFIG_HZ_250=y
149# CONFIG_HZ_300 is not set
150# CONFIG_HZ_1000 is not set
151CONFIG_HZ=250
152CONFIG_PREEMPT_NONE=y
153# CONFIG_PREEMPT_VOLUNTARY is not set
154# CONFIG_PREEMPT is not set
155CONFIG_BINFMT_ELF=y
156# CONFIG_BINFMT_MISC is not set
157CONFIG_MATH_EMULATION=y
158CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
159CONFIG_ARCH_FLATMEM_ENABLE=y
160CONFIG_ARCH_POPULATES_NODE_MAP=y
161CONFIG_SELECT_MEMORY_MODEL=y
162CONFIG_FLATMEM_MANUAL=y
163# CONFIG_DISCONTIGMEM_MANUAL is not set
164# CONFIG_SPARSEMEM_MANUAL is not set
165CONFIG_FLATMEM=y
166CONFIG_FLAT_NODE_MEM_MAP=y
167# CONFIG_SPARSEMEM_STATIC is not set
168CONFIG_SPLIT_PTLOCK_CPUS=4
169# CONFIG_RESOURCES_64BIT is not set
170CONFIG_ZONE_DMA_FLAG=1
171CONFIG_PROC_DEVICETREE=y
172# CONFIG_CMDLINE_BOOL is not set
173# CONFIG_PM is not set
174CONFIG_SECCOMP=y
175CONFIG_ISA_DMA_API=y
176
177#
178# Bus options
179#
180CONFIG_ZONE_DMA=y
181CONFIG_GENERIC_ISA_DMA=y
182# CONFIG_MPIC_WEIRD is not set
183# CONFIG_PPC_I8259 is not set
184CONFIG_PPC_INDIRECT_PCI=y
185CONFIG_FSL_SOC=y
186CONFIG_PCI=y
187CONFIG_PCI_DOMAINS=y
188# CONFIG_PCIEPORTBUS is not set
189
190#
191# PCCARD (PCMCIA/CardBus) support
192#
193# CONFIG_PCCARD is not set
194
195#
196# PCI Hotplug Support
197#
198# CONFIG_HOTPLUG_PCI is not set
199
200#
201# Advanced setup
202#
203# CONFIG_ADVANCED_OPTIONS is not set
204
205#
206# Default settings for advanced configuration options are used
207#
208CONFIG_HIGHMEM_START=0xfe000000
209CONFIG_LOWMEM_SIZE=0x30000000
210CONFIG_KERNEL_START=0xc0000000
211CONFIG_TASK_SIZE=0x80000000
212CONFIG_BOOT_LOAD=0x00800000
213
214#
215# Networking
216#
217CONFIG_NET=y
218
219#
220# Networking options
221#
222# CONFIG_NETDEBUG is not set
223CONFIG_PACKET=y
224# CONFIG_PACKET_MMAP is not set
225CONFIG_UNIX=y
226CONFIG_XFRM=y
227# CONFIG_XFRM_USER is not set
228# CONFIG_XFRM_SUB_POLICY is not set
229# CONFIG_XFRM_MIGRATE is not set
230# CONFIG_NET_KEY is not set
231CONFIG_INET=y
232CONFIG_IP_MULTICAST=y
233# CONFIG_IP_ADVANCED_ROUTER is not set
234CONFIG_IP_FIB_HASH=y
235CONFIG_IP_PNP=y
236CONFIG_IP_PNP_DHCP=y
237CONFIG_IP_PNP_BOOTP=y
238# CONFIG_IP_PNP_RARP is not set
239# CONFIG_NET_IPIP is not set
240# CONFIG_NET_IPGRE is not set
241# CONFIG_IP_MROUTE is not set
242# CONFIG_ARPD is not set
243CONFIG_SYN_COOKIES=y
244# CONFIG_INET_AH is not set
245# CONFIG_INET_ESP is not set
246# CONFIG_INET_IPCOMP is not set
247# CONFIG_INET_XFRM_TUNNEL is not set
248# CONFIG_INET_TUNNEL is not set
249CONFIG_INET_XFRM_MODE_TRANSPORT=y
250CONFIG_INET_XFRM_MODE_TUNNEL=y
251CONFIG_INET_XFRM_MODE_BEET=y
252CONFIG_INET_DIAG=y
253CONFIG_INET_TCP_DIAG=y
254# CONFIG_TCP_CONG_ADVANCED is not set
255CONFIG_TCP_CONG_CUBIC=y
256CONFIG_DEFAULT_TCP_CONG="cubic"
257# CONFIG_TCP_MD5SIG is not set
258# CONFIG_IPV6 is not set
259# CONFIG_INET6_XFRM_TUNNEL is not set
260# CONFIG_INET6_TUNNEL is not set
261# CONFIG_NETWORK_SECMARK is not set
262# CONFIG_NETFILTER is not set
263
264#
265# DCCP Configuration (EXPERIMENTAL)
266#
267# CONFIG_IP_DCCP is not set
268
269#
270# SCTP Configuration (EXPERIMENTAL)
271#
272# CONFIG_IP_SCTP is not set
273
274#
275# TIPC Configuration (EXPERIMENTAL)
276#
277# CONFIG_TIPC is not set
278# CONFIG_ATM is not set
279# CONFIG_BRIDGE is not set
280# CONFIG_VLAN_8021Q is not set
281# CONFIG_DECNET is not set
282# CONFIG_LLC2 is not set
283# CONFIG_IPX is not set
284# CONFIG_ATALK is not set
285# CONFIG_X25 is not set
286# CONFIG_LAPB is not set
287# CONFIG_ECONET is not set
288# CONFIG_WAN_ROUTER is not set
289
290#
291# QoS and/or fair queueing
292#
293# CONFIG_NET_SCHED is not set
294
295#
296# Network testing
297#
298# CONFIG_NET_PKTGEN is not set
299# CONFIG_HAMRADIO is not set
300# CONFIG_IRDA is not set
301# CONFIG_BT is not set
302# CONFIG_IEEE80211 is not set
303
304#
305# Device Drivers
306#
307
308#
309# Generic Driver Options
310#
311CONFIG_STANDALONE=y
312CONFIG_PREVENT_FIRMWARE_BUILD=y
313# CONFIG_FW_LOADER is not set
314# CONFIG_SYS_HYPERVISOR is not set
315
316#
317# Connector - unified userspace <-> kernelspace linker
318#
319# CONFIG_CONNECTOR is not set
320
321#
322# Memory Technology Devices (MTD)
323#
324# CONFIG_MTD is not set
325
326#
327# Parallel port support
328#
329# CONFIG_PARPORT is not set
330
331#
332# Plug and Play support
333#
334# CONFIG_PNPACPI is not set
335
336#
337# Block devices
338#
339# CONFIG_BLK_DEV_FD is not set
340# CONFIG_BLK_CPQ_DA is not set
341# CONFIG_BLK_CPQ_CISS_DA is not set
342# CONFIG_BLK_DEV_DAC960 is not set
343# CONFIG_BLK_DEV_UMEM is not set
344# CONFIG_BLK_DEV_COW_COMMON is not set
345CONFIG_BLK_DEV_LOOP=y
346# CONFIG_BLK_DEV_CRYPTOLOOP is not set
347# CONFIG_BLK_DEV_NBD is not set
348# CONFIG_BLK_DEV_SX8 is not set
349# CONFIG_BLK_DEV_UB is not set
350CONFIG_BLK_DEV_RAM=y
351CONFIG_BLK_DEV_RAM_COUNT=16
352CONFIG_BLK_DEV_RAM_SIZE=32768
353CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
354# CONFIG_CDROM_PKTCDVD is not set
355# CONFIG_ATA_OVER_ETH is not set
356
357#
358# Misc devices
359#
360# CONFIG_SGI_IOC4 is not set
361# CONFIG_TIFM_CORE is not set
362
363#
364# ATA/ATAPI/MFM/RLL support
365#
366# CONFIG_IDE is not set
367
368#
369# SCSI device support
370#
371# CONFIG_RAID_ATTRS is not set
372CONFIG_SCSI=y
373# CONFIG_SCSI_TGT is not set
374# CONFIG_SCSI_NETLINK is not set
375CONFIG_SCSI_PROC_FS=y
376
377#
378# SCSI support type (disk, tape, CD-ROM)
379#
380CONFIG_BLK_DEV_SD=y
381# CONFIG_CHR_DEV_ST is not set
382# CONFIG_CHR_DEV_OSST is not set
383# CONFIG_BLK_DEV_SR is not set
384# CONFIG_CHR_DEV_SG is not set
385# CONFIG_CHR_DEV_SCH is not set
386
387#
388# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
389#
390# CONFIG_SCSI_MULTI_LUN is not set
391# CONFIG_SCSI_CONSTANTS is not set
392# CONFIG_SCSI_LOGGING is not set
393# CONFIG_SCSI_SCAN_ASYNC is not set
394
395#
396# SCSI Transports
397#
398# CONFIG_SCSI_SPI_ATTRS is not set
399# CONFIG_SCSI_FC_ATTRS is not set
400# CONFIG_SCSI_ISCSI_ATTRS is not set
401# CONFIG_SCSI_SAS_ATTRS is not set
402# CONFIG_SCSI_SAS_LIBSAS is not set
403
404#
405# SCSI low-level drivers
406#
407# CONFIG_ISCSI_TCP is not set
408# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
409# CONFIG_SCSI_3W_9XXX is not set
410# CONFIG_SCSI_ACARD is not set
411# CONFIG_SCSI_AACRAID is not set
412# CONFIG_SCSI_AIC7XXX is not set
413# CONFIG_SCSI_AIC7XXX_OLD is not set
414# CONFIG_SCSI_AIC79XX is not set
415# CONFIG_SCSI_AIC94XX is not set
416# CONFIG_SCSI_DPT_I2O is not set
417# CONFIG_SCSI_ARCMSR is not set
418# CONFIG_MEGARAID_NEWGEN is not set
419# CONFIG_MEGARAID_LEGACY is not set
420# CONFIG_MEGARAID_SAS is not set
421# CONFIG_SCSI_HPTIOP is not set
422# CONFIG_SCSI_BUSLOGIC is not set
423# CONFIG_SCSI_DMX3191D is not set
424# CONFIG_SCSI_EATA is not set
425# CONFIG_SCSI_FUTURE_DOMAIN is not set
426# CONFIG_SCSI_GDTH is not set
427# CONFIG_SCSI_IPS is not set
428# CONFIG_SCSI_INITIO is not set
429# CONFIG_SCSI_INIA100 is not set
430# CONFIG_SCSI_STEX is not set
431# CONFIG_SCSI_SYM53C8XX_2 is not set
432# CONFIG_SCSI_QLOGIC_1280 is not set
433# CONFIG_SCSI_QLA_FC is not set
434# CONFIG_SCSI_QLA_ISCSI is not set
435# CONFIG_SCSI_LPFC is not set
436# CONFIG_SCSI_DC395x is not set
437# CONFIG_SCSI_DC390T is not set
438# CONFIG_SCSI_NSP32 is not set
439# CONFIG_SCSI_DEBUG is not set
440# CONFIG_SCSI_SRP is not set
441
442#
443# Serial ATA (prod) and Parallel ATA (experimental) drivers
444#
445# CONFIG_ATA is not set
446
447#
448# Multi-device support (RAID and LVM)
449#
450# CONFIG_MD is not set
451
452#
453# Fusion MPT device support
454#
455# CONFIG_FUSION is not set
456# CONFIG_FUSION_SPI is not set
457# CONFIG_FUSION_FC is not set
458# CONFIG_FUSION_SAS is not set
459
460#
461# IEEE 1394 (FireWire) support
462#
463# CONFIG_IEEE1394 is not set
464
465#
466# I2O device support
467#
468# CONFIG_I2O is not set
469
470#
471# Macintosh device drivers
472#
473# CONFIG_MAC_EMUMOUSEBTN is not set
474# CONFIG_WINDFARM is not set
475
476#
477# Network device support
478#
479CONFIG_NETDEVICES=y
480# CONFIG_DUMMY is not set
481# CONFIG_BONDING is not set
482# CONFIG_EQUALIZER is not set
483# CONFIG_TUN is not set
484
485#
486# ARCnet devices
487#
488# CONFIG_ARCNET is not set
489
490#
491# PHY device support
492#
493# CONFIG_PHYLIB is not set
494
495#
496# Ethernet (10 or 100Mbit)
497#
498CONFIG_NET_ETHERNET=y
499CONFIG_MII=y
500# CONFIG_HAPPYMEAL is not set
501# CONFIG_SUNGEM is not set
502# CONFIG_CASSINI is not set
503# CONFIG_NET_VENDOR_3COM is not set
504
505#
506# Tulip family network device support
507#
508# CONFIG_NET_TULIP is not set
509# CONFIG_HP100 is not set
510# CONFIG_NET_PCI is not set
511
512#
513# Ethernet (1000 Mbit)
514#
515# CONFIG_ACENIC is not set
516# CONFIG_DL2K is not set
517CONFIG_E1000=y
518# CONFIG_E1000_NAPI is not set
519# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
520# CONFIG_NS83820 is not set
521# CONFIG_HAMACHI is not set
522# CONFIG_YELLOWFIN is not set
523# CONFIG_R8169 is not set
524# CONFIG_SIS190 is not set
525# CONFIG_SKGE is not set
526# CONFIG_SKY2 is not set
527# CONFIG_SK98LIN is not set
528# CONFIG_TIGON3 is not set
529# CONFIG_BNX2 is not set
530# CONFIG_GIANFAR is not set
531CONFIG_UCC_GETH=y
532CONFIG_UGETH_NAPI=y
533# CONFIG_UGETH_MAGIC_PACKET is not set
534# CONFIG_UGETH_FILTERING is not set
535# CONFIG_UGETH_TX_ON_DEMOND is not set
536# CONFIG_QLA3XXX is not set
537# CONFIG_ATL1 is not set
538
539#
540# Ethernet (10000 Mbit)
541#
542# CONFIG_CHELSIO_T1 is not set
543# CONFIG_CHELSIO_T3 is not set
544# CONFIG_IXGB is not set
545# CONFIG_S2IO is not set
546# CONFIG_MYRI10GE is not set
547# CONFIG_NETXEN_NIC is not set
548
549#
550# Token Ring devices
551#
552# CONFIG_TR is not set
553
554#
555# Wireless LAN (non-hamradio)
556#
557# CONFIG_NET_RADIO is not set
558
559#
560# Wan interfaces
561#
562# CONFIG_WAN is not set
563# CONFIG_FDDI is not set
564# CONFIG_HIPPI is not set
565# CONFIG_PPP is not set
566# CONFIG_SLIP is not set
567# CONFIG_NET_FC is not set
568# CONFIG_SHAPER is not set
569# CONFIG_NETCONSOLE is not set
570# CONFIG_NETPOLL is not set
571# CONFIG_NET_POLL_CONTROLLER is not set
572
573#
574# ISDN subsystem
575#
576# CONFIG_ISDN is not set
577
578#
579# Telephony Support
580#
581# CONFIG_PHONE is not set
582
583#
584# Input device support
585#
586CONFIG_INPUT=y
587# CONFIG_INPUT_FF_MEMLESS is not set
588
589#
590# Userland interfaces
591#
592# CONFIG_INPUT_MOUSEDEV is not set
593# CONFIG_INPUT_JOYDEV is not set
594# CONFIG_INPUT_TSDEV is not set
595# CONFIG_INPUT_EVDEV is not set
596# CONFIG_INPUT_EVBUG is not set
597
598#
599# Input Device Drivers
600#
601# CONFIG_INPUT_KEYBOARD is not set
602# CONFIG_INPUT_MOUSE is not set
603# CONFIG_INPUT_JOYSTICK is not set
604# CONFIG_INPUT_TOUCHSCREEN is not set
605# CONFIG_INPUT_MISC is not set
606
607#
608# Hardware I/O ports
609#
610# CONFIG_SERIO is not set
611# CONFIG_GAMEPORT is not set
612
613#
614# Character devices
615#
616# CONFIG_VT is not set
617# CONFIG_SERIAL_NONSTANDARD is not set
618
619#
620# Serial drivers
621#
622CONFIG_SERIAL_8250=y
623CONFIG_SERIAL_8250_CONSOLE=y
624CONFIG_SERIAL_8250_PCI=y
625CONFIG_SERIAL_8250_NR_UARTS=4
626CONFIG_SERIAL_8250_RUNTIME_UARTS=4
627# CONFIG_SERIAL_8250_EXTENDED is not set
628
629#
630# Non-8250 serial port support
631#
632# CONFIG_SERIAL_UARTLITE is not set
633CONFIG_SERIAL_CORE=y
634CONFIG_SERIAL_CORE_CONSOLE=y
635# CONFIG_SERIAL_JSM is not set
636# CONFIG_SERIAL_OF_PLATFORM is not set
637CONFIG_UNIX98_PTYS=y
638CONFIG_LEGACY_PTYS=y
639CONFIG_LEGACY_PTY_COUNT=256
640
641#
642# IPMI
643#
644# CONFIG_IPMI_HANDLER is not set
645
646#
647# Watchdog Cards
648#
649CONFIG_WATCHDOG=y
650# CONFIG_WATCHDOG_NOWAYOUT is not set
651
652#
653# Watchdog Device Drivers
654#
655# CONFIG_SOFT_WATCHDOG is not set
656CONFIG_83xx_WDT=y
657
658#
659# PCI-based Watchdog Cards
660#
661# CONFIG_PCIPCWATCHDOG is not set
662# CONFIG_WDTPCI is not set
663
664#
665# USB-based Watchdog Cards
666#
667# CONFIG_USBPCWATCHDOG is not set
668CONFIG_HW_RANDOM=y
669# CONFIG_NVRAM is not set
670CONFIG_GEN_RTC=y
671# CONFIG_GEN_RTC_X is not set
672# CONFIG_DTLK is not set
673# CONFIG_R3964 is not set
674# CONFIG_APPLICOM is not set
675# CONFIG_AGP is not set
676# CONFIG_DRM is not set
677# CONFIG_RAW_DRIVER is not set
678
679#
680# TPM devices
681#
682# CONFIG_TCG_TPM is not set
683
684#
685# I2C support
686#
687CONFIG_I2C=y
688CONFIG_I2C_CHARDEV=y
689
690#
691# I2C Algorithms
692#
693# CONFIG_I2C_ALGOBIT is not set
694# CONFIG_I2C_ALGOPCF is not set
695# CONFIG_I2C_ALGOPCA is not set
696
697#
698# I2C Hardware Bus support
699#
700# CONFIG_I2C_ALI1535 is not set
701# CONFIG_I2C_ALI1563 is not set
702# CONFIG_I2C_ALI15X3 is not set
703# CONFIG_I2C_AMD756 is not set
704# CONFIG_I2C_AMD8111 is not set
705# CONFIG_I2C_I801 is not set
706# CONFIG_I2C_I810 is not set
707# CONFIG_I2C_PIIX4 is not set
708CONFIG_I2C_MPC=y
709# CONFIG_I2C_NFORCE2 is not set
710# CONFIG_I2C_OCORES is not set
711# CONFIG_I2C_PARPORT_LIGHT is not set
712# CONFIG_I2C_PASEMI is not set
713# CONFIG_I2C_PROSAVAGE is not set
714# CONFIG_I2C_SAVAGE4 is not set
715# CONFIG_I2C_SIS5595 is not set
716# CONFIG_I2C_SIS630 is not set
717# CONFIG_I2C_SIS96X is not set
718# CONFIG_I2C_STUB is not set
719# CONFIG_I2C_VIA is not set
720# CONFIG_I2C_VIAPRO is not set
721# CONFIG_I2C_VOODOO3 is not set
722# CONFIG_I2C_PCA_ISA is not set
723
724#
725# Miscellaneous I2C Chip support
726#
727# CONFIG_SENSORS_DS1337 is not set
728# CONFIG_SENSORS_DS1374 is not set
729# CONFIG_SENSORS_EEPROM is not set
730# CONFIG_SENSORS_PCF8574 is not set
731# CONFIG_SENSORS_PCA9539 is not set
732# CONFIG_SENSORS_PCF8591 is not set
733# CONFIG_SENSORS_M41T00 is not set
734# CONFIG_SENSORS_MAX6875 is not set
735# CONFIG_I2C_DEBUG_CORE is not set
736# CONFIG_I2C_DEBUG_ALGO is not set
737# CONFIG_I2C_DEBUG_BUS is not set
738# CONFIG_I2C_DEBUG_CHIP is not set
739
740#
741# SPI support
742#
743# CONFIG_SPI is not set
744# CONFIG_SPI_MASTER is not set
745
746#
747# Dallas's 1-wire bus
748#
749# CONFIG_W1 is not set
750
751#
752# Hardware Monitoring support
753#
754CONFIG_HWMON=y
755# CONFIG_HWMON_VID is not set
756# CONFIG_SENSORS_ABITUGURU is not set
757# CONFIG_SENSORS_ADM1021 is not set
758# CONFIG_SENSORS_ADM1025 is not set
759# CONFIG_SENSORS_ADM1026 is not set
760# CONFIG_SENSORS_ADM1029 is not set
761# CONFIG_SENSORS_ADM1031 is not set
762# CONFIG_SENSORS_ADM9240 is not set
763# CONFIG_SENSORS_ASB100 is not set
764# CONFIG_SENSORS_ATXP1 is not set
765# CONFIG_SENSORS_DS1621 is not set
766# CONFIG_SENSORS_F71805F is not set
767# CONFIG_SENSORS_FSCHER is not set
768# CONFIG_SENSORS_FSCPOS is not set
769# CONFIG_SENSORS_GL518SM is not set
770# CONFIG_SENSORS_GL520SM is not set
771# CONFIG_SENSORS_IT87 is not set
772# CONFIG_SENSORS_LM63 is not set
773# CONFIG_SENSORS_LM75 is not set
774# CONFIG_SENSORS_LM77 is not set
775# CONFIG_SENSORS_LM78 is not set
776# CONFIG_SENSORS_LM80 is not set
777# CONFIG_SENSORS_LM83 is not set
778# CONFIG_SENSORS_LM85 is not set
779# CONFIG_SENSORS_LM87 is not set
780# CONFIG_SENSORS_LM90 is not set
781# CONFIG_SENSORS_LM92 is not set
782# CONFIG_SENSORS_MAX1619 is not set
783# CONFIG_SENSORS_PC87360 is not set
784# CONFIG_SENSORS_PC87427 is not set
785# CONFIG_SENSORS_SIS5595 is not set
786# CONFIG_SENSORS_SMSC47M1 is not set
787# CONFIG_SENSORS_SMSC47M192 is not set
788# CONFIG_SENSORS_SMSC47B397 is not set
789# CONFIG_SENSORS_VIA686A is not set
790# CONFIG_SENSORS_VT1211 is not set
791# CONFIG_SENSORS_VT8231 is not set
792# CONFIG_SENSORS_W83781D is not set
793# CONFIG_SENSORS_W83791D is not set
794# CONFIG_SENSORS_W83792D is not set
795# CONFIG_SENSORS_W83793 is not set
796# CONFIG_SENSORS_W83L785TS is not set
797# CONFIG_SENSORS_W83627HF is not set
798# CONFIG_SENSORS_W83627EHF is not set
799# CONFIG_HWMON_DEBUG_CHIP is not set
800
801#
802# Multifunction device drivers
803#
804# CONFIG_MFD_SM501 is not set
805
806#
807# Multimedia devices
808#
809# CONFIG_VIDEO_DEV is not set
810
811#
812# Digital Video Broadcasting Devices
813#
814# CONFIG_DVB is not set
815# CONFIG_USB_DABUSB is not set
816
817#
818# Graphics support
819#
820# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
821# CONFIG_FB is not set
822# CONFIG_FB_IBM_GXT4500 is not set
823
824#
825# Sound
826#
827# CONFIG_SOUND is not set
828
829#
830# HID Devices
831#
832CONFIG_HID=y
833# CONFIG_HID_DEBUG is not set
834
835#
836# USB support
837#
838CONFIG_USB_ARCH_HAS_HCD=y
839CONFIG_USB_ARCH_HAS_OHCI=y
840CONFIG_USB_ARCH_HAS_EHCI=y
841CONFIG_USB=y
842# CONFIG_USB_DEBUG is not set
843
844#
845# Miscellaneous USB options
846#
847CONFIG_USB_DEVICEFS=y
848# CONFIG_USB_DYNAMIC_MINORS is not set
849# CONFIG_USB_OTG is not set
850
851#
852# USB Host Controller Drivers
853#
854CONFIG_USB_EHCI_HCD=y
855# CONFIG_USB_EHCI_SPLIT_ISO is not set
856# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
857# CONFIG_USB_EHCI_TT_NEWSCHED is not set
858# CONFIG_USB_EHCI_BIG_ENDIAN_MMIO is not set
859# CONFIG_USB_ISP116X_HCD is not set
860CONFIG_USB_OHCI_HCD=y
861CONFIG_USB_OHCI_HCD_PPC_OF=y
862CONFIG_USB_OHCI_HCD_PPC_OF_BE=y
863# CONFIG_USB_OHCI_HCD_PPC_OF_LE is not set
864CONFIG_USB_OHCI_HCD_PCI=y
865CONFIG_USB_OHCI_BIG_ENDIAN_DESC=y
866CONFIG_USB_OHCI_BIG_ENDIAN_MMIO=y
867CONFIG_USB_OHCI_LITTLE_ENDIAN=y
868# CONFIG_USB_UHCI_HCD is not set
869# CONFIG_USB_SL811_HCD is not set
870
871#
872# USB Device Class drivers
873#
874# CONFIG_USB_ACM is not set
875# CONFIG_USB_PRINTER is not set
876
877#
878# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
879#
880
881#
882# may also be needed; see USB_STORAGE Help for more information
883#
884CONFIG_USB_STORAGE=y
885# CONFIG_USB_STORAGE_DEBUG is not set
886# CONFIG_USB_STORAGE_DATAFAB is not set
887# CONFIG_USB_STORAGE_FREECOM is not set
888# CONFIG_USB_STORAGE_DPCM is not set
889# CONFIG_USB_STORAGE_USBAT is not set
890# CONFIG_USB_STORAGE_SDDR09 is not set
891# CONFIG_USB_STORAGE_SDDR55 is not set
892# CONFIG_USB_STORAGE_JUMPSHOT is not set
893# CONFIG_USB_STORAGE_ALAUDA is not set
894# CONFIG_USB_STORAGE_KARMA is not set
895# CONFIG_USB_LIBUSUAL is not set
896
897#
898# USB Input Devices
899#
900# CONFIG_USB_HID is not set
901
902#
903# USB HID Boot Protocol drivers
904#
905# CONFIG_USB_KBD is not set
906# CONFIG_USB_MOUSE is not set
907# CONFIG_USB_AIPTEK is not set
908# CONFIG_USB_WACOM is not set
909# CONFIG_USB_ACECAD is not set
910# CONFIG_USB_KBTAB is not set
911# CONFIG_USB_POWERMATE is not set
912# CONFIG_USB_TOUCHSCREEN is not set
913# CONFIG_USB_YEALINK is not set
914# CONFIG_USB_XPAD is not set
915# CONFIG_USB_ATI_REMOTE is not set
916# CONFIG_USB_ATI_REMOTE2 is not set
917# CONFIG_USB_KEYSPAN_REMOTE is not set
918# CONFIG_USB_APPLETOUCH is not set
919# CONFIG_USB_GTCO is not set
920
921#
922# USB Imaging devices
923#
924# CONFIG_USB_MDC800 is not set
925# CONFIG_USB_MICROTEK is not set
926
927#
928# USB Network Adapters
929#
930# CONFIG_USB_CATC is not set
931# CONFIG_USB_KAWETH is not set
932# CONFIG_USB_PEGASUS is not set
933# CONFIG_USB_RTL8150 is not set
934# CONFIG_USB_USBNET_MII is not set
935# CONFIG_USB_USBNET is not set
936CONFIG_USB_MON=y
937
938#
939# USB port drivers
940#
941
942#
943# USB Serial Converter support
944#
945# CONFIG_USB_SERIAL is not set
946
947#
948# USB Miscellaneous drivers
949#
950# CONFIG_USB_EMI62 is not set
951# CONFIG_USB_EMI26 is not set
952# CONFIG_USB_ADUTUX is not set
953# CONFIG_USB_AUERSWALD is not set
954# CONFIG_USB_RIO500 is not set
955# CONFIG_USB_LEGOTOWER is not set
956# CONFIG_USB_LCD is not set
957# CONFIG_USB_BERRY_CHARGE is not set
958# CONFIG_USB_LED is not set
959# CONFIG_USB_CYPRESS_CY7C63 is not set
960# CONFIG_USB_CYTHERM is not set
961# CONFIG_USB_PHIDGET is not set
962# CONFIG_USB_IDMOUSE is not set
963# CONFIG_USB_FTDI_ELAN is not set
964# CONFIG_USB_APPLEDISPLAY is not set
965# CONFIG_USB_SISUSBVGA is not set
966# CONFIG_USB_LD is not set
967# CONFIG_USB_TRANCEVIBRATOR is not set
968# CONFIG_USB_IOWARRIOR is not set
969# CONFIG_USB_TEST is not set
970
971#
972# USB DSL modem support
973#
974
975#
976# USB Gadget Support
977#
978# CONFIG_USB_GADGET is not set
979
980#
981# MMC/SD Card support
982#
983# CONFIG_MMC is not set
984
985#
986# LED devices
987#
988# CONFIG_NEW_LEDS is not set
989
990#
991# LED drivers
992#
993
994#
995# LED Triggers
996#
997
998#
999# InfiniBand support
1000#
1001# CONFIG_INFINIBAND is not set
1002
1003#
1004# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
1005#
1006
1007#
1008# Real Time Clock
1009#
1010# CONFIG_RTC_CLASS is not set
1011
1012#
1013# DMA Engine support
1014#
1015# CONFIG_DMA_ENGINE is not set
1016
1017#
1018# DMA Clients
1019#
1020
1021#
1022# DMA Devices
1023#
1024
1025#
1026# Auxiliary Display support
1027#
1028
1029#
1030# Virtualization
1031#
1032
1033#
1034# File systems
1035#
1036CONFIG_EXT2_FS=y
1037# CONFIG_EXT2_FS_XATTR is not set
1038# CONFIG_EXT2_FS_XIP is not set
1039CONFIG_EXT3_FS=y
1040CONFIG_EXT3_FS_XATTR=y
1041# CONFIG_EXT3_FS_POSIX_ACL is not set
1042# CONFIG_EXT3_FS_SECURITY is not set
1043# CONFIG_EXT4DEV_FS is not set
1044CONFIG_JBD=y
1045# CONFIG_JBD_DEBUG is not set
1046CONFIG_FS_MBCACHE=y
1047# CONFIG_REISERFS_FS is not set
1048# CONFIG_JFS_FS is not set
1049# CONFIG_FS_POSIX_ACL is not set
1050# CONFIG_XFS_FS is not set
1051# CONFIG_GFS2_FS is not set
1052# CONFIG_OCFS2_FS is not set
1053# CONFIG_MINIX_FS is not set
1054# CONFIG_ROMFS_FS is not set
1055CONFIG_INOTIFY=y
1056CONFIG_INOTIFY_USER=y
1057# CONFIG_QUOTA is not set
1058CONFIG_DNOTIFY=y
1059# CONFIG_AUTOFS_FS is not set
1060# CONFIG_AUTOFS4_FS is not set
1061# CONFIG_FUSE_FS is not set
1062
1063#
1064# CD-ROM/DVD Filesystems
1065#
1066# CONFIG_ISO9660_FS is not set
1067# CONFIG_UDF_FS is not set
1068
1069#
1070# DOS/FAT/NT Filesystems
1071#
1072CONFIG_FAT_FS=y
1073CONFIG_MSDOS_FS=y
1074CONFIG_VFAT_FS=y
1075CONFIG_FAT_DEFAULT_CODEPAGE=437
1076CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1077# CONFIG_NTFS_FS is not set
1078
1079#
1080# Pseudo filesystems
1081#
1082CONFIG_PROC_FS=y
1083CONFIG_PROC_KCORE=y
1084CONFIG_PROC_SYSCTL=y
1085CONFIG_SYSFS=y
1086CONFIG_TMPFS=y
1087# CONFIG_TMPFS_POSIX_ACL is not set
1088# CONFIG_HUGETLB_PAGE is not set
1089CONFIG_RAMFS=y
1090# CONFIG_CONFIGFS_FS is not set
1091
1092#
1093# Miscellaneous filesystems
1094#
1095# CONFIG_ADFS_FS is not set
1096# CONFIG_AFFS_FS is not set
1097# CONFIG_HFS_FS is not set
1098# CONFIG_HFSPLUS_FS is not set
1099# CONFIG_BEFS_FS is not set
1100# CONFIG_BFS_FS is not set
1101# CONFIG_EFS_FS is not set
1102# CONFIG_CRAMFS is not set
1103# CONFIG_VXFS_FS is not set
1104# CONFIG_HPFS_FS is not set
1105# CONFIG_QNX4FS_FS is not set
1106# CONFIG_SYSV_FS is not set
1107# CONFIG_UFS_FS is not set
1108
1109#
1110# Network File Systems
1111#
1112CONFIG_NFS_FS=y
1113CONFIG_NFS_V3=y
1114# CONFIG_NFS_V3_ACL is not set
1115CONFIG_NFS_V4=y
1116# CONFIG_NFS_DIRECTIO is not set
1117# CONFIG_NFSD is not set
1118CONFIG_ROOT_NFS=y
1119CONFIG_LOCKD=y
1120CONFIG_LOCKD_V4=y
1121CONFIG_NFS_COMMON=y
1122CONFIG_SUNRPC=y
1123CONFIG_SUNRPC_GSS=y
1124CONFIG_RPCSEC_GSS_KRB5=y
1125# CONFIG_RPCSEC_GSS_SPKM3 is not set
1126# CONFIG_SMB_FS is not set
1127# CONFIG_CIFS is not set
1128# CONFIG_NCP_FS is not set
1129# CONFIG_CODA_FS is not set
1130# CONFIG_AFS_FS is not set
1131# CONFIG_9P_FS is not set
1132
1133#
1134# Partition Types
1135#
1136CONFIG_PARTITION_ADVANCED=y
1137# CONFIG_ACORN_PARTITION is not set
1138# CONFIG_OSF_PARTITION is not set
1139# CONFIG_AMIGA_PARTITION is not set
1140# CONFIG_ATARI_PARTITION is not set
1141# CONFIG_MAC_PARTITION is not set
1142CONFIG_MSDOS_PARTITION=y
1143# CONFIG_BSD_DISKLABEL is not set
1144# CONFIG_MINIX_SUBPARTITION is not set
1145# CONFIG_SOLARIS_X86_PARTITION is not set
1146# CONFIG_UNIXWARE_DISKLABEL is not set
1147CONFIG_LDM_PARTITION=y
1148# CONFIG_LDM_DEBUG is not set
1149# CONFIG_SGI_PARTITION is not set
1150# CONFIG_ULTRIX_PARTITION is not set
1151# CONFIG_SUN_PARTITION is not set
1152# CONFIG_KARMA_PARTITION is not set
1153# CONFIG_EFI_PARTITION is not set
1154
1155#
1156# Native Language Support
1157#
1158CONFIG_NLS=y
1159CONFIG_NLS_DEFAULT="iso8859-1"
1160CONFIG_NLS_CODEPAGE_437=y
1161# CONFIG_NLS_CODEPAGE_737 is not set
1162# CONFIG_NLS_CODEPAGE_775 is not set
1163# CONFIG_NLS_CODEPAGE_850 is not set
1164# CONFIG_NLS_CODEPAGE_852 is not set
1165# CONFIG_NLS_CODEPAGE_855 is not set
1166# CONFIG_NLS_CODEPAGE_857 is not set
1167# CONFIG_NLS_CODEPAGE_860 is not set
1168# CONFIG_NLS_CODEPAGE_861 is not set
1169# CONFIG_NLS_CODEPAGE_862 is not set
1170# CONFIG_NLS_CODEPAGE_863 is not set
1171# CONFIG_NLS_CODEPAGE_864 is not set
1172# CONFIG_NLS_CODEPAGE_865 is not set
1173# CONFIG_NLS_CODEPAGE_866 is not set
1174# CONFIG_NLS_CODEPAGE_869 is not set
1175# CONFIG_NLS_CODEPAGE_936 is not set
1176# CONFIG_NLS_CODEPAGE_950 is not set
1177CONFIG_NLS_CODEPAGE_932=y
1178# CONFIG_NLS_CODEPAGE_949 is not set
1179# CONFIG_NLS_CODEPAGE_874 is not set
1180CONFIG_NLS_ISO8859_8=y
1181# CONFIG_NLS_CODEPAGE_1250 is not set
1182# CONFIG_NLS_CODEPAGE_1251 is not set
1183# CONFIG_NLS_ASCII is not set
1184CONFIG_NLS_ISO8859_1=y
1185# CONFIG_NLS_ISO8859_2 is not set
1186# CONFIG_NLS_ISO8859_3 is not set
1187# CONFIG_NLS_ISO8859_4 is not set
1188# CONFIG_NLS_ISO8859_5 is not set
1189# CONFIG_NLS_ISO8859_6 is not set
1190# CONFIG_NLS_ISO8859_7 is not set
1191# CONFIG_NLS_ISO8859_9 is not set
1192# CONFIG_NLS_ISO8859_13 is not set
1193# CONFIG_NLS_ISO8859_14 is not set
1194# CONFIG_NLS_ISO8859_15 is not set
1195# CONFIG_NLS_KOI8_R is not set
1196# CONFIG_NLS_KOI8_U is not set
1197# CONFIG_NLS_UTF8 is not set
1198
1199#
1200# Distributed Lock Manager
1201#
1202# CONFIG_DLM is not set
1203
1204#
1205# QE Options
1206#
1207CONFIG_UCC_SLOW=y
1208CONFIG_UCC_FAST=y
1209CONFIG_UCC=y
1210
1211#
1212# Library routines
1213#
1214CONFIG_BITREVERSE=y
1215# CONFIG_CRC_CCITT is not set
1216# CONFIG_CRC16 is not set
1217CONFIG_CRC32=y
1218# CONFIG_LIBCRC32C is not set
1219CONFIG_PLIST=y
1220CONFIG_HAS_IOMEM=y
1221CONFIG_HAS_IOPORT=y
1222
1223#
1224# Instrumentation Support
1225#
1226# CONFIG_PROFILING is not set
1227
1228#
1229# Kernel hacking
1230#
1231# CONFIG_PRINTK_TIME is not set
1232CONFIG_ENABLE_MUST_CHECK=y
1233# CONFIG_MAGIC_SYSRQ is not set
1234# CONFIG_UNUSED_SYMBOLS is not set
1235# CONFIG_DEBUG_FS is not set
1236# CONFIG_HEADERS_CHECK is not set
1237# CONFIG_DEBUG_KERNEL is not set
1238CONFIG_LOG_BUF_SHIFT=14
1239# CONFIG_DEBUG_BUGVERBOSE is not set
1240# CONFIG_BOOTX_TEXT is not set
1241# CONFIG_SERIAL_TEXT_DEBUG is not set
1242# CONFIG_PPC_EARLY_DEBUG is not set
1243
1244#
1245# Security options
1246#
1247# CONFIG_KEYS is not set
1248# CONFIG_SECURITY is not set
1249
1250#
1251# Cryptographic options
1252#
1253CONFIG_CRYPTO=y
1254CONFIG_CRYPTO_ALGAPI=y
1255CONFIG_CRYPTO_BLKCIPHER=y
1256CONFIG_CRYPTO_MANAGER=y
1257# CONFIG_CRYPTO_HMAC is not set
1258# CONFIG_CRYPTO_XCBC is not set
1259# CONFIG_CRYPTO_NULL is not set
1260# CONFIG_CRYPTO_MD4 is not set
1261CONFIG_CRYPTO_MD5=y
1262# CONFIG_CRYPTO_SHA1 is not set
1263# CONFIG_CRYPTO_SHA256 is not set
1264# CONFIG_CRYPTO_SHA512 is not set
1265# CONFIG_CRYPTO_WP512 is not set
1266# CONFIG_CRYPTO_TGR192 is not set
1267# CONFIG_CRYPTO_GF128MUL is not set
1268CONFIG_CRYPTO_ECB=m
1269CONFIG_CRYPTO_CBC=y
1270CONFIG_CRYPTO_PCBC=m
1271# CONFIG_CRYPTO_LRW is not set
1272CONFIG_CRYPTO_DES=y
1273# CONFIG_CRYPTO_FCRYPT is not set
1274# CONFIG_CRYPTO_BLOWFISH is not set
1275# CONFIG_CRYPTO_TWOFISH is not set
1276# CONFIG_CRYPTO_SERPENT is not set
1277# CONFIG_CRYPTO_AES is not set
1278# CONFIG_CRYPTO_CAST5 is not set
1279# CONFIG_CRYPTO_CAST6 is not set
1280# CONFIG_CRYPTO_TEA is not set
1281# CONFIG_CRYPTO_ARC4 is not set
1282# CONFIG_CRYPTO_KHAZAD is not set
1283# CONFIG_CRYPTO_ANUBIS is not set
1284# CONFIG_CRYPTO_DEFLATE is not set
1285# CONFIG_CRYPTO_MICHAEL_MIC is not set
1286# CONFIG_CRYPTO_CRC32C is not set
1287# CONFIG_CRYPTO_CAMELLIA is not set
1288# CONFIG_CRYPTO_TEST is not set
1289
1290#
1291# Hardware crypto devices
1292#
diff --git a/arch/powerpc/configs/mpc8544_ds_defconfig b/arch/powerpc/configs/mpc8544_ds_defconfig
new file mode 100644
index 000000000000..b563513cc96c
--- /dev/null
+++ b/arch/powerpc/configs/mpc8544_ds_defconfig
@@ -0,0 +1,1077 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.21-rc3
4# Mon Mar 19 17:18:49 2007
5#
6# CONFIG_PPC64 is not set
7CONFIG_PPC32=y
8CONFIG_PPC_MERGE=y
9CONFIG_MMU=y
10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_IRQ_PER_CPU=y
12CONFIG_RWSEM_XCHGADD_ALGORITHM=y
13CONFIG_ARCH_HAS_ILOG2_U32=y
14CONFIG_GENERIC_HWEIGHT=y
15CONFIG_GENERIC_CALIBRATE_DELAY=y
16CONFIG_GENERIC_FIND_NEXT_BIT=y
17CONFIG_PPC=y
18CONFIG_EARLY_PRINTK=y
19CONFIG_GENERIC_NVRAM=y
20CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
21CONFIG_ARCH_MAY_HAVE_PC_FDC=y
22CONFIG_PPC_OF=y
23CONFIG_PPC_UDBG_16550=y
24# CONFIG_GENERIC_TBSYNC is not set
25CONFIG_AUDIT_ARCH=y
26CONFIG_GENERIC_BUG=y
27CONFIG_DEFAULT_UIMAGE=y
28
29#
30# Processor support
31#
32# CONFIG_CLASSIC32 is not set
33# CONFIG_PPC_82xx is not set
34# CONFIG_PPC_83xx is not set
35CONFIG_PPC_85xx=y
36# CONFIG_PPC_86xx is not set
37# CONFIG_PPC_8xx is not set
38# CONFIG_40x is not set
39# CONFIG_44x is not set
40# CONFIG_E200 is not set
41CONFIG_85xx=y
42CONFIG_E500=y
43# CONFIG_PPC_DCR_NATIVE is not set
44# CONFIG_PPC_DCR_MMIO is not set
45CONFIG_BOOKE=y
46CONFIG_FSL_BOOKE=y
47# CONFIG_PHYS_64BIT is not set
48# CONFIG_SPE is not set
49CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
50
51#
52# Code maturity level options
53#
54CONFIG_EXPERIMENTAL=y
55CONFIG_BROKEN_ON_SMP=y
56CONFIG_INIT_ENV_ARG_LIMIT=32
57
58#
59# General setup
60#
61CONFIG_LOCALVERSION=""
62CONFIG_LOCALVERSION_AUTO=y
63CONFIG_SWAP=y
64CONFIG_SYSVIPC=y
65CONFIG_IPC_NS=y
66CONFIG_SYSVIPC_SYSCTL=y
67CONFIG_POSIX_MQUEUE=y
68CONFIG_BSD_PROCESS_ACCT=y
69# CONFIG_BSD_PROCESS_ACCT_V3 is not set
70# CONFIG_TASKSTATS is not set
71# CONFIG_UTS_NS is not set
72CONFIG_AUDIT=y
73# CONFIG_AUDITSYSCALL is not set
74CONFIG_IKCONFIG=y
75CONFIG_IKCONFIG_PROC=y
76CONFIG_SYSFS_DEPRECATED=y
77# CONFIG_RELAY is not set
78CONFIG_BLK_DEV_INITRD=y
79CONFIG_INITRAMFS_SOURCE=""
80# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
81CONFIG_SYSCTL=y
82CONFIG_EMBEDDED=y
83CONFIG_SYSCTL_SYSCALL=y
84CONFIG_KALLSYMS=y
85CONFIG_KALLSYMS_ALL=y
86# CONFIG_KALLSYMS_EXTRA_PASS is not set
87# CONFIG_HOTPLUG is not set
88CONFIG_PRINTK=y
89CONFIG_BUG=y
90CONFIG_ELF_CORE=y
91CONFIG_BASE_FULL=y
92CONFIG_FUTEX=y
93CONFIG_EPOLL=y
94CONFIG_SHMEM=y
95CONFIG_SLAB=y
96CONFIG_VM_EVENT_COUNTERS=y
97CONFIG_RT_MUTEXES=y
98# CONFIG_TINY_SHMEM is not set
99CONFIG_BASE_SMALL=0
100# CONFIG_SLOB is not set
101
102#
103# Loadable module support
104#
105CONFIG_MODULES=y
106CONFIG_MODULE_UNLOAD=y
107CONFIG_MODULE_FORCE_UNLOAD=y
108CONFIG_MODVERSIONS=y
109# CONFIG_MODULE_SRCVERSION_ALL is not set
110CONFIG_KMOD=y
111
112#
113# Block layer
114#
115CONFIG_BLOCK=y
116CONFIG_LBD=y
117# CONFIG_BLK_DEV_IO_TRACE is not set
118# CONFIG_LSF is not set
119
120#
121# IO Schedulers
122#
123CONFIG_IOSCHED_NOOP=y
124CONFIG_IOSCHED_AS=y
125CONFIG_IOSCHED_DEADLINE=y
126CONFIG_IOSCHED_CFQ=y
127# CONFIG_DEFAULT_AS is not set
128# CONFIG_DEFAULT_DEADLINE is not set
129CONFIG_DEFAULT_CFQ=y
130# CONFIG_DEFAULT_NOOP is not set
131CONFIG_DEFAULT_IOSCHED="cfq"
132# CONFIG_WANT_EARLY_SERIAL is not set
133
134#
135# Platform support
136#
137# CONFIG_MPC8540_ADS is not set
138# CONFIG_MPC8560_ADS is not set
139# CONFIG_MPC85xx_CDS is not set
140# CONFIG_MPC85xx_MDS is not set
141CONFIG_MPC8544_DS=y
142CONFIG_MPC85xx=y
143CONFIG_PPC_INDIRECT_PCI_BE=y
144CONFIG_MPIC=y
145
146#
147# Kernel options
148#
149CONFIG_HIGHMEM=y
150# CONFIG_HZ_100 is not set
151CONFIG_HZ_250=y
152# CONFIG_HZ_300 is not set
153# CONFIG_HZ_1000 is not set
154CONFIG_HZ=250
155CONFIG_PREEMPT_NONE=y
156# CONFIG_PREEMPT_VOLUNTARY is not set
157# CONFIG_PREEMPT is not set
158CONFIG_BINFMT_ELF=y
159CONFIG_BINFMT_MISC=m
160CONFIG_MATH_EMULATION=y
161CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
162CONFIG_ARCH_FLATMEM_ENABLE=y
163CONFIG_ARCH_POPULATES_NODE_MAP=y
164CONFIG_SELECT_MEMORY_MODEL=y
165CONFIG_FLATMEM_MANUAL=y
166# CONFIG_DISCONTIGMEM_MANUAL is not set
167# CONFIG_SPARSEMEM_MANUAL is not set
168CONFIG_FLATMEM=y
169CONFIG_FLAT_NODE_MEM_MAP=y
170# CONFIG_SPARSEMEM_STATIC is not set
171CONFIG_SPLIT_PTLOCK_CPUS=4
172# CONFIG_RESOURCES_64BIT is not set
173CONFIG_ZONE_DMA_FLAG=1
174CONFIG_PROC_DEVICETREE=y
175CONFIG_CMDLINE_BOOL=y
176CONFIG_CMDLINE="root=/dev/sda3 rw console=ttyS0,115200"
177# CONFIG_PM is not set
178CONFIG_SECCOMP=y
179CONFIG_ISA_DMA_API=y
180
181#
182# Bus options
183#
184CONFIG_ZONE_DMA=y
185# CONFIG_MPIC_WEIRD is not set
186# CONFIG_PPC_I8259 is not set
187CONFIG_PPC_INDIRECT_PCI=y
188CONFIG_FSL_SOC=y
189# CONFIG_PCI is not set
190# CONFIG_PCI_DOMAINS is not set
191
192#
193# PCCARD (PCMCIA/CardBus) support
194#
195
196#
197# PCI Hotplug Support
198#
199
200#
201# Advanced setup
202#
203# CONFIG_ADVANCED_OPTIONS is not set
204
205#
206# Default settings for advanced configuration options are used
207#
208CONFIG_HIGHMEM_START=0xfe000000
209CONFIG_LOWMEM_SIZE=0x30000000
210CONFIG_KERNEL_START=0xc0000000
211CONFIG_TASK_SIZE=0x80000000
212CONFIG_BOOT_LOAD=0x00800000
213
214#
215# Networking
216#
217CONFIG_NET=y
218
219#
220# Networking options
221#
222# CONFIG_NETDEBUG is not set
223CONFIG_PACKET=y
224# CONFIG_PACKET_MMAP is not set
225CONFIG_UNIX=y
226CONFIG_XFRM=y
227CONFIG_XFRM_USER=m
228# CONFIG_XFRM_SUB_POLICY is not set
229# CONFIG_XFRM_MIGRATE is not set
230CONFIG_NET_KEY=m
231# CONFIG_NET_KEY_MIGRATE is not set
232CONFIG_INET=y
233CONFIG_IP_MULTICAST=y
234CONFIG_IP_ADVANCED_ROUTER=y
235CONFIG_ASK_IP_FIB_HASH=y
236# CONFIG_IP_FIB_TRIE is not set
237CONFIG_IP_FIB_HASH=y
238CONFIG_IP_MULTIPLE_TABLES=y
239CONFIG_IP_ROUTE_MULTIPATH=y
240# CONFIG_IP_ROUTE_MULTIPATH_CACHED is not set
241CONFIG_IP_ROUTE_VERBOSE=y
242CONFIG_IP_PNP=y
243CONFIG_IP_PNP_DHCP=y
244CONFIG_IP_PNP_BOOTP=y
245CONFIG_IP_PNP_RARP=y
246CONFIG_NET_IPIP=y
247CONFIG_NET_IPGRE=y
248CONFIG_NET_IPGRE_BROADCAST=y
249CONFIG_IP_MROUTE=y
250CONFIG_IP_PIMSM_V1=y
251CONFIG_IP_PIMSM_V2=y
252CONFIG_ARPD=y
253# CONFIG_SYN_COOKIES is not set
254# CONFIG_INET_AH is not set
255# CONFIG_INET_ESP is not set
256# CONFIG_INET_IPCOMP is not set
257# CONFIG_INET_XFRM_TUNNEL is not set
258CONFIG_INET_TUNNEL=y
259# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
260# CONFIG_INET_XFRM_MODE_TUNNEL is not set
261# CONFIG_INET_XFRM_MODE_BEET is not set
262CONFIG_INET_DIAG=y
263CONFIG_INET_TCP_DIAG=y
264# CONFIG_TCP_CONG_ADVANCED is not set
265CONFIG_TCP_CONG_CUBIC=y
266CONFIG_DEFAULT_TCP_CONG="cubic"
267# CONFIG_TCP_MD5SIG is not set
268# CONFIG_IPV6 is not set
269# CONFIG_INET6_XFRM_TUNNEL is not set
270# CONFIG_INET6_TUNNEL is not set
271# CONFIG_NETWORK_SECMARK is not set
272# CONFIG_NETFILTER is not set
273
274#
275# DCCP Configuration (EXPERIMENTAL)
276#
277# CONFIG_IP_DCCP is not set
278
279#
280# SCTP Configuration (EXPERIMENTAL)
281#
282CONFIG_IP_SCTP=m
283# CONFIG_SCTP_DBG_MSG is not set
284# CONFIG_SCTP_DBG_OBJCNT is not set
285# CONFIG_SCTP_HMAC_NONE is not set
286# CONFIG_SCTP_HMAC_SHA1 is not set
287CONFIG_SCTP_HMAC_MD5=y
288
289#
290# TIPC Configuration (EXPERIMENTAL)
291#
292# CONFIG_TIPC is not set
293# CONFIG_ATM is not set
294# CONFIG_BRIDGE is not set
295# CONFIG_VLAN_8021Q is not set
296# CONFIG_DECNET is not set
297# CONFIG_LLC2 is not set
298# CONFIG_IPX is not set
299# CONFIG_ATALK is not set
300# CONFIG_X25 is not set
301# CONFIG_LAPB is not set
302# CONFIG_ECONET is not set
303# CONFIG_WAN_ROUTER is not set
304
305#
306# QoS and/or fair queueing
307#
308# CONFIG_NET_SCHED is not set
309
310#
311# Network testing
312#
313# CONFIG_NET_PKTGEN is not set
314# CONFIG_HAMRADIO is not set
315# CONFIG_IRDA is not set
316# CONFIG_BT is not set
317# CONFIG_IEEE80211 is not set
318CONFIG_FIB_RULES=y
319
320#
321# Device Drivers
322#
323
324#
325# Generic Driver Options
326#
327CONFIG_STANDALONE=y
328CONFIG_PREVENT_FIRMWARE_BUILD=y
329# CONFIG_DEBUG_DRIVER is not set
330# CONFIG_DEBUG_DEVRES is not set
331# CONFIG_SYS_HYPERVISOR is not set
332
333#
334# Connector - unified userspace <-> kernelspace linker
335#
336# CONFIG_CONNECTOR is not set
337
338#
339# Memory Technology Devices (MTD)
340#
341# CONFIG_MTD is not set
342
343#
344# Parallel port support
345#
346# CONFIG_PARPORT is not set
347
348#
349# Plug and Play support
350#
351# CONFIG_PNPACPI is not set
352
353#
354# Block devices
355#
356# CONFIG_BLK_DEV_FD is not set
357# CONFIG_BLK_DEV_COW_COMMON is not set
358CONFIG_BLK_DEV_LOOP=y
359# CONFIG_BLK_DEV_CRYPTOLOOP is not set
360CONFIG_BLK_DEV_NBD=y
361CONFIG_BLK_DEV_RAM=y
362CONFIG_BLK_DEV_RAM_COUNT=2
363CONFIG_BLK_DEV_RAM_SIZE=16384
364CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
365# CONFIG_CDROM_PKTCDVD is not set
366# CONFIG_ATA_OVER_ETH is not set
367
368#
369# Misc devices
370#
371
372#
373# ATA/ATAPI/MFM/RLL support
374#
375# CONFIG_IDE is not set
376
377#
378# SCSI device support
379#
380# CONFIG_RAID_ATTRS is not set
381CONFIG_SCSI=y
382# CONFIG_SCSI_TGT is not set
383# CONFIG_SCSI_NETLINK is not set
384CONFIG_SCSI_PROC_FS=y
385
386#
387# SCSI support type (disk, tape, CD-ROM)
388#
389CONFIG_BLK_DEV_SD=y
390CONFIG_CHR_DEV_ST=y
391# CONFIG_CHR_DEV_OSST is not set
392# CONFIG_BLK_DEV_SR is not set
393CONFIG_CHR_DEV_SG=y
394# CONFIG_CHR_DEV_SCH is not set
395
396#
397# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
398#
399CONFIG_SCSI_MULTI_LUN=y
400# CONFIG_SCSI_CONSTANTS is not set
401CONFIG_SCSI_LOGGING=y
402# CONFIG_SCSI_SCAN_ASYNC is not set
403
404#
405# SCSI Transports
406#
407# CONFIG_SCSI_SPI_ATTRS is not set
408# CONFIG_SCSI_FC_ATTRS is not set
409# CONFIG_SCSI_ISCSI_ATTRS is not set
410# CONFIG_SCSI_SAS_ATTRS is not set
411# CONFIG_SCSI_SAS_LIBSAS is not set
412
413#
414# SCSI low-level drivers
415#
416# CONFIG_ISCSI_TCP is not set
417# CONFIG_SCSI_DEBUG is not set
418
419#
420# Serial ATA (prod) and Parallel ATA (experimental) drivers
421#
422CONFIG_ATA=y
423# CONFIG_ATA_NONSTANDARD is not set
424# CONFIG_PATA_PLATFORM is not set
425
426#
427# Multi-device support (RAID and LVM)
428#
429# CONFIG_MD is not set
430
431#
432# Fusion MPT device support
433#
434# CONFIG_FUSION is not set
435
436#
437# IEEE 1394 (FireWire) support
438#
439
440#
441# I2O device support
442#
443
444#
445# Macintosh device drivers
446#
447# CONFIG_MAC_EMUMOUSEBTN is not set
448# CONFIG_WINDFARM is not set
449
450#
451# Network device support
452#
453CONFIG_NETDEVICES=y
454# CONFIG_DUMMY is not set
455# CONFIG_BONDING is not set
456# CONFIG_EQUALIZER is not set
457# CONFIG_TUN is not set
458
459#
460# PHY device support
461#
462CONFIG_PHYLIB=y
463
464#
465# MII PHY device drivers
466#
467# CONFIG_MARVELL_PHY is not set
468# CONFIG_DAVICOM_PHY is not set
469# CONFIG_QSEMI_PHY is not set
470# CONFIG_LXT_PHY is not set
471# CONFIG_CICADA_PHY is not set
472CONFIG_VITESSE_PHY=y
473# CONFIG_SMSC_PHY is not set
474# CONFIG_BROADCOM_PHY is not set
475# CONFIG_FIXED_PHY is not set
476
477#
478# Ethernet (10 or 100Mbit)
479#
480CONFIG_NET_ETHERNET=y
481CONFIG_MII=y
482
483#
484# Ethernet (1000 Mbit)
485#
486CONFIG_GIANFAR=y
487CONFIG_GFAR_NAPI=y
488
489#
490# Ethernet (10000 Mbit)
491#
492
493#
494# Token Ring devices
495#
496
497#
498# Wireless LAN (non-hamradio)
499#
500# CONFIG_NET_RADIO is not set
501
502#
503# Wan interfaces
504#
505# CONFIG_WAN is not set
506# CONFIG_PPP is not set
507# CONFIG_SLIP is not set
508# CONFIG_SHAPER is not set
509# CONFIG_NETCONSOLE is not set
510# CONFIG_NETPOLL is not set
511# CONFIG_NET_POLL_CONTROLLER is not set
512
513#
514# ISDN subsystem
515#
516# CONFIG_ISDN is not set
517
518#
519# Telephony Support
520#
521# CONFIG_PHONE is not set
522
523#
524# Input device support
525#
526CONFIG_INPUT=y
527# CONFIG_INPUT_FF_MEMLESS is not set
528
529#
530# Userland interfaces
531#
532# CONFIG_INPUT_MOUSEDEV is not set
533# CONFIG_INPUT_JOYDEV is not set
534# CONFIG_INPUT_TSDEV is not set
535# CONFIG_INPUT_EVDEV is not set
536# CONFIG_INPUT_EVBUG is not set
537
538#
539# Input Device Drivers
540#
541# CONFIG_INPUT_KEYBOARD is not set
542# CONFIG_INPUT_MOUSE is not set
543# CONFIG_INPUT_JOYSTICK is not set
544# CONFIG_INPUT_TOUCHSCREEN is not set
545# CONFIG_INPUT_MISC is not set
546
547#
548# Hardware I/O ports
549#
550CONFIG_SERIO=y
551CONFIG_SERIO_I8042=y
552CONFIG_SERIO_SERPORT=y
553CONFIG_SERIO_LIBPS2=y
554# CONFIG_SERIO_RAW is not set
555# CONFIG_GAMEPORT is not set
556
557#
558# Character devices
559#
560CONFIG_VT=y
561CONFIG_VT_CONSOLE=y
562CONFIG_HW_CONSOLE=y
563# CONFIG_VT_HW_CONSOLE_BINDING is not set
564# CONFIG_SERIAL_NONSTANDARD is not set
565
566#
567# Serial drivers
568#
569CONFIG_SERIAL_8250=y
570CONFIG_SERIAL_8250_CONSOLE=y
571CONFIG_SERIAL_8250_NR_UARTS=4
572CONFIG_SERIAL_8250_RUNTIME_UARTS=4
573# CONFIG_SERIAL_8250_EXTENDED is not set
574
575#
576# Non-8250 serial port support
577#
578# CONFIG_SERIAL_UARTLITE is not set
579CONFIG_SERIAL_CORE=y
580CONFIG_SERIAL_CORE_CONSOLE=y
581# CONFIG_SERIAL_OF_PLATFORM is not set
582CONFIG_UNIX98_PTYS=y
583CONFIG_LEGACY_PTYS=y
584CONFIG_LEGACY_PTY_COUNT=256
585
586#
587# IPMI
588#
589# CONFIG_IPMI_HANDLER is not set
590
591#
592# Watchdog Cards
593#
594# CONFIG_WATCHDOG is not set
595# CONFIG_HW_RANDOM is not set
596CONFIG_NVRAM=y
597CONFIG_GEN_RTC=y
598CONFIG_GEN_RTC_X=y
599# CONFIG_DTLK is not set
600# CONFIG_R3964 is not set
601# CONFIG_RAW_DRIVER is not set
602
603#
604# TPM devices
605#
606# CONFIG_TCG_TPM is not set
607
608#
609# I2C support
610#
611# CONFIG_I2C is not set
612
613#
614# SPI support
615#
616# CONFIG_SPI is not set
617# CONFIG_SPI_MASTER is not set
618
619#
620# Dallas's 1-wire bus
621#
622# CONFIG_W1 is not set
623
624#
625# Hardware Monitoring support
626#
627# CONFIG_HWMON is not set
628# CONFIG_HWMON_VID is not set
629
630#
631# Multifunction device drivers
632#
633# CONFIG_MFD_SM501 is not set
634
635#
636# Multimedia devices
637#
638# CONFIG_VIDEO_DEV is not set
639
640#
641# Digital Video Broadcasting Devices
642#
643CONFIG_DVB=y
644CONFIG_DVB_CORE=m
645# CONFIG_DVB_CORE_ATTACH is not set
646
647#
648# Supported DVB Frontends
649#
650
651#
652# Customise DVB Frontends
653#
654# CONFIG_DVB_FE_CUSTOMISE is not set
655
656#
657# DVB-S (satellite) frontends
658#
659
660#
661# DVB-T (terrestrial) frontends
662#
663
664#
665# DVB-C (cable) frontends
666#
667
668#
669# ATSC (North American/Korean Terrestrial/Cable DTV) frontends
670#
671
672#
673# Tuners/PLL support
674#
675
676#
677# Miscellaneous devices
678#
679
680#
681# Graphics support
682#
683# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
684# CONFIG_FB is not set
685# CONFIG_FB_IBM_GXT4500 is not set
686
687#
688# Console display driver support
689#
690# CONFIG_VGA_CONSOLE is not set
691CONFIG_DUMMY_CONSOLE=y
692
693#
694# Sound
695#
696# CONFIG_SOUND is not set
697
698#
699# HID Devices
700#
701CONFIG_HID=y
702# CONFIG_HID_DEBUG is not set
703
704#
705# USB support
706#
707# CONFIG_USB_ARCH_HAS_HCD is not set
708# CONFIG_USB_ARCH_HAS_OHCI is not set
709# CONFIG_USB_ARCH_HAS_EHCI is not set
710
711#
712# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
713#
714
715#
716# USB Gadget Support
717#
718# CONFIG_USB_GADGET is not set
719
720#
721# MMC/SD Card support
722#
723# CONFIG_MMC is not set
724
725#
726# LED devices
727#
728# CONFIG_NEW_LEDS is not set
729
730#
731# LED drivers
732#
733
734#
735# LED Triggers
736#
737
738#
739# InfiniBand support
740#
741
742#
743# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
744#
745
746#
747# Real Time Clock
748#
749CONFIG_RTC_LIB=y
750CONFIG_RTC_CLASS=y
751CONFIG_RTC_HCTOSYS=y
752CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
753# CONFIG_RTC_DEBUG is not set
754
755#
756# RTC interfaces
757#
758CONFIG_RTC_INTF_SYSFS=y
759CONFIG_RTC_INTF_PROC=y
760CONFIG_RTC_INTF_DEV=y
761# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
762
763#
764# RTC drivers
765#
766# CONFIG_RTC_DRV_DS1553 is not set
767# CONFIG_RTC_DRV_DS1742 is not set
768# CONFIG_RTC_DRV_M48T86 is not set
769# CONFIG_RTC_DRV_TEST is not set
770# CONFIG_RTC_DRV_V3020 is not set
771
772#
773# DMA Engine support
774#
775# CONFIG_DMA_ENGINE is not set
776
777#
778# DMA Clients
779#
780
781#
782# DMA Devices
783#
784
785#
786# Auxiliary Display support
787#
788
789#
790# Virtualization
791#
792
793#
794# File systems
795#
796CONFIG_EXT2_FS=y
797# CONFIG_EXT2_FS_XATTR is not set
798# CONFIG_EXT2_FS_XIP is not set
799CONFIG_EXT3_FS=y
800CONFIG_EXT3_FS_XATTR=y
801# CONFIG_EXT3_FS_POSIX_ACL is not set
802# CONFIG_EXT3_FS_SECURITY is not set
803# CONFIG_EXT4DEV_FS is not set
804CONFIG_JBD=y
805# CONFIG_JBD_DEBUG is not set
806CONFIG_FS_MBCACHE=y
807# CONFIG_REISERFS_FS is not set
808# CONFIG_JFS_FS is not set
809# CONFIG_FS_POSIX_ACL is not set
810# CONFIG_XFS_FS is not set
811# CONFIG_GFS2_FS is not set
812# CONFIG_OCFS2_FS is not set
813# CONFIG_MINIX_FS is not set
814# CONFIG_ROMFS_FS is not set
815CONFIG_INOTIFY=y
816CONFIG_INOTIFY_USER=y
817# CONFIG_QUOTA is not set
818CONFIG_DNOTIFY=y
819# CONFIG_AUTOFS_FS is not set
820# CONFIG_AUTOFS4_FS is not set
821# CONFIG_FUSE_FS is not set
822
823#
824# CD-ROM/DVD Filesystems
825#
826CONFIG_ISO9660_FS=m
827CONFIG_JOLIET=y
828CONFIG_ZISOFS=y
829CONFIG_UDF_FS=m
830CONFIG_UDF_NLS=y
831
832#
833# DOS/FAT/NT Filesystems
834#
835CONFIG_FAT_FS=y
836CONFIG_MSDOS_FS=m
837CONFIG_VFAT_FS=y
838CONFIG_FAT_DEFAULT_CODEPAGE=437
839CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
840CONFIG_NTFS_FS=y
841# CONFIG_NTFS_DEBUG is not set
842# CONFIG_NTFS_RW is not set
843
844#
845# Pseudo filesystems
846#
847CONFIG_PROC_FS=y
848CONFIG_PROC_KCORE=y
849CONFIG_PROC_SYSCTL=y
850CONFIG_SYSFS=y
851CONFIG_TMPFS=y
852# CONFIG_TMPFS_POSIX_ACL is not set
853# CONFIG_HUGETLB_PAGE is not set
854CONFIG_RAMFS=y
855# CONFIG_CONFIGFS_FS is not set
856
857#
858# Miscellaneous filesystems
859#
860CONFIG_ADFS_FS=m
861# CONFIG_ADFS_FS_RW is not set
862CONFIG_AFFS_FS=m
863CONFIG_HFS_FS=m
864CONFIG_HFSPLUS_FS=m
865CONFIG_BEFS_FS=m
866# CONFIG_BEFS_DEBUG is not set
867CONFIG_BFS_FS=m
868CONFIG_EFS_FS=m
869CONFIG_CRAMFS=y
870CONFIG_VXFS_FS=m
871CONFIG_HPFS_FS=m
872CONFIG_QNX4FS_FS=m
873CONFIG_SYSV_FS=m
874CONFIG_UFS_FS=m
875# CONFIG_UFS_FS_WRITE is not set
876# CONFIG_UFS_DEBUG is not set
877
878#
879# Network File Systems
880#
881CONFIG_NFS_FS=y
882CONFIG_NFS_V3=y
883# CONFIG_NFS_V3_ACL is not set
884CONFIG_NFS_V4=y
885# CONFIG_NFS_DIRECTIO is not set
886# CONFIG_NFSD is not set
887CONFIG_ROOT_NFS=y
888CONFIG_LOCKD=y
889CONFIG_LOCKD_V4=y
890CONFIG_NFS_COMMON=y
891CONFIG_SUNRPC=y
892CONFIG_SUNRPC_GSS=y
893CONFIG_RPCSEC_GSS_KRB5=y
894# CONFIG_RPCSEC_GSS_SPKM3 is not set
895# CONFIG_SMB_FS is not set
896# CONFIG_CIFS is not set
897# CONFIG_NCP_FS is not set
898# CONFIG_CODA_FS is not set
899# CONFIG_AFS_FS is not set
900# CONFIG_9P_FS is not set
901
902#
903# Partition Types
904#
905CONFIG_PARTITION_ADVANCED=y
906# CONFIG_ACORN_PARTITION is not set
907# CONFIG_OSF_PARTITION is not set
908# CONFIG_AMIGA_PARTITION is not set
909# CONFIG_ATARI_PARTITION is not set
910# CONFIG_MAC_PARTITION is not set
911CONFIG_MSDOS_PARTITION=y
912# CONFIG_BSD_DISKLABEL is not set
913# CONFIG_MINIX_SUBPARTITION is not set
914# CONFIG_SOLARIS_X86_PARTITION is not set
915# CONFIG_UNIXWARE_DISKLABEL is not set
916# CONFIG_LDM_PARTITION is not set
917# CONFIG_SGI_PARTITION is not set
918# CONFIG_ULTRIX_PARTITION is not set
919# CONFIG_SUN_PARTITION is not set
920# CONFIG_KARMA_PARTITION is not set
921# CONFIG_EFI_PARTITION is not set
922
923#
924# Native Language Support
925#
926CONFIG_NLS=y
927CONFIG_NLS_DEFAULT="iso8859-1"
928# CONFIG_NLS_CODEPAGE_437 is not set
929# CONFIG_NLS_CODEPAGE_737 is not set
930# CONFIG_NLS_CODEPAGE_775 is not set
931# CONFIG_NLS_CODEPAGE_850 is not set
932# CONFIG_NLS_CODEPAGE_852 is not set
933# CONFIG_NLS_CODEPAGE_855 is not set
934# CONFIG_NLS_CODEPAGE_857 is not set
935# CONFIG_NLS_CODEPAGE_860 is not set
936# CONFIG_NLS_CODEPAGE_861 is not set
937# CONFIG_NLS_CODEPAGE_862 is not set
938# CONFIG_NLS_CODEPAGE_863 is not set
939# CONFIG_NLS_CODEPAGE_864 is not set
940# CONFIG_NLS_CODEPAGE_865 is not set
941# CONFIG_NLS_CODEPAGE_866 is not set
942# CONFIG_NLS_CODEPAGE_869 is not set
943# CONFIG_NLS_CODEPAGE_936 is not set
944# CONFIG_NLS_CODEPAGE_950 is not set
945# CONFIG_NLS_CODEPAGE_932 is not set
946# CONFIG_NLS_CODEPAGE_949 is not set
947# CONFIG_NLS_CODEPAGE_874 is not set
948# CONFIG_NLS_ISO8859_8 is not set
949# CONFIG_NLS_CODEPAGE_1250 is not set
950# CONFIG_NLS_CODEPAGE_1251 is not set
951# CONFIG_NLS_ASCII is not set
952# CONFIG_NLS_ISO8859_1 is not set
953# CONFIG_NLS_ISO8859_2 is not set
954# CONFIG_NLS_ISO8859_3 is not set
955# CONFIG_NLS_ISO8859_4 is not set
956# CONFIG_NLS_ISO8859_5 is not set
957# CONFIG_NLS_ISO8859_6 is not set
958# CONFIG_NLS_ISO8859_7 is not set
959# CONFIG_NLS_ISO8859_9 is not set
960# CONFIG_NLS_ISO8859_13 is not set
961# CONFIG_NLS_ISO8859_14 is not set
962# CONFIG_NLS_ISO8859_15 is not set
963# CONFIG_NLS_KOI8_R is not set
964# CONFIG_NLS_KOI8_U is not set
965CONFIG_NLS_UTF8=m
966
967#
968# Distributed Lock Manager
969#
970# CONFIG_DLM is not set
971
972#
973# Library routines
974#
975CONFIG_BITREVERSE=y
976# CONFIG_CRC_CCITT is not set
977# CONFIG_CRC16 is not set
978CONFIG_CRC32=y
979CONFIG_LIBCRC32C=m
980CONFIG_ZLIB_INFLATE=y
981CONFIG_PLIST=y
982CONFIG_HAS_IOMEM=y
983CONFIG_HAS_IOPORT=y
984
985#
986# Instrumentation Support
987#
988# CONFIG_PROFILING is not set
989
990#
991# Kernel hacking
992#
993# CONFIG_PRINTK_TIME is not set
994CONFIG_ENABLE_MUST_CHECK=y
995# CONFIG_MAGIC_SYSRQ is not set
996# CONFIG_UNUSED_SYMBOLS is not set
997# CONFIG_DEBUG_FS is not set
998# CONFIG_HEADERS_CHECK is not set
999CONFIG_DEBUG_KERNEL=y
1000# CONFIG_DEBUG_SHIRQ is not set
1001CONFIG_LOG_BUF_SHIFT=14
1002CONFIG_DETECT_SOFTLOCKUP=y
1003# CONFIG_SCHEDSTATS is not set
1004# CONFIG_TIMER_STATS is not set
1005# CONFIG_DEBUG_SLAB is not set
1006# CONFIG_DEBUG_RT_MUTEXES is not set
1007# CONFIG_RT_MUTEX_TESTER is not set
1008# CONFIG_DEBUG_SPINLOCK is not set
1009# CONFIG_DEBUG_MUTEXES is not set
1010# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1011# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1012# CONFIG_DEBUG_KOBJECT is not set
1013# CONFIG_DEBUG_HIGHMEM is not set
1014# CONFIG_DEBUG_BUGVERBOSE is not set
1015CONFIG_DEBUG_INFO=y
1016# CONFIG_DEBUG_VM is not set
1017# CONFIG_DEBUG_LIST is not set
1018CONFIG_FORCED_INLINING=y
1019# CONFIG_RCU_TORTURE_TEST is not set
1020# CONFIG_FAULT_INJECTION is not set
1021# CONFIG_DEBUG_STACKOVERFLOW is not set
1022# CONFIG_DEBUG_STACK_USAGE is not set
1023# CONFIG_DEBUGGER is not set
1024# CONFIG_BDI_SWITCH is not set
1025# CONFIG_BOOTX_TEXT is not set
1026# CONFIG_PPC_EARLY_DEBUG is not set
1027
1028#
1029# Security options
1030#
1031# CONFIG_KEYS is not set
1032# CONFIG_SECURITY is not set
1033
1034#
1035# Cryptographic options
1036#
1037CONFIG_CRYPTO=y
1038CONFIG_CRYPTO_ALGAPI=y
1039CONFIG_CRYPTO_BLKCIPHER=y
1040CONFIG_CRYPTO_HASH=y
1041CONFIG_CRYPTO_MANAGER=y
1042CONFIG_CRYPTO_HMAC=y
1043# CONFIG_CRYPTO_XCBC is not set
1044# CONFIG_CRYPTO_NULL is not set
1045# CONFIG_CRYPTO_MD4 is not set
1046CONFIG_CRYPTO_MD5=y
1047# CONFIG_CRYPTO_SHA1 is not set
1048# CONFIG_CRYPTO_SHA256 is not set
1049# CONFIG_CRYPTO_SHA512 is not set
1050# CONFIG_CRYPTO_WP512 is not set
1051# CONFIG_CRYPTO_TGR192 is not set
1052# CONFIG_CRYPTO_GF128MUL is not set
1053# CONFIG_CRYPTO_ECB is not set
1054CONFIG_CRYPTO_CBC=y
1055CONFIG_CRYPTO_PCBC=m
1056# CONFIG_CRYPTO_LRW is not set
1057CONFIG_CRYPTO_DES=y
1058# CONFIG_CRYPTO_FCRYPT is not set
1059# CONFIG_CRYPTO_BLOWFISH is not set
1060# CONFIG_CRYPTO_TWOFISH is not set
1061# CONFIG_CRYPTO_SERPENT is not set
1062# CONFIG_CRYPTO_AES is not set
1063# CONFIG_CRYPTO_CAST5 is not set
1064# CONFIG_CRYPTO_CAST6 is not set
1065# CONFIG_CRYPTO_TEA is not set
1066# CONFIG_CRYPTO_ARC4 is not set
1067# CONFIG_CRYPTO_KHAZAD is not set
1068# CONFIG_CRYPTO_ANUBIS is not set
1069# CONFIG_CRYPTO_DEFLATE is not set
1070# CONFIG_CRYPTO_MICHAEL_MIC is not set
1071# CONFIG_CRYPTO_CRC32C is not set
1072# CONFIG_CRYPTO_CAMELLIA is not set
1073# CONFIG_CRYPTO_TEST is not set
1074
1075#
1076# Hardware crypto devices
1077#
diff --git a/arch/powerpc/configs/ppc64_defconfig b/arch/powerpc/configs/ppc64_defconfig
index a8da0aea3b87..126b9f87df25 100644
--- a/arch/powerpc/configs/ppc64_defconfig
+++ b/arch/powerpc/configs/ppc64_defconfig
@@ -152,7 +152,7 @@ CONFIG_RTAS_ERROR_LOGGING=y
152CONFIG_RTAS_PROC=y 152CONFIG_RTAS_PROC=y
153CONFIG_RTAS_FLASH=m 153CONFIG_RTAS_FLASH=m
154CONFIG_MMIO_NVRAM=y 154CONFIG_MMIO_NVRAM=y
155CONFIG_MPIC_BROKEN_U3=y 155CONFIG_MPIC_U3_HT_IRQS=y
156CONFIG_IBMVIO=y 156CONFIG_IBMVIO=y
157# CONFIG_IBMEBUS is not set 157# CONFIG_IBMEBUS is not set
158# CONFIG_PPC_MPC106 is not set 158# CONFIG_PPC_MPC106 is not set
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 8120d428ebfd..e0fa80eca366 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -25,8 +25,8 @@ obj-$(CONFIG_PPC_970_NAP) += idle_power4.o
25obj-$(CONFIG_PPC_OF) += of_device.o of_platform.o prom_parse.o 25obj-$(CONFIG_PPC_OF) += of_device.o of_platform.o prom_parse.o
26procfs-$(CONFIG_PPC64) := proc_ppc64.o 26procfs-$(CONFIG_PPC64) := proc_ppc64.o
27obj-$(CONFIG_PROC_FS) += $(procfs-y) 27obj-$(CONFIG_PROC_FS) += $(procfs-y)
28rtaspci-$(CONFIG_PPC64) := rtas_pci.o 28rtaspci-$(CONFIG_PPC64)-$(CONFIG_PCI) := rtas_pci.o
29obj-$(CONFIG_PPC_RTAS) += rtas.o rtas-rtc.o $(rtaspci-y) 29obj-$(CONFIG_PPC_RTAS) += rtas.o rtas-rtc.o $(rtaspci-y-y)
30obj-$(CONFIG_RTAS_FLASH) += rtas_flash.o 30obj-$(CONFIG_RTAS_FLASH) += rtas_flash.o
31obj-$(CONFIG_RTAS_PROC) += rtas-proc.o 31obj-$(CONFIG_RTAS_PROC) += rtas-proc.o
32obj-$(CONFIG_LPARCFG) += lparcfg.o 32obj-$(CONFIG_LPARCFG) += lparcfg.o
diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c
index 4734b5de599d..5c9ff7f5c44e 100644
--- a/arch/powerpc/kernel/align.c
+++ b/arch/powerpc/kernel/align.c
@@ -241,7 +241,7 @@ static int emulate_dcbz(struct pt_regs *regs, unsigned char __user *addr)
241 if (user_mode(regs) && !access_ok(VERIFY_WRITE, p, size)) 241 if (user_mode(regs) && !access_ok(VERIFY_WRITE, p, size))
242 return -EFAULT; 242 return -EFAULT;
243 for (i = 0; i < size / sizeof(long); ++i) 243 for (i = 0; i < size / sizeof(long); ++i)
244 if (__put_user(0, p+i)) 244 if (__put_user_inatomic(0, p+i))
245 return -EFAULT; 245 return -EFAULT;
246 return 1; 246 return 1;
247} 247}
@@ -288,7 +288,8 @@ static int emulate_multiple(struct pt_regs *regs, unsigned char __user *addr,
288 } else { 288 } else {
289 unsigned long pc = regs->nip ^ (swiz & 4); 289 unsigned long pc = regs->nip ^ (swiz & 4);
290 290
291 if (__get_user(instr, (unsigned int __user *)pc)) 291 if (__get_user_inatomic(instr,
292 (unsigned int __user *)pc))
292 return -EFAULT; 293 return -EFAULT;
293 if (swiz == 0 && (flags & SW)) 294 if (swiz == 0 && (flags & SW))
294 instr = cpu_to_le32(instr); 295 instr = cpu_to_le32(instr);
@@ -324,27 +325,31 @@ static int emulate_multiple(struct pt_regs *regs, unsigned char __user *addr,
324 ((nb0 + 3) / 4) * sizeof(unsigned long)); 325 ((nb0 + 3) / 4) * sizeof(unsigned long));
325 326
326 for (i = 0; i < nb; ++i, ++p) 327 for (i = 0; i < nb; ++i, ++p)
327 if (__get_user(REG_BYTE(rptr, i ^ bswiz), SWIZ_PTR(p))) 328 if (__get_user_inatomic(REG_BYTE(rptr, i ^ bswiz),
329 SWIZ_PTR(p)))
328 return -EFAULT; 330 return -EFAULT;
329 if (nb0 > 0) { 331 if (nb0 > 0) {
330 rptr = &regs->gpr[0]; 332 rptr = &regs->gpr[0];
331 addr += nb; 333 addr += nb;
332 for (i = 0; i < nb0; ++i, ++p) 334 for (i = 0; i < nb0; ++i, ++p)
333 if (__get_user(REG_BYTE(rptr, i ^ bswiz), 335 if (__get_user_inatomic(REG_BYTE(rptr,
334 SWIZ_PTR(p))) 336 i ^ bswiz),
337 SWIZ_PTR(p)))
335 return -EFAULT; 338 return -EFAULT;
336 } 339 }
337 340
338 } else { 341 } else {
339 for (i = 0; i < nb; ++i, ++p) 342 for (i = 0; i < nb; ++i, ++p)
340 if (__put_user(REG_BYTE(rptr, i ^ bswiz), SWIZ_PTR(p))) 343 if (__put_user_inatomic(REG_BYTE(rptr, i ^ bswiz),
344 SWIZ_PTR(p)))
341 return -EFAULT; 345 return -EFAULT;
342 if (nb0 > 0) { 346 if (nb0 > 0) {
343 rptr = &regs->gpr[0]; 347 rptr = &regs->gpr[0];
344 addr += nb; 348 addr += nb;
345 for (i = 0; i < nb0; ++i, ++p) 349 for (i = 0; i < nb0; ++i, ++p)
346 if (__put_user(REG_BYTE(rptr, i ^ bswiz), 350 if (__put_user_inatomic(REG_BYTE(rptr,
347 SWIZ_PTR(p))) 351 i ^ bswiz),
352 SWIZ_PTR(p)))
348 return -EFAULT; 353 return -EFAULT;
349 } 354 }
350 } 355 }
@@ -398,7 +403,8 @@ int fix_alignment(struct pt_regs *regs)
398 403
399 if (cpu_has_feature(CPU_FTR_PPC_LE) && (regs->msr & MSR_LE)) 404 if (cpu_has_feature(CPU_FTR_PPC_LE) && (regs->msr & MSR_LE))
400 pc ^= 4; 405 pc ^= 4;
401 if (unlikely(__get_user(instr, (unsigned int __user *)pc))) 406 if (unlikely(__get_user_inatomic(instr,
407 (unsigned int __user *)pc)))
402 return -EFAULT; 408 return -EFAULT;
403 if (cpu_has_feature(CPU_FTR_REAL_LE) && (regs->msr & MSR_LE)) 409 if (cpu_has_feature(CPU_FTR_REAL_LE) && (regs->msr & MSR_LE))
404 instr = cpu_to_le32(instr); 410 instr = cpu_to_le32(instr);
@@ -474,16 +480,16 @@ int fix_alignment(struct pt_regs *regs)
474 p = (unsigned long) addr; 480 p = (unsigned long) addr;
475 switch (nb) { 481 switch (nb) {
476 case 8: 482 case 8:
477 ret |= __get_user(data.v[0], SWIZ_PTR(p++)); 483 ret |= __get_user_inatomic(data.v[0], SWIZ_PTR(p++));
478 ret |= __get_user(data.v[1], SWIZ_PTR(p++)); 484 ret |= __get_user_inatomic(data.v[1], SWIZ_PTR(p++));
479 ret |= __get_user(data.v[2], SWIZ_PTR(p++)); 485 ret |= __get_user_inatomic(data.v[2], SWIZ_PTR(p++));
480 ret |= __get_user(data.v[3], SWIZ_PTR(p++)); 486 ret |= __get_user_inatomic(data.v[3], SWIZ_PTR(p++));
481 case 4: 487 case 4:
482 ret |= __get_user(data.v[4], SWIZ_PTR(p++)); 488 ret |= __get_user_inatomic(data.v[4], SWIZ_PTR(p++));
483 ret |= __get_user(data.v[5], SWIZ_PTR(p++)); 489 ret |= __get_user_inatomic(data.v[5], SWIZ_PTR(p++));
484 case 2: 490 case 2:
485 ret |= __get_user(data.v[6], SWIZ_PTR(p++)); 491 ret |= __get_user_inatomic(data.v[6], SWIZ_PTR(p++));
486 ret |= __get_user(data.v[7], SWIZ_PTR(p++)); 492 ret |= __get_user_inatomic(data.v[7], SWIZ_PTR(p++));
487 if (unlikely(ret)) 493 if (unlikely(ret))
488 return -EFAULT; 494 return -EFAULT;
489 } 495 }
@@ -551,16 +557,16 @@ int fix_alignment(struct pt_regs *regs)
551 p = (unsigned long) addr; 557 p = (unsigned long) addr;
552 switch (nb) { 558 switch (nb) {
553 case 8: 559 case 8:
554 ret |= __put_user(data.v[0], SWIZ_PTR(p++)); 560 ret |= __put_user_inatomic(data.v[0], SWIZ_PTR(p++));
555 ret |= __put_user(data.v[1], SWIZ_PTR(p++)); 561 ret |= __put_user_inatomic(data.v[1], SWIZ_PTR(p++));
556 ret |= __put_user(data.v[2], SWIZ_PTR(p++)); 562 ret |= __put_user_inatomic(data.v[2], SWIZ_PTR(p++));
557 ret |= __put_user(data.v[3], SWIZ_PTR(p++)); 563 ret |= __put_user_inatomic(data.v[3], SWIZ_PTR(p++));
558 case 4: 564 case 4:
559 ret |= __put_user(data.v[4], SWIZ_PTR(p++)); 565 ret |= __put_user_inatomic(data.v[4], SWIZ_PTR(p++));
560 ret |= __put_user(data.v[5], SWIZ_PTR(p++)); 566 ret |= __put_user_inatomic(data.v[5], SWIZ_PTR(p++));
561 case 2: 567 case 2:
562 ret |= __put_user(data.v[6], SWIZ_PTR(p++)); 568 ret |= __put_user_inatomic(data.v[6], SWIZ_PTR(p++));
563 ret |= __put_user(data.v[7], SWIZ_PTR(p++)); 569 ret |= __put_user_inatomic(data.v[7], SWIZ_PTR(p++));
564 } 570 }
565 if (unlikely(ret)) 571 if (unlikely(ret))
566 return -EFAULT; 572 return -EFAULT;
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 030d300cd71c..0c5150c69175 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -77,7 +77,6 @@ int main(void)
77 DEFINE(KSP_VSID, offsetof(struct thread_struct, ksp_vsid)); 77 DEFINE(KSP_VSID, offsetof(struct thread_struct, ksp_vsid));
78#else /* CONFIG_PPC64 */ 78#else /* CONFIG_PPC64 */
79 DEFINE(PGDIR, offsetof(struct thread_struct, pgdir)); 79 DEFINE(PGDIR, offsetof(struct thread_struct, pgdir));
80 DEFINE(LAST_SYSCALL, offsetof(struct thread_struct, last_syscall));
81#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE) 80#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
82 DEFINE(THREAD_DBCR0, offsetof(struct thread_struct, dbcr0)); 81 DEFINE(THREAD_DBCR0, offsetof(struct thread_struct, dbcr0));
83 DEFINE(PT_PTRACED, PT_PTRACED); 82 DEFINE(PT_PTRACED, PT_PTRACED);
@@ -140,6 +139,7 @@ int main(void)
140 DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time)); 139 DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time));
141 DEFINE(PACA_SLBSHADOWPTR, offsetof(struct paca_struct, slb_shadow_ptr)); 140 DEFINE(PACA_SLBSHADOWPTR, offsetof(struct paca_struct, slb_shadow_ptr));
142 DEFINE(PACA_DATA_OFFSET, offsetof(struct paca_struct, data_offset)); 141 DEFINE(PACA_DATA_OFFSET, offsetof(struct paca_struct, data_offset));
142 DEFINE(PACA_TRAP_SAVE, offsetof(struct paca_struct, trap_save));
143 143
144 DEFINE(SLBSHADOW_STACKVSID, 144 DEFINE(SLBSHADOW_STACKVSID,
145 offsetof(struct slb_shadow, save_area[SLB_NUM_BOLTED - 1].vsid)); 145 offsetof(struct slb_shadow, save_area[SLB_NUM_BOLTED - 1].vsid));
diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c
index 3678997339d6..e7b684689e04 100644
--- a/arch/powerpc/kernel/btext.c
+++ b/arch/powerpc/kernel/btext.c
@@ -161,33 +161,33 @@ int btext_initialize(struct device_node *np)
161 unsigned long address = 0; 161 unsigned long address = 0;
162 const u32 *prop; 162 const u32 *prop;
163 163
164 prop = get_property(np, "linux,bootx-width", NULL); 164 prop = of_get_property(np, "linux,bootx-width", NULL);
165 if (prop == NULL) 165 if (prop == NULL)
166 prop = get_property(np, "width", NULL); 166 prop = of_get_property(np, "width", NULL);
167 if (prop == NULL) 167 if (prop == NULL)
168 return -EINVAL; 168 return -EINVAL;
169 width = *prop; 169 width = *prop;
170 prop = get_property(np, "linux,bootx-height", NULL); 170 prop = of_get_property(np, "linux,bootx-height", NULL);
171 if (prop == NULL) 171 if (prop == NULL)
172 prop = get_property(np, "height", NULL); 172 prop = of_get_property(np, "height", NULL);
173 if (prop == NULL) 173 if (prop == NULL)
174 return -EINVAL; 174 return -EINVAL;
175 height = *prop; 175 height = *prop;
176 prop = get_property(np, "linux,bootx-depth", NULL); 176 prop = of_get_property(np, "linux,bootx-depth", NULL);
177 if (prop == NULL) 177 if (prop == NULL)
178 prop = get_property(np, "depth", NULL); 178 prop = of_get_property(np, "depth", NULL);
179 if (prop == NULL) 179 if (prop == NULL)
180 return -EINVAL; 180 return -EINVAL;
181 depth = *prop; 181 depth = *prop;
182 pitch = width * ((depth + 7) / 8); 182 pitch = width * ((depth + 7) / 8);
183 prop = get_property(np, "linux,bootx-linebytes", NULL); 183 prop = of_get_property(np, "linux,bootx-linebytes", NULL);
184 if (prop == NULL) 184 if (prop == NULL)
185 prop = get_property(np, "linebytes", NULL); 185 prop = of_get_property(np, "linebytes", NULL);
186 if (prop && *prop != 0xffffffffu) 186 if (prop && *prop != 0xffffffffu)
187 pitch = *prop; 187 pitch = *prop;
188 if (pitch == 1) 188 if (pitch == 1)
189 pitch = 0x1000; 189 pitch = 0x1000;
190 prop = get_property(np, "address", NULL); 190 prop = of_get_property(np, "address", NULL);
191 if (prop) 191 if (prop)
192 address = *prop; 192 address = *prop;
193 193
@@ -219,7 +219,7 @@ int __init btext_find_display(int allow_nonstdout)
219 struct device_node *np = NULL; 219 struct device_node *np = NULL;
220 int rc = -ENODEV; 220 int rc = -ENODEV;
221 221
222 name = get_property(of_chosen, "linux,stdout-path", NULL); 222 name = of_get_property(of_chosen, "linux,stdout-path", NULL);
223 if (name != NULL) { 223 if (name != NULL) {
224 np = of_find_node_by_path(name); 224 np = of_find_node_by_path(name);
225 if (np != NULL) { 225 if (np != NULL) {
@@ -236,7 +236,7 @@ int __init btext_find_display(int allow_nonstdout)
236 return rc; 236 return rc;
237 237
238 for (np = NULL; (np = of_find_node_by_type(np, "display"));) { 238 for (np = NULL; (np = of_find_node_by_type(np, "display"));) {
239 if (get_property(np, "linux,opened", NULL)) { 239 if (of_get_property(np, "linux,opened", NULL)) {
240 printk("trying %s ...\n", np->full_name); 240 printk("trying %s ...\n", np->full_name);
241 rc = btext_initialize(np); 241 rc = btext_initialize(np);
242 printk("result: %d\n", rc); 242 printk("result: %d\n", rc);
diff --git a/arch/powerpc/kernel/cpu_setup_pa6t.S b/arch/powerpc/kernel/cpu_setup_pa6t.S
index 4047be25c4d2..d62cb9cae4e9 100644
--- a/arch/powerpc/kernel/cpu_setup_pa6t.S
+++ b/arch/powerpc/kernel/cpu_setup_pa6t.S
@@ -34,7 +34,7 @@ _GLOBAL(__setup_cpu_pa6t)
34 beqlr 34 beqlr
35 35
36 mfspr r0,SPRN_HID5 36 mfspr r0,SPRN_HID5
37 ori r0,r0,0x30 37 ori r0,r0,0x38
38 mtspr SPRN_HID5,r0 38 mtspr SPRN_HID5,r0
39 39
40 mfspr r0,SPRN_LPCR 40 mfspr r0,SPRN_LPCR
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index e4006dc087ca..9cb24d20f0f9 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -389,6 +389,8 @@ static struct cpu_spec cpu_specs[] = {
389 .pmc_type = PPC_PMC_PA6T, 389 .pmc_type = PPC_PMC_PA6T,
390 .cpu_setup = __setup_cpu_pa6t, 390 .cpu_setup = __setup_cpu_pa6t,
391 .cpu_restore = __restore_cpu_pa6t, 391 .cpu_restore = __restore_cpu_pa6t,
392 .oprofile_cpu_type = "ppc64/pa6t",
393 .oprofile_type = PPC_OPROFILE_PA6T,
392 .platform = "pa6t", 394 .platform = "pa6t",
393 }, 395 },
394 { /* default match */ 396 { /* default match */
@@ -558,6 +560,18 @@ static struct cpu_spec cpu_specs[] = {
558 .cpu_setup = __setup_cpu_750cx, 560 .cpu_setup = __setup_cpu_750cx,
559 .platform = "ppc750", 561 .platform = "ppc750",
560 }, 562 },
563 { /* 750CL */
564 .pvr_mask = 0xfffff0f0,
565 .pvr_value = 0x00087010,
566 .cpu_name = "750CL",
567 .cpu_features = CPU_FTRS_750CL,
568 .cpu_user_features = COMMON_USER | PPC_FEATURE_PPC_LE,
569 .icache_bsize = 32,
570 .dcache_bsize = 32,
571 .num_pmcs = 4,
572 .cpu_setup = __setup_cpu_750,
573 .platform = "ppc750",
574 },
561 { /* 745/755 */ 575 { /* 745/755 */
562 .pvr_mask = 0xfffff000, 576 .pvr_mask = 0xfffff000,
563 .pvr_value = 0x00083000, 577 .pvr_value = 0x00083000,
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index c03e829fee3c..c29d1652a421 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -191,7 +191,6 @@ stack_ovf:
1910: 1910:
192 192
193_GLOBAL(DoSyscall) 193_GLOBAL(DoSyscall)
194 stw r0,THREAD+LAST_SYSCALL(r2)
195 stw r3,ORIG_GPR3(r1) 194 stw r3,ORIG_GPR3(r1)
196 li r12,0 195 li r12,0
197 stw r12,RESULT(r1) 196 stw r12,RESULT(r1)
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 97cedcd6c9b4..1111fcec7673 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -278,8 +278,12 @@ exception_marker:
278 beq- 1f; \ 278 beq- 1f; \
279 ld r1,PACAKSAVE(r13); /* kernel stack to use */ \ 279 ld r1,PACAKSAVE(r13); /* kernel stack to use */ \
2801: cmpdi cr1,r1,0; /* check if r1 is in userspace */ \ 2801: cmpdi cr1,r1,0; /* check if r1 is in userspace */ \
281 bge- cr1,bad_stack; /* abort if it is */ \ 281 bge- cr1,2f; /* abort if it is */ \
282 std r9,_CCR(r1); /* save CR in stackframe */ \ 282 b 3f; \
2832: li r1,(n); /* will be reloaded later */ \
284 sth r1,PACA_TRAP_SAVE(r13); \
285 b bad_stack; \
2863: std r9,_CCR(r1); /* save CR in stackframe */ \
283 std r11,_NIP(r1); /* save SRR0 in stackframe */ \ 287 std r11,_NIP(r1); /* save SRR0 in stackframe */ \
284 std r12,_MSR(r1); /* save SRR1 in stackframe */ \ 288 std r12,_MSR(r1); /* save SRR1 in stackframe */ \
285 std r10,0(r1); /* make stack chain pointer */ \ 289 std r10,0(r1); /* make stack chain pointer */ \
@@ -940,6 +944,8 @@ bad_stack:
940 SAVE_2GPRS(7,r1) 944 SAVE_2GPRS(7,r1)
941 SAVE_10GPRS(12,r1) 945 SAVE_10GPRS(12,r1)
942 SAVE_10GPRS(22,r1) 946 SAVE_10GPRS(22,r1)
947 lhz r12,PACA_TRAP_SAVE(r13)
948 std r12,_TRAP(r1)
943 addi r11,r1,INT_FRAME_SIZE 949 addi r11,r1,INT_FRAME_SIZE
944 std r11,0(r1) 950 std r11,0(r1)
945 li r12,0 951 li r12,0
@@ -1555,7 +1561,6 @@ _GLOBAL(generic_secondary_smp_init)
1555 1561
1556 /* turn on 64-bit mode */ 1562 /* turn on 64-bit mode */
1557 bl .enable_64b_mode 1563 bl .enable_64b_mode
1558 isync
1559 1564
1560 /* Set up a paca value for this processor. Since we have the 1565 /* Set up a paca value for this processor. Since we have the
1561 * physical cpu id in r24, we need to search the pacas to find 1566 * physical cpu id in r24, we need to search the pacas to find
@@ -1735,10 +1740,6 @@ _STATIC(__boot_from_prom)
1735 /* We never return */ 1740 /* We never return */
1736 trap 1741 trap
1737 1742
1738/*
1739 * At this point, r3 contains the physical address we are running at,
1740 * returned by prom_init()
1741 */
1742_STATIC(__after_prom_start) 1743_STATIC(__after_prom_start)
1743 1744
1744/* 1745/*
@@ -1851,7 +1852,6 @@ __secondary_start_pmac_0:
1851_GLOBAL(pmac_secondary_start) 1852_GLOBAL(pmac_secondary_start)
1852 /* turn on 64-bit mode */ 1853 /* turn on 64-bit mode */
1853 bl .enable_64b_mode 1854 bl .enable_64b_mode
1854 isync
1855 1855
1856 /* Copy some CPU settings from CPU 0 */ 1856 /* Copy some CPU settings from CPU 0 */
1857 bl .__restore_cpu_ppc970 1857 bl .__restore_cpu_ppc970
diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index 82bd2f10770f..9a8c9af43b22 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -2,36 +2,37 @@
2 * IBM PowerPC IBM eBus Infrastructure Support. 2 * IBM PowerPC IBM eBus Infrastructure Support.
3 * 3 *
4 * Copyright (c) 2005 IBM Corporation 4 * Copyright (c) 2005 IBM Corporation
5 * Joachim Fenkes <fenkes@de.ibm.com>
5 * Heiko J Schick <schickhj@de.ibm.com> 6 * Heiko J Schick <schickhj@de.ibm.com>
6 * 7 *
7 * All rights reserved. 8 * All rights reserved.
8 * 9 *
9 * This source code is distributed under a dual license of GPL v2.0 and OpenIB 10 * This source code is distributed under a dual license of GPL v2.0 and OpenIB
10 * BSD. 11 * BSD.
11 * 12 *
12 * OpenIB BSD License 13 * OpenIB BSD License
13 * 14 *
14 * Redistribution and use in source and binary forms, with or without 15 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are met: 16 * modification, are permitted provided that the following conditions are met:
16 * 17 *
17 * Redistributions of source code must retain the above copyright notice, this 18 * Redistributions of source code must retain the above copyright notice, this
18 * list of conditions and the following disclaimer. 19 * list of conditions and the following disclaimer.
19 * 20 *
20 * Redistributions in binary form must reproduce the above copyright notice, 21 * Redistributions in binary form must reproduce the above copyright notice,
21 * this list of conditions and the following disclaimer in the documentation 22 * this list of conditions and the following disclaimer in the documentation
22 * and/or other materials 23 * and/or other materials
23 * provided with the distribution. 24 * provided with the distribution.
24 * 25 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
32 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 33 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
33 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE. 36 * POSSIBILITY OF SUCH DAMAGE.
36 */ 37 */
37 38
@@ -43,19 +44,19 @@
43#include <asm/ibmebus.h> 44#include <asm/ibmebus.h>
44#include <asm/abs_addr.h> 45#include <asm/abs_addr.h>
45 46
46static struct ibmebus_dev ibmebus_bus_device = { /* fake "parent" device */ 47static struct device ibmebus_bus_device = { /* fake "parent" device */
47 .name = ibmebus_bus_device.ofdev.dev.bus_id, 48 .bus_id = "ibmebus",
48 .ofdev.dev.bus_id = "ibmebus",
49 .ofdev.dev.bus = &ibmebus_bus_type,
50}; 49};
51 50
51struct bus_type ibmebus_bus_type;
52
52static void *ibmebus_alloc_coherent(struct device *dev, 53static void *ibmebus_alloc_coherent(struct device *dev,
53 size_t size, 54 size_t size,
54 dma_addr_t *dma_handle, 55 dma_addr_t *dma_handle,
55 gfp_t flag) 56 gfp_t flag)
56{ 57{
57 void *mem; 58 void *mem;
58 59
59 mem = kmalloc(size, flag); 60 mem = kmalloc(size, flag);
60 *dma_handle = (dma_addr_t)mem; 61 *dma_handle = (dma_addr_t)mem;
61 62
@@ -63,7 +64,7 @@ static void *ibmebus_alloc_coherent(struct device *dev,
63} 64}
64 65
65static void ibmebus_free_coherent(struct device *dev, 66static void ibmebus_free_coherent(struct device *dev,
66 size_t size, void *vaddr, 67 size_t size, void *vaddr,
67 dma_addr_t dma_handle) 68 dma_addr_t dma_handle)
68{ 69{
69 kfree(vaddr); 70 kfree(vaddr);
@@ -79,7 +80,7 @@ static dma_addr_t ibmebus_map_single(struct device *dev,
79 80
80static void ibmebus_unmap_single(struct device *dev, 81static void ibmebus_unmap_single(struct device *dev,
81 dma_addr_t dma_addr, 82 dma_addr_t dma_addr,
82 size_t size, 83 size_t size,
83 enum dma_data_direction direction) 84 enum dma_data_direction direction)
84{ 85{
85 return; 86 return;
@@ -90,13 +91,13 @@ static int ibmebus_map_sg(struct device *dev,
90 int nents, enum dma_data_direction direction) 91 int nents, enum dma_data_direction direction)
91{ 92{
92 int i; 93 int i;
93 94
94 for (i = 0; i < nents; i++) { 95 for (i = 0; i < nents; i++) {
95 sg[i].dma_address = (dma_addr_t)page_address(sg[i].page) 96 sg[i].dma_address = (dma_addr_t)page_address(sg[i].page)
96 + sg[i].offset; 97 + sg[i].offset;
97 sg[i].dma_length = sg[i].length; 98 sg[i].dma_length = sg[i].length;
98 } 99 }
99 100
100 return nents; 101 return nents;
101} 102}
102 103
@@ -128,15 +129,15 @@ static int ibmebus_bus_probe(struct device *dev)
128 struct ibmebus_driver *ibmebusdrv = to_ibmebus_driver(dev->driver); 129 struct ibmebus_driver *ibmebusdrv = to_ibmebus_driver(dev->driver);
129 const struct of_device_id *id; 130 const struct of_device_id *id;
130 int error = -ENODEV; 131 int error = -ENODEV;
131 132
132 if (!ibmebusdrv->probe) 133 if (!ibmebusdrv->probe)
133 return error; 134 return error;
134 135
135 id = of_match_device(ibmebusdrv->id_table, &ibmebusdev->ofdev); 136 id = of_match_device(ibmebusdrv->id_table, &ibmebusdev->ofdev);
136 if (id) { 137 if (id) {
137 error = ibmebusdrv->probe(ibmebusdev, id); 138 error = ibmebusdrv->probe(ibmebusdev, id);
138 } 139 }
139 140
140 return error; 141 return error;
141} 142}
142 143
@@ -144,11 +145,11 @@ static int ibmebus_bus_remove(struct device *dev)
144{ 145{
145 struct ibmebus_dev *ibmebusdev = to_ibmebus_dev(dev); 146 struct ibmebus_dev *ibmebusdev = to_ibmebus_dev(dev);
146 struct ibmebus_driver *ibmebusdrv = to_ibmebus_driver(dev->driver); 147 struct ibmebus_driver *ibmebusdrv = to_ibmebus_driver(dev->driver);
147 148
148 if (ibmebusdrv->remove) { 149 if (ibmebusdrv->remove) {
149 return ibmebusdrv->remove(ibmebusdev); 150 return ibmebusdrv->remove(ibmebusdev);
150 } 151 }
151 152
152 return 0; 153 return 0;
153} 154}
154 155
@@ -158,21 +159,12 @@ static void __devinit ibmebus_dev_release(struct device *dev)
158 kfree(to_ibmebus_dev(dev)); 159 kfree(to_ibmebus_dev(dev));
159} 160}
160 161
161static ssize_t ibmebusdev_show_name(struct device *dev, 162static int __devinit ibmebus_register_device_common(
162 struct device_attribute *attr, char *buf)
163{
164 return sprintf(buf, "%s\n", to_ibmebus_dev(dev)->name);
165}
166static DEVICE_ATTR(name, S_IRUSR | S_IRGRP | S_IROTH, ibmebusdev_show_name,
167 NULL);
168
169static struct ibmebus_dev* __devinit ibmebus_register_device_common(
170 struct ibmebus_dev *dev, const char *name) 163 struct ibmebus_dev *dev, const char *name)
171{ 164{
172 int err = 0; 165 int err = 0;
173 166
174 dev->name = name; 167 dev->ofdev.dev.parent = &ibmebus_bus_device;
175 dev->ofdev.dev.parent = &ibmebus_bus_device.ofdev.dev;
176 dev->ofdev.dev.bus = &ibmebus_bus_type; 168 dev->ofdev.dev.bus = &ibmebus_bus_type;
177 dev->ofdev.dev.release = ibmebus_dev_release; 169 dev->ofdev.dev.release = ibmebus_dev_release;
178 170
@@ -181,17 +173,15 @@ static struct ibmebus_dev* __devinit ibmebus_register_device_common(
181 dev->ofdev.dev.archdata.numa_node = of_node_to_nid(dev->ofdev.node); 173 dev->ofdev.dev.archdata.numa_node = of_node_to_nid(dev->ofdev.node);
182 174
183 /* An ibmebusdev is based on a of_device. We have to change the 175 /* An ibmebusdev is based on a of_device. We have to change the
184 * bus type to use our own DMA mapping operations. 176 * bus type to use our own DMA mapping operations.
185 */ 177 */
186 if ((err = of_device_register(&dev->ofdev)) != 0) { 178 if ((err = of_device_register(&dev->ofdev)) != 0) {
187 printk(KERN_ERR "%s: failed to register device (%d).\n", 179 printk(KERN_ERR "%s: failed to register device (%d).\n",
188 __FUNCTION__, err); 180 __FUNCTION__, err);
189 return NULL; 181 return -ENODEV;
190 } 182 }
191 183
192 device_create_file(&dev->ofdev.dev, &dev_attr_name); 184 return 0;
193
194 return dev;
195} 185}
196 186
197static struct ibmebus_dev* __devinit ibmebus_register_device_node( 187static struct ibmebus_dev* __devinit ibmebus_register_device_node(
@@ -201,35 +191,35 @@ static struct ibmebus_dev* __devinit ibmebus_register_device_node(
201 const char *loc_code; 191 const char *loc_code;
202 int length; 192 int length;
203 193
204 loc_code = get_property(dn, "ibm,loc-code", NULL); 194 loc_code = of_get_property(dn, "ibm,loc-code", NULL);
205 if (!loc_code) { 195 if (!loc_code) {
206 printk(KERN_WARNING "%s: node %s missing 'ibm,loc-code'\n", 196 printk(KERN_WARNING "%s: node %s missing 'ibm,loc-code'\n",
207 __FUNCTION__, dn->name ? dn->name : "<unknown>"); 197 __FUNCTION__, dn->name ? dn->name : "<unknown>");
208 return NULL; 198 return ERR_PTR(-EINVAL);
209 } 199 }
210 200
211 if (strlen(loc_code) == 0) { 201 if (strlen(loc_code) == 0) {
212 printk(KERN_WARNING "%s: 'ibm,loc-code' is invalid\n", 202 printk(KERN_WARNING "%s: 'ibm,loc-code' is invalid\n",
213 __FUNCTION__); 203 __FUNCTION__);
214 return NULL; 204 return ERR_PTR(-EINVAL);
215 } 205 }
216 206
217 dev = kzalloc(sizeof(struct ibmebus_dev), GFP_KERNEL); 207 dev = kzalloc(sizeof(struct ibmebus_dev), GFP_KERNEL);
218 if (!dev) { 208 if (!dev) {
219 return NULL; 209 return ERR_PTR(-ENOMEM);
220 } 210 }
221 211
222 dev->ofdev.node = of_node_get(dn); 212 dev->ofdev.node = of_node_get(dn);
223 213
224 length = strlen(loc_code); 214 length = strlen(loc_code);
225 memcpy(dev->ofdev.dev.bus_id, loc_code 215 memcpy(dev->ofdev.dev.bus_id, loc_code
226 + (length - min(length, BUS_ID_SIZE - 1)), 216 + (length - min(length, BUS_ID_SIZE - 1)),
227 min(length, BUS_ID_SIZE - 1)); 217 min(length, BUS_ID_SIZE - 1));
228 218
229 /* Register with generic device framework. */ 219 /* Register with generic device framework. */
230 if (ibmebus_register_device_common(dev, dn->name) == NULL) { 220 if (ibmebus_register_device_common(dev, dn->name) != 0) {
231 kfree(dev); 221 kfree(dev);
232 return NULL; 222 return ERR_PTR(-ENODEV);
233 } 223 }
234 224
235 return dev; 225 return dev;
@@ -238,17 +228,16 @@ static struct ibmebus_dev* __devinit ibmebus_register_device_node(
238static void ibmebus_probe_of_nodes(char* name) 228static void ibmebus_probe_of_nodes(char* name)
239{ 229{
240 struct device_node *dn = NULL; 230 struct device_node *dn = NULL;
241 231
242 while ((dn = of_find_node_by_name(dn, name))) { 232 while ((dn = of_find_node_by_name(dn, name))) {
243 if (ibmebus_register_device_node(dn) == NULL) { 233 if (IS_ERR(ibmebus_register_device_node(dn))) {
244 of_node_put(dn); 234 of_node_put(dn);
245
246 return; 235 return;
247 } 236 }
248 } 237 }
249 238
250 of_node_put(dn); 239 of_node_put(dn);
251 240
252 return; 241 return;
253} 242}
254 243
@@ -262,17 +251,21 @@ static void ibmebus_add_devices_by_id(struct of_device_id *idt)
262 return; 251 return;
263} 252}
264 253
265static int ibmebus_match_helper(struct device *dev, void *data) 254static int ibmebus_match_name(struct device *dev, void *data)
266{ 255{
267 if (strcmp((char*)data, to_ibmebus_dev(dev)->name) == 0) 256 const struct ibmebus_dev *ebus_dev = to_ibmebus_dev(dev);
257 const char *name;
258
259 name = of_get_property(ebus_dev->ofdev.node, "name", NULL);
260
261 if (name && (strcmp(data, name) == 0))
268 return 1; 262 return 1;
269 263
270 return 0; 264 return 0;
271} 265}
272 266
273static int ibmebus_unregister_device(struct device *dev) 267static int ibmebus_unregister_device(struct device *dev)
274{ 268{
275 device_remove_file(dev, &dev_attr_name);
276 of_device_unregister(to_of_device(dev)); 269 of_device_unregister(to_of_device(dev));
277 270
278 return 0; 271 return 0;
@@ -281,17 +274,16 @@ static int ibmebus_unregister_device(struct device *dev)
281static void ibmebus_remove_devices_by_id(struct of_device_id *idt) 274static void ibmebus_remove_devices_by_id(struct of_device_id *idt)
282{ 275{
283 struct device *dev; 276 struct device *dev;
284 277
285 while (strlen(idt->name) > 0) { 278 while (strlen(idt->name) > 0) {
286 while ((dev = bus_find_device(&ibmebus_bus_type, NULL, 279 while ((dev = bus_find_device(&ibmebus_bus_type, NULL,
287 (void*)idt->name, 280 (void*)idt->name,
288 ibmebus_match_helper))) { 281 ibmebus_match_name))) {
289 ibmebus_unregister_device(dev); 282 ibmebus_unregister_device(dev);
290 } 283 }
291 idt++; 284 idt++;
292
293 } 285 }
294 286
295 return; 287 return;
296} 288}
297 289
@@ -307,30 +299,33 @@ int ibmebus_register_driver(struct ibmebus_driver *drv)
307 if ((err = driver_register(&drv->driver) != 0)) 299 if ((err = driver_register(&drv->driver) != 0))
308 return err; 300 return err;
309 301
302 /* remove all supported devices first, in case someone
303 * probed them manually before registering the driver */
304 ibmebus_remove_devices_by_id(drv->id_table);
310 ibmebus_add_devices_by_id(drv->id_table); 305 ibmebus_add_devices_by_id(drv->id_table);
311 306
312 return 0; 307 return 0;
313} 308}
314EXPORT_SYMBOL(ibmebus_register_driver); 309EXPORT_SYMBOL(ibmebus_register_driver);
315 310
316void ibmebus_unregister_driver(struct ibmebus_driver *drv) 311void ibmebus_unregister_driver(struct ibmebus_driver *drv)
317{ 312{
318 driver_unregister(&drv->driver); 313 driver_unregister(&drv->driver);
319 ibmebus_remove_devices_by_id(drv->id_table); 314 ibmebus_remove_devices_by_id(drv->id_table);
320} 315}
321EXPORT_SYMBOL(ibmebus_unregister_driver); 316EXPORT_SYMBOL(ibmebus_unregister_driver);
322 317
323int ibmebus_request_irq(struct ibmebus_dev *dev, 318int ibmebus_request_irq(struct ibmebus_dev *dev,
324 u32 ist, 319 u32 ist,
325 irq_handler_t handler, 320 irq_handler_t handler,
326 unsigned long irq_flags, const char * devname, 321 unsigned long irq_flags, const char * devname,
327 void *dev_id) 322 void *dev_id)
328{ 323{
329 unsigned int irq = irq_create_mapping(NULL, ist); 324 unsigned int irq = irq_create_mapping(NULL, ist);
330 325
331 if (irq == NO_IRQ) 326 if (irq == NO_IRQ)
332 return -EINVAL; 327 return -EINVAL;
333 328
334 return request_irq(irq, handler, 329 return request_irq(irq, handler,
335 irq_flags, devname, dev_id); 330 irq_flags, devname, dev_id);
336} 331}
@@ -339,56 +334,163 @@ EXPORT_SYMBOL(ibmebus_request_irq);
339void ibmebus_free_irq(struct ibmebus_dev *dev, u32 ist, void *dev_id) 334void ibmebus_free_irq(struct ibmebus_dev *dev, u32 ist, void *dev_id)
340{ 335{
341 unsigned int irq = irq_find_mapping(NULL, ist); 336 unsigned int irq = irq_find_mapping(NULL, ist);
342 337
343 free_irq(irq, dev_id); 338 free_irq(irq, dev_id);
344} 339}
345EXPORT_SYMBOL(ibmebus_free_irq); 340EXPORT_SYMBOL(ibmebus_free_irq);
346 341
347static int ibmebus_bus_match(struct device *dev, struct device_driver *drv) 342static int ibmebus_bus_match(struct device *dev, struct device_driver *drv)
348{ 343{
349 const struct ibmebus_dev *ebus_dev = to_ibmebus_dev(dev); 344 const struct ibmebus_dev *ebus_dev = to_ibmebus_dev(dev);
350 struct ibmebus_driver *ebus_drv = to_ibmebus_driver(drv); 345 struct ibmebus_driver *ebus_drv = to_ibmebus_driver(drv);
351 const struct of_device_id *ids = ebus_drv->id_table; 346 const struct of_device_id *ids = ebus_drv->id_table;
352 const struct of_device_id *found_id; 347 const struct of_device_id *found_id;
353 348
354 if (!ids) 349 if (!ids)
355 return 0; 350 return 0;
356 351
357 found_id = of_match_device(ids, &ebus_dev->ofdev); 352 found_id = of_match_device(ids, &ebus_dev->ofdev);
358 if (found_id) 353 if (found_id)
359 return 1; 354 return 1;
360 355
361 return 0; 356 return 0;
362} 357}
363 358
359static ssize_t name_show(struct device *dev,
360 struct device_attribute *attr, char *buf)
361{
362 struct ibmebus_dev *ebus_dev = to_ibmebus_dev(dev);
363 const char *name = of_get_property(ebus_dev->ofdev.node, "name", NULL);
364 return sprintf(buf, "%s\n", name);
365}
366
367static struct device_attribute ibmebus_dev_attrs[] = {
368 __ATTR_RO(name),
369 __ATTR_NULL
370};
371
372static int ibmebus_match_path(struct device *dev, void *data)
373{
374 int rc;
375 struct device_node *dn =
376 of_node_get(to_ibmebus_dev(dev)->ofdev.node);
377
378 rc = (dn->full_name && (strcasecmp((char*)data, dn->full_name) == 0));
379
380 of_node_put(dn);
381 return rc;
382}
383
384static char *ibmebus_chomp(const char *in, size_t count)
385{
386 char *out = (char*)kmalloc(count + 1, GFP_KERNEL);
387 if (!out)
388 return NULL;
389
390 memcpy(out, in, count);
391 out[count] = '\0';
392 if (out[count - 1] == '\n')
393 out[count - 1] = '\0';
394
395 return out;
396}
397
398static ssize_t ibmebus_store_probe(struct bus_type *bus,
399 const char *buf, size_t count)
400{
401 struct device_node *dn = NULL;
402 struct ibmebus_dev *dev;
403 char *path;
404 ssize_t rc;
405
406 path = ibmebus_chomp(buf, count);
407 if (!path)
408 return -ENOMEM;
409
410 if (bus_find_device(&ibmebus_bus_type, NULL, path,
411 ibmebus_match_path)) {
412 printk(KERN_WARNING "%s: %s has already been probed\n",
413 __FUNCTION__, path);
414 rc = -EINVAL;
415 goto out;
416 }
417
418 if ((dn = of_find_node_by_path(path))) {
419 dev = ibmebus_register_device_node(dn);
420 of_node_put(dn);
421 rc = IS_ERR(dev) ? PTR_ERR(dev) : count;
422 } else {
423 printk(KERN_WARNING "%s: no such device node: %s\n",
424 __FUNCTION__, path);
425 rc = -ENODEV;
426 }
427
428out:
429 kfree(path);
430 return rc;
431}
432
433static ssize_t ibmebus_store_remove(struct bus_type *bus,
434 const char *buf, size_t count)
435{
436 struct device *dev;
437 char *path;
438
439 path = ibmebus_chomp(buf, count);
440 if (!path)
441 return -ENOMEM;
442
443 if ((dev = bus_find_device(&ibmebus_bus_type, NULL, path,
444 ibmebus_match_path))) {
445 ibmebus_unregister_device(dev);
446
447 kfree(path);
448 return count;
449 } else {
450 printk(KERN_WARNING "%s: %s not on the bus\n",
451 __FUNCTION__, path);
452
453 kfree(path);
454 return -ENODEV;
455 }
456}
457
458static struct bus_attribute ibmebus_bus_attrs[] = {
459 __ATTR(probe, S_IWUSR, NULL, ibmebus_store_probe),
460 __ATTR(remove, S_IWUSR, NULL, ibmebus_store_remove),
461 __ATTR_NULL
462};
463
364struct bus_type ibmebus_bus_type = { 464struct bus_type ibmebus_bus_type = {
365 .name = "ibmebus", 465 .name = "ibmebus",
366 .match = ibmebus_bus_match, 466 .match = ibmebus_bus_match,
467 .dev_attrs = ibmebus_dev_attrs,
468 .bus_attrs = ibmebus_bus_attrs
367}; 469};
368EXPORT_SYMBOL(ibmebus_bus_type); 470EXPORT_SYMBOL(ibmebus_bus_type);
369 471
370static int __init ibmebus_bus_init(void) 472static int __init ibmebus_bus_init(void)
371{ 473{
372 int err; 474 int err;
373 475
374 printk(KERN_INFO "IBM eBus Device Driver\n"); 476 printk(KERN_INFO "IBM eBus Device Driver\n");
375 477
376 err = bus_register(&ibmebus_bus_type); 478 err = bus_register(&ibmebus_bus_type);
377 if (err) { 479 if (err) {
378 printk(KERN_ERR ":%s: failed to register IBM eBus.\n", 480 printk(KERN_ERR ":%s: failed to register IBM eBus.\n",
379 __FUNCTION__); 481 __FUNCTION__);
380 return err; 482 return err;
381 } 483 }
382 484
383 err = device_register(&ibmebus_bus_device.ofdev.dev); 485 err = device_register(&ibmebus_bus_device);
384 if (err) { 486 if (err) {
385 printk(KERN_WARNING "%s: device_register returned %i\n", 487 printk(KERN_WARNING "%s: device_register returned %i\n",
386 __FUNCTION__, err); 488 __FUNCTION__, err);
387 bus_unregister(&ibmebus_bus_type); 489 bus_unregister(&ibmebus_bus_type);
388 490
389 return err; 491 return err;
390 } 492 }
391 493
392 return 0; 494 return 0;
393} 495}
394__initcall(ibmebus_bus_init); 496__initcall(ibmebus_bus_init);
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index 95edad4faf26..c08ceca6277d 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -47,6 +47,8 @@ static int novmerge = 0;
47static int novmerge = 1; 47static int novmerge = 1;
48#endif 48#endif
49 49
50static int protect4gb = 1;
51
50static inline unsigned long iommu_num_pages(unsigned long vaddr, 52static inline unsigned long iommu_num_pages(unsigned long vaddr,
51 unsigned long slen) 53 unsigned long slen)
52{ 54{
@@ -58,6 +60,16 @@ static inline unsigned long iommu_num_pages(unsigned long vaddr,
58 return npages; 60 return npages;
59} 61}
60 62
63static int __init setup_protect4gb(char *str)
64{
65 if (strcmp(str, "on") == 0)
66 protect4gb = 1;
67 else if (strcmp(str, "off") == 0)
68 protect4gb = 0;
69
70 return 1;
71}
72
61static int __init setup_iommu(char *str) 73static int __init setup_iommu(char *str)
62{ 74{
63 if (!strcmp(str, "novmerge")) 75 if (!strcmp(str, "novmerge"))
@@ -67,6 +79,7 @@ static int __init setup_iommu(char *str)
67 return 1; 79 return 1;
68} 80}
69 81
82__setup("protect4gb=", setup_protect4gb);
70__setup("iommu=", setup_iommu); 83__setup("iommu=", setup_iommu);
71 84
72static unsigned long iommu_range_alloc(struct iommu_table *tbl, 85static unsigned long iommu_range_alloc(struct iommu_table *tbl,
@@ -429,6 +442,9 @@ void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
429struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid) 442struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
430{ 443{
431 unsigned long sz; 444 unsigned long sz;
445 unsigned long start_index, end_index;
446 unsigned long entries_per_4g;
447 unsigned long index;
432 static int welcomed = 0; 448 static int welcomed = 0;
433 struct page *page; 449 struct page *page;
434 450
@@ -450,7 +466,7 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
450 466
451#ifdef CONFIG_CRASH_DUMP 467#ifdef CONFIG_CRASH_DUMP
452 if (ppc_md.tce_get) { 468 if (ppc_md.tce_get) {
453 unsigned long index, tceval; 469 unsigned long tceval;
454 unsigned long tcecount = 0; 470 unsigned long tcecount = 0;
455 471
456 /* 472 /*
@@ -480,6 +496,23 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
480 ppc_md.tce_free(tbl, tbl->it_offset, tbl->it_size); 496 ppc_md.tce_free(tbl, tbl->it_offset, tbl->it_size);
481#endif 497#endif
482 498
499 /*
500 * DMA cannot cross 4 GB boundary. Mark last entry of each 4
501 * GB chunk as reserved.
502 */
503 if (protect4gb) {
504 entries_per_4g = 0x100000000l >> IOMMU_PAGE_SHIFT;
505
506 /* Mark the last bit before a 4GB boundary as used */
507 start_index = tbl->it_offset | (entries_per_4g - 1);
508 start_index -= tbl->it_offset;
509
510 end_index = tbl->it_size;
511
512 for (index = start_index; index < end_index - 1; index += entries_per_4g)
513 __set_bit(index, tbl->it_map);
514 }
515
483 if (!welcomed) { 516 if (!welcomed) {
484 printk(KERN_INFO "IOMMU table initialized, virtual merging %s\n", 517 printk(KERN_INFO "IOMMU table initialized, virtual merging %s\n",
485 novmerge ? "disabled" : "enabled"); 518 novmerge ? "disabled" : "enabled");
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 100930826850..6c83fe229e60 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -394,7 +394,7 @@ EXPORT_SYMBOL(do_softirq);
394#ifdef CONFIG_PPC_MERGE 394#ifdef CONFIG_PPC_MERGE
395 395
396static LIST_HEAD(irq_hosts); 396static LIST_HEAD(irq_hosts);
397static spinlock_t irq_big_lock = SPIN_LOCK_UNLOCKED; 397static DEFINE_SPINLOCK(irq_big_lock);
398static DEFINE_PER_CPU(unsigned int, irq_radix_reader); 398static DEFINE_PER_CPU(unsigned int, irq_radix_reader);
399static unsigned int irq_radix_writer; 399static unsigned int irq_radix_writer;
400struct irq_map_entry irq_map[NR_IRQS]; 400struct irq_map_entry irq_map[NR_IRQS];
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index dd2886f97e98..ef647e7a9dc3 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -59,12 +59,14 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
59 } 59 }
60 60
61 if (!ret) { 61 if (!ret) {
62 memcpy(p->ainsn.insn, p->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); 62 memcpy(p->ainsn.insn, p->addr,
63 MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
63 p->opcode = *p->addr; 64 p->opcode = *p->addr;
64 flush_icache_range((unsigned long)p->ainsn.insn, 65 flush_icache_range((unsigned long)p->ainsn.insn,
65 (unsigned long)p->ainsn.insn + sizeof(kprobe_opcode_t)); 66 (unsigned long)p->ainsn.insn + sizeof(kprobe_opcode_t));
66 } 67 }
67 68
69 p->ainsn.boostable = 0;
68 return ret; 70 return ret;
69} 71}
70 72
@@ -232,6 +234,38 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
232 return 1; 234 return 1;
233 235
234ss_probe: 236ss_probe:
237 if (p->ainsn.boostable >= 0) {
238 unsigned int insn = *p->ainsn.insn;
239
240 /* regs->nip is also adjusted if emulate_step returns 1 */
241 ret = emulate_step(regs, insn);
242 if (ret > 0) {
243 /*
244 * Once this instruction has been boosted
245 * successfully, set the boostable flag
246 */
247 if (unlikely(p->ainsn.boostable == 0))
248 p->ainsn.boostable = 1;
249
250 if (p->post_handler)
251 p->post_handler(p, regs, 0);
252
253 kcb->kprobe_status = KPROBE_HIT_SSDONE;
254 reset_current_kprobe();
255 preempt_enable_no_resched();
256 return 1;
257 } else if (ret < 0) {
258 /*
259 * We don't allow kprobes on mtmsr(d)/rfi(d), etc.
260 * So, we should never get here... but, its still
261 * good to catch them, just in case...
262 */
263 printk("Can't step on instruction %x\n", insn);
264 BUG();
265 } else if (ret == 0)
266 /* This instruction can't be boosted */
267 p->ainsn.boostable = -1;
268 }
235 prepare_singlestep(p, regs); 269 prepare_singlestep(p, regs);
236 kcb->kprobe_status = KPROBE_HIT_SS; 270 kcb->kprobe_status = KPROBE_HIT_SS;
237 return 1; 271 return 1;
diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index 325f490a10cc..63dd2c3ad95e 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -44,12 +44,12 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
44 int index; 44 int index;
45 45
46 /* get clock freq. if present */ 46 /* get clock freq. if present */
47 clk = get_property(np, "clock-frequency", NULL); 47 clk = of_get_property(np, "clock-frequency", NULL);
48 if (clk && *clk) 48 if (clk && *clk)
49 clock = *clk; 49 clock = *clk;
50 50
51 /* get default speed if present */ 51 /* get default speed if present */
52 spd = get_property(np, "current-speed", NULL); 52 spd = of_get_property(np, "current-speed", NULL);
53 53
54 /* If we have a location index, then try to use it */ 54 /* If we have a location index, then try to use it */
55 if (want_index >= 0 && want_index < MAX_LEGACY_SERIAL_PORTS) 55 if (want_index >= 0 && want_index < MAX_LEGACY_SERIAL_PORTS)
@@ -121,11 +121,11 @@ static int __init add_legacy_soc_port(struct device_node *np,
121 /* We only support ports that have a clock frequency properly 121 /* We only support ports that have a clock frequency properly
122 * encoded in the device-tree. 122 * encoded in the device-tree.
123 */ 123 */
124 if (get_property(np, "clock-frequency", NULL) == NULL) 124 if (of_get_property(np, "clock-frequency", NULL) == NULL)
125 return -1; 125 return -1;
126 126
127 /* if rtas uses this device, don't try to use it as well */ 127 /* if rtas uses this device, don't try to use it as well */
128 if (get_property(np, "used-by-rtas", NULL) != NULL) 128 if (of_get_property(np, "used-by-rtas", NULL) != NULL)
129 return -1; 129 return -1;
130 130
131 /* Get the address */ 131 /* Get the address */
@@ -157,7 +157,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
157 DBG(" -> add_legacy_isa_port(%s)\n", np->full_name); 157 DBG(" -> add_legacy_isa_port(%s)\n", np->full_name);
158 158
159 /* Get the ISA port number */ 159 /* Get the ISA port number */
160 reg = get_property(np, "reg", NULL); 160 reg = of_get_property(np, "reg", NULL);
161 if (reg == NULL) 161 if (reg == NULL)
162 return -1; 162 return -1;
163 163
@@ -168,7 +168,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
168 /* Now look for an "ibm,aix-loc" property that gives us ordering 168 /* Now look for an "ibm,aix-loc" property that gives us ordering
169 * if any... 169 * if any...
170 */ 170 */
171 typep = get_property(np, "ibm,aix-loc", NULL); 171 typep = of_get_property(np, "ibm,aix-loc", NULL);
172 172
173 /* If we have a location index, then use it */ 173 /* If we have a location index, then use it */
174 if (typep && *typep == 'S') 174 if (typep && *typep == 'S')
@@ -206,7 +206,7 @@ static int __init add_legacy_pci_port(struct device_node *np,
206 * compatible UARTs on PCI need all sort of quirks (port offsets 206 * compatible UARTs on PCI need all sort of quirks (port offsets
207 * etc...) that this code doesn't know about 207 * etc...) that this code doesn't know about
208 */ 208 */
209 if (get_property(np, "clock-frequency", NULL) == NULL) 209 if (of_get_property(np, "clock-frequency", NULL) == NULL)
210 return -1; 210 return -1;
211 211
212 /* Get the PCI address. Assume BAR 0 */ 212 /* Get the PCI address. Assume BAR 0 */
@@ -232,7 +232,7 @@ static int __init add_legacy_pci_port(struct device_node *np,
232 * we get to their "reg" property 232 * we get to their "reg" property
233 */ 233 */
234 if (np != pci_dev) { 234 if (np != pci_dev) {
235 const u32 *reg = get_property(np, "reg", NULL); 235 const u32 *reg = of_get_property(np, "reg", NULL);
236 if (reg && (*reg < 4)) 236 if (reg && (*reg < 4))
237 index = lindex = *reg; 237 index = lindex = *reg;
238 } 238 }
@@ -296,7 +296,7 @@ void __init find_legacy_serial_ports(void)
296 DBG(" -> find_legacy_serial_port()\n"); 296 DBG(" -> find_legacy_serial_port()\n");
297 297
298 /* Now find out if one of these is out firmware console */ 298 /* Now find out if one of these is out firmware console */
299 path = get_property(of_chosen, "linux,stdout-path", NULL); 299 path = of_get_property(of_chosen, "linux,stdout-path", NULL);
300 if (path != NULL) { 300 if (path != NULL) {
301 stdout = of_find_node_by_path(path); 301 stdout = of_find_node_by_path(path);
302 if (stdout) 302 if (stdout)
@@ -529,7 +529,7 @@ static int __init check_legacy_serial_console(void)
529 } 529 }
530 /* We are getting a weird phandle from OF ... */ 530 /* We are getting a weird phandle from OF ... */
531 /* ... So use the full path instead */ 531 /* ... So use the full path instead */
532 name = get_property(of_chosen, "linux,stdout-path", NULL); 532 name = of_get_property(of_chosen, "linux,stdout-path", NULL);
533 if (name == NULL) { 533 if (name == NULL) {
534 DBG(" no linux,stdout-path !\n"); 534 DBG(" no linux,stdout-path !\n");
535 return -ENODEV; 535 return -ENODEV;
@@ -541,12 +541,12 @@ static int __init check_legacy_serial_console(void)
541 } 541 }
542 DBG("stdout is %s\n", prom_stdout->full_name); 542 DBG("stdout is %s\n", prom_stdout->full_name);
543 543
544 name = get_property(prom_stdout, "name", NULL); 544 name = of_get_property(prom_stdout, "name", NULL);
545 if (!name) { 545 if (!name) {
546 DBG(" stdout package has no name !\n"); 546 DBG(" stdout package has no name !\n");
547 goto not_found; 547 goto not_found;
548 } 548 }
549 spd = get_property(prom_stdout, "current-speed", NULL); 549 spd = of_get_property(prom_stdout, "current-speed", NULL);
550 if (spd) 550 if (spd)
551 speed = *spd; 551 speed = *spd;
552 552
diff --git a/arch/powerpc/kernel/lparcfg.c b/arch/powerpc/kernel/lparcfg.c
index 89486b631284..c492cee90e0f 100644
--- a/arch/powerpc/kernel/lparcfg.c
+++ b/arch/powerpc/kernel/lparcfg.c
@@ -130,30 +130,31 @@ static int iseries_lparcfg_data(struct seq_file *m, void *v)
130/* 130/*
131 * Methods used to fetch LPAR data when running on a pSeries platform. 131 * Methods used to fetch LPAR data when running on a pSeries platform.
132 */ 132 */
133/* find a better place for this function... */
134static void log_plpar_hcall_return(unsigned long rc, char *tag) 133static void log_plpar_hcall_return(unsigned long rc, char *tag)
135{ 134{
136 if (rc == 0) /* success, return */ 135 switch(rc) {
136 case 0:
137 return; 137 return;
138/* check for null tag ? */ 138 case H_HARDWARE:
139 if (rc == H_HARDWARE) 139 printk(KERN_INFO "plpar-hcall (%s) "
140 printk(KERN_INFO 140 "Hardware fault\n", tag);
141 "plpar-hcall (%s) failed with hardware fault\n", tag); 141 return;
142 else if (rc == H_FUNCTION) 142 case H_FUNCTION:
143 printk(KERN_INFO 143 printk(KERN_INFO "plpar-hcall (%s) "
144 "plpar-hcall (%s) failed; function not allowed\n", tag); 144 "Function not allowed\n", tag);
145 else if (rc == H_AUTHORITY) 145 return;
146 printk(KERN_INFO 146 case H_AUTHORITY:
147 "plpar-hcall (%s) failed; not authorized to this" 147 printk(KERN_INFO "plpar-hcall (%s) "
148 " function\n", tag); 148 "Not authorized to this function\n", tag);
149 else if (rc == H_PARAMETER) 149 return;
150 printk(KERN_INFO "plpar-hcall (%s) failed; Bad parameter(s)\n", 150 case H_PARAMETER:
151 tag); 151 printk(KERN_INFO "plpar-hcall (%s) "
152 else 152 "Bad parameter(s)\n",tag);
153 printk(KERN_INFO 153 return;
154 "plpar-hcall (%s) failed with unexpected rc(0x%lx)\n", 154 default:
155 tag, rc); 155 printk(KERN_INFO "plpar-hcall (%s) "
156 156 "Unexpected rc(0x%lx)\n", tag, rc);
157 }
157} 158}
158 159
159/* 160/*
@@ -321,15 +322,16 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v)
321 struct device_node *rtas_node; 322 struct device_node *rtas_node;
322 const int *lrdrp = NULL; 323 const int *lrdrp = NULL;
323 324
324 rtas_node = find_path_device("/rtas"); 325 rtas_node = of_find_node_by_path("/rtas");
325 if (rtas_node) 326 if (rtas_node)
326 lrdrp = get_property(rtas_node, "ibm,lrdr-capacity", NULL); 327 lrdrp = of_get_property(rtas_node, "ibm,lrdr-capacity", NULL);
327 328
328 if (lrdrp == NULL) { 329 if (lrdrp == NULL) {
329 partition_potential_processors = vdso_data->processorCount; 330 partition_potential_processors = vdso_data->processorCount;
330 } else { 331 } else {
331 partition_potential_processors = *(lrdrp + 4); 332 partition_potential_processors = *(lrdrp + 4);
332 } 333 }
334 of_node_put(rtas_node);
333 335
334 partition_active_processors = lparcfg_count_active_processors(); 336 partition_active_processors = lparcfg_count_active_processors();
335 337
@@ -537,25 +539,27 @@ static int lparcfg_data(struct seq_file *m, void *v)
537 539
538 seq_printf(m, "%s %s \n", MODULE_NAME, MODULE_VERS); 540 seq_printf(m, "%s %s \n", MODULE_NAME, MODULE_VERS);
539 541
540 rootdn = find_path_device("/"); 542 rootdn = of_find_node_by_path("/");
541 if (rootdn) { 543 if (rootdn) {
542 tmp = get_property(rootdn, "model", NULL); 544 tmp = of_get_property(rootdn, "model", NULL);
543 if (tmp) { 545 if (tmp) {
544 model = tmp; 546 model = tmp;
545 /* Skip "IBM," - see platforms/iseries/dt.c */ 547 /* Skip "IBM," - see platforms/iseries/dt.c */
546 if (firmware_has_feature(FW_FEATURE_ISERIES)) 548 if (firmware_has_feature(FW_FEATURE_ISERIES))
547 model += 4; 549 model += 4;
548 } 550 }
549 tmp = get_property(rootdn, "system-id", NULL); 551 tmp = of_get_property(rootdn, "system-id", NULL);
550 if (tmp) { 552 if (tmp) {
551 system_id = tmp; 553 system_id = tmp;
552 /* Skip "IBM," - see platforms/iseries/dt.c */ 554 /* Skip "IBM," - see platforms/iseries/dt.c */
553 if (firmware_has_feature(FW_FEATURE_ISERIES)) 555 if (firmware_has_feature(FW_FEATURE_ISERIES))
554 system_id += 4; 556 system_id += 4;
555 } 557 }
556 lp_index_ptr = get_property(rootdn, "ibm,partition-no", NULL); 558 lp_index_ptr = of_get_property(rootdn, "ibm,partition-no",
559 NULL);
557 if (lp_index_ptr) 560 if (lp_index_ptr)
558 lp_index = *lp_index_ptr; 561 lp_index = *lp_index_ptr;
562 of_node_put(rootdn);
559 } 563 }
560 seq_printf(m, "serial_number=%s\n", system_id); 564 seq_printf(m, "serial_number=%s\n", system_id);
561 seq_printf(m, "system_type=%s\n", model); 565 seq_printf(m, "system_type=%s\n", model);
diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
index a24b09c27718..704375bda73a 100644
--- a/arch/powerpc/kernel/machine_kexec_64.c
+++ b/arch/powerpc/kernel/machine_kexec_64.c
@@ -72,8 +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 = get_property(node, "linux,tce-base", NULL); 75 basep = of_get_property(node, "linux,tce-base", NULL);
76 sizep = get_property(node, "linux,tce-size", NULL); 76 sizep = of_get_property(node, "linux,tce-size", NULL);
77 if (basep == NULL || sizep == NULL) 77 if (basep == NULL || sizep == NULL)
78 continue; 78 continue;
79 79
@@ -294,19 +294,19 @@ static unsigned long htab_base, kernel_end;
294static struct property htab_base_prop = { 294static struct property htab_base_prop = {
295 .name = "linux,htab-base", 295 .name = "linux,htab-base",
296 .length = sizeof(unsigned long), 296 .length = sizeof(unsigned long),
297 .value = (unsigned char *)&htab_base, 297 .value = &htab_base,
298}; 298};
299 299
300static struct property htab_size_prop = { 300static struct property htab_size_prop = {
301 .name = "linux,htab-size", 301 .name = "linux,htab-size",
302 .length = sizeof(unsigned long), 302 .length = sizeof(unsigned long),
303 .value = (unsigned char *)&htab_size_bytes, 303 .value = &htab_size_bytes,
304}; 304};
305 305
306static struct property kernel_end_prop = { 306static struct property kernel_end_prop = {
307 .name = "linux,kernel-end", 307 .name = "linux,kernel-end",
308 .length = sizeof(unsigned long), 308 .length = sizeof(unsigned long),
309 .value = (unsigned char *)&kernel_end, 309 .value = &kernel_end,
310}; 310};
311 311
312static void __init export_htab_values(void) 312static void __init export_htab_values(void)
@@ -335,7 +335,7 @@ static void __init export_htab_values(void)
335static struct property crashk_base_prop = { 335static struct property crashk_base_prop = {
336 .name = "linux,crashkernel-base", 336 .name = "linux,crashkernel-base",
337 .length = sizeof(unsigned long), 337 .length = sizeof(unsigned long),
338 .value = (unsigned char *)&crashk_res.start, 338 .value = &crashk_res.start,
339}; 339};
340 340
341static unsigned long crashk_size; 341static unsigned long crashk_size;
@@ -343,7 +343,7 @@ static unsigned long crashk_size;
343static struct property crashk_size_prop = { 343static struct property crashk_size_prop = {
344 .name = "linux,crashkernel-size", 344 .name = "linux,crashkernel-size",
345 .length = sizeof(unsigned long), 345 .length = sizeof(unsigned long),
346 .value = (unsigned char *)&crashk_size, 346 .value = &crashk_size,
347}; 347};
348 348
349static void __init export_crashk_values(void) 349static void __init export_crashk_values(void)
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 412bea3cf813..98decf8ebff4 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -734,10 +734,6 @@ _GLOBAL(abs)
734 sub r3,r3,r4 734 sub r3,r3,r4
735 blr 735 blr
736 736
737_GLOBAL(_get_SP)
738 mr r3,r1 /* Close enough */
739 blr
740
741/* 737/*
742 * Create a kernel thread 738 * Create a kernel thread
743 * kernel_thread(fn, arg, flags) 739 * kernel_thread(fn, arg, flags)
diff --git a/arch/powerpc/kernel/of_device.c b/arch/powerpc/kernel/of_device.c
index e921514e655b..0c8ea7659d92 100644
--- a/arch/powerpc/kernel/of_device.c
+++ b/arch/powerpc/kernel/of_device.c
@@ -120,6 +120,117 @@ void of_device_unregister(struct of_device *ofdev)
120} 120}
121 121
122 122
123static ssize_t of_device_get_modalias(struct of_device *ofdev,
124 char *str, ssize_t len)
125{
126 const char *compat;
127 int cplen, i;
128 ssize_t tsize, csize, repend;
129
130 /* Name & Type */
131 csize = snprintf(str, len, "of:N%sT%s",
132 ofdev->node->name, ofdev->node->type);
133
134 /* Get compatible property if any */
135 compat = of_get_property(ofdev->node, "compatible", &cplen);
136 if (!compat)
137 return csize;
138
139 /* Find true end (we tolerate multiple \0 at the end */
140 for (i=(cplen-1); i>=0 && !compat[i]; i--)
141 cplen--;
142 if (!cplen)
143 return csize;
144 cplen++;
145
146 /* Check space (need cplen+1 chars including final \0) */
147 tsize = csize + cplen;
148 repend = tsize;
149
150 if (csize>=len) /* @ the limit, all is already filled */
151 return tsize;
152
153 if (tsize>=len) { /* limit compat list */
154 cplen = len-csize-1;
155 repend = len;
156 }
157
158 /* Copy and do char replacement */
159 memcpy(&str[csize+1], compat, cplen);
160 for (i=csize; i<repend; i++) {
161 char c = str[i];
162 if (c=='\0')
163 str[i] = 'C';
164 else if (c==' ')
165 str[i] = '_';
166 }
167
168 return tsize;
169}
170
171int of_device_uevent(struct device *dev,
172 char **envp, int num_envp, char *buffer, int buffer_size)
173{
174 struct of_device *ofdev;
175 const char *compat;
176 int i = 0, length = 0, seen = 0, cplen, sl;
177
178 if (!dev)
179 return -ENODEV;
180
181 ofdev = to_of_device(dev);
182
183 if (add_uevent_var(envp, num_envp, &i,
184 buffer, buffer_size, &length,
185 "OF_NAME=%s", ofdev->node->name))
186 return -ENOMEM;
187
188 if (add_uevent_var(envp, num_envp, &i,
189 buffer, buffer_size, &length,
190 "OF_TYPE=%s", ofdev->node->type))
191 return -ENOMEM;
192
193 /* Since the compatible field can contain pretty much anything
194 * it's not really legal to split it out with commas. We split it
195 * up using a number of environment variables instead. */
196
197 compat = of_get_property(ofdev->node, "compatible", &cplen);
198 while (compat && *compat && cplen > 0) {
199 if (add_uevent_var(envp, num_envp, &i,
200 buffer, buffer_size, &length,
201 "OF_COMPATIBLE_%d=%s", seen, compat))
202 return -ENOMEM;
203
204 sl = strlen (compat) + 1;
205 compat += sl;
206 cplen -= sl;
207 seen++;
208 }
209
210 if (add_uevent_var(envp, num_envp, &i,
211 buffer, buffer_size, &length,
212 "OF_COMPATIBLE_N=%d", seen))
213 return -ENOMEM;
214
215 /* modalias is trickier, we add it in 2 steps */
216 if (add_uevent_var(envp, num_envp, &i,
217 buffer, buffer_size, &length,
218 "MODALIAS="))
219 return -ENOMEM;
220
221 sl = of_device_get_modalias(ofdev, &buffer[length-1],
222 buffer_size-length);
223 if (sl >= (buffer_size-length))
224 return -ENOMEM;
225
226 length += sl;
227
228 envp[i] = NULL;
229
230 return 0;
231}
232
233
123EXPORT_SYMBOL(of_match_node); 234EXPORT_SYMBOL(of_match_node);
124EXPORT_SYMBOL(of_match_device); 235EXPORT_SYMBOL(of_match_device);
125EXPORT_SYMBOL(of_device_register); 236EXPORT_SYMBOL(of_device_register);
@@ -127,3 +238,4 @@ EXPORT_SYMBOL(of_device_unregister);
127EXPORT_SYMBOL(of_dev_get); 238EXPORT_SYMBOL(of_dev_get);
128EXPORT_SYMBOL(of_dev_put); 239EXPORT_SYMBOL(of_dev_put);
129EXPORT_SYMBOL(of_release_dev); 240EXPORT_SYMBOL(of_release_dev);
241EXPORT_SYMBOL(of_device_uevent);
diff --git a/arch/powerpc/kernel/of_platform.c b/arch/powerpc/kernel/of_platform.c
index 9e7a4d249f03..908ed7926db4 100644
--- a/arch/powerpc/kernel/of_platform.c
+++ b/arch/powerpc/kernel/of_platform.c
@@ -133,6 +133,7 @@ static int of_platform_device_resume(struct device * dev)
133struct bus_type of_platform_bus_type = { 133struct bus_type of_platform_bus_type = {
134 .name = "of_platform", 134 .name = "of_platform",
135 .match = of_platform_bus_match, 135 .match = of_platform_bus_match,
136 .uevent = of_device_uevent,
136 .probe = of_platform_device_probe, 137 .probe = of_platform_device_probe,
137 .remove = of_platform_device_remove, 138 .remove = of_platform_device_remove,
138 .suspend = of_platform_device_suspend, 139 .suspend = of_platform_device_suspend,
@@ -177,7 +178,7 @@ static void of_platform_make_bus_id(struct of_device *dev)
177 * and 'D' for MMIO DCRs. 178 * and 'D' for MMIO DCRs.
178 */ 179 */
179#ifdef CONFIG_PPC_DCR 180#ifdef CONFIG_PPC_DCR
180 reg = get_property(node, "dcr-reg", NULL); 181 reg = of_get_property(node, "dcr-reg", NULL);
181 if (reg) { 182 if (reg) {
182#ifdef CONFIG_PPC_DCR_NATIVE 183#ifdef CONFIG_PPC_DCR_NATIVE
183 snprintf(name, BUS_ID_SIZE, "d%x.%s", 184 snprintf(name, BUS_ID_SIZE, "d%x.%s",
@@ -197,7 +198,7 @@ static void of_platform_make_bus_id(struct of_device *dev)
197 /* 198 /*
198 * For MMIO, get the physical address 199 * For MMIO, get the physical address
199 */ 200 */
200 reg = get_property(node, "reg", NULL); 201 reg = of_get_property(node, "reg", NULL);
201 if (reg) { 202 if (reg) {
202 addr = of_translate_address(node, reg); 203 addr = of_translate_address(node, reg);
203 if (addr != OF_BAD_ADDR) { 204 if (addr != OF_BAD_ADDR) {
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index d8ef2e100505..f022862de344 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -637,7 +637,7 @@ make_one_node_map(struct device_node* node, u8 pci_bus)
637 637
638 if (pci_bus >= pci_bus_count) 638 if (pci_bus >= pci_bus_count)
639 return; 639 return;
640 bus_range = get_property(node, "bus-range", &len); 640 bus_range = of_get_property(node, "bus-range", &len);
641 if (bus_range == NULL || len < 2 * sizeof(int)) { 641 if (bus_range == NULL || len < 2 * sizeof(int)) {
642 printk(KERN_WARNING "Can't get bus-range for %s, " 642 printk(KERN_WARNING "Can't get bus-range for %s, "
643 "assuming it starts at 0\n", node->full_name); 643 "assuming it starts at 0\n", node->full_name);
@@ -649,17 +649,20 @@ make_one_node_map(struct device_node* node, u8 pci_bus)
649 struct pci_dev* dev; 649 struct pci_dev* dev;
650 const unsigned int *class_code, *reg; 650 const unsigned int *class_code, *reg;
651 651
652 class_code = get_property(node, "class-code", NULL); 652 class_code = of_get_property(node, "class-code", NULL);
653 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI && 653 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
654 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) 654 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS))
655 continue; 655 continue;
656 reg = get_property(node, "reg", NULL); 656 reg = of_get_property(node, "reg", NULL);
657 if (!reg) 657 if (!reg)
658 continue; 658 continue;
659 dev = pci_find_slot(pci_bus, ((reg[0] >> 8) & 0xff)); 659 dev = pci_get_bus_and_slot(pci_bus, ((reg[0] >> 8) & 0xff));
660 if (!dev || !dev->subordinate) 660 if (!dev || !dev->subordinate) {
661 pci_dev_put(dev);
661 continue; 662 continue;
663 }
662 make_one_node_map(node, dev->subordinate->number); 664 make_one_node_map(node, dev->subordinate->number);
665 pci_dev_put(dev);
663 } 666 }
664} 667}
665 668
@@ -669,6 +672,7 @@ pcibios_make_OF_bus_map(void)
669 int i; 672 int i;
670 struct pci_controller* hose; 673 struct pci_controller* hose;
671 struct property *map_prop; 674 struct property *map_prop;
675 struct device_node *dn;
672 676
673 pci_to_OF_bus_map = kmalloc(pci_bus_count, GFP_KERNEL); 677 pci_to_OF_bus_map = kmalloc(pci_bus_count, GFP_KERNEL);
674 if (!pci_to_OF_bus_map) { 678 if (!pci_to_OF_bus_map) {
@@ -690,12 +694,13 @@ pcibios_make_OF_bus_map(void)
690 continue; 694 continue;
691 make_one_node_map(node, hose->first_busno); 695 make_one_node_map(node, hose->first_busno);
692 } 696 }
693 map_prop = of_find_property(find_path_device("/"), 697 dn = of_find_node_by_path("/");
694 "pci-OF-bus-map", NULL); 698 map_prop = of_find_property(dn, "pci-OF-bus-map", NULL);
695 if (map_prop) { 699 if (map_prop) {
696 BUG_ON(pci_bus_count > map_prop->length); 700 BUG_ON(pci_bus_count > map_prop->length);
697 memcpy(map_prop->value, pci_to_OF_bus_map, pci_bus_count); 701 memcpy(map_prop->value, pci_to_OF_bus_map, pci_bus_count);
698 } 702 }
703 of_node_put(dn);
699#ifdef DEBUG 704#ifdef DEBUG
700 printk("PCI->OF bus map:\n"); 705 printk("PCI->OF bus map:\n");
701 for (i=0; i<pci_bus_count; i++) { 706 for (i=0; i<pci_bus_count; i++) {
@@ -724,7 +729,7 @@ scan_OF_pci_childs(struct device_node* node, pci_OF_scan_iterator filter, void*
724 * a fake root for all functions of a multi-function device, 729 * a fake root for all functions of a multi-function device,
725 * we go down them as well. 730 * we go down them as well.
726 */ 731 */
727 class_code = get_property(node, "class-code", NULL); 732 class_code = of_get_property(node, "class-code", NULL);
728 if ((!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI && 733 if ((!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
729 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) && 734 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) &&
730 strcmp(node->name, "multifunc-device")) 735 strcmp(node->name, "multifunc-device"))
@@ -744,7 +749,7 @@ static struct device_node *scan_OF_for_pci_dev(struct device_node *parent,
744 unsigned int psize; 749 unsigned int psize;
745 750
746 while ((np = of_get_next_child(parent, np)) != NULL) { 751 while ((np = of_get_next_child(parent, np)) != NULL) {
747 reg = get_property(np, "reg", &psize); 752 reg = of_get_property(np, "reg", &psize);
748 if (reg == NULL || psize < 4) 753 if (reg == NULL || psize < 4)
749 continue; 754 continue;
750 if (((reg[0] >> 8) & 0xff) == devfn) 755 if (((reg[0] >> 8) & 0xff) == devfn)
@@ -859,7 +864,7 @@ pci_device_from_OF_node(struct device_node* node, u8* bus, u8* devfn)
859 if (!scan_OF_pci_childs(((struct device_node*)hose->arch_data)->child, 864 if (!scan_OF_pci_childs(((struct device_node*)hose->arch_data)->child,
860 find_OF_pci_device_filter, (void *)node)) 865 find_OF_pci_device_filter, (void *)node))
861 return -ENODEV; 866 return -ENODEV;
862 reg = get_property(node, "reg", NULL); 867 reg = of_get_property(node, "reg", NULL);
863 if (!reg) 868 if (!reg)
864 return -ENODEV; 869 return -ENODEV;
865 *bus = (reg[0] >> 16) & 0xff; 870 *bus = (reg[0] >> 16) & 0xff;
@@ -895,14 +900,14 @@ pci_process_bridge_OF_ranges(struct pci_controller *hose,
895 int rlen = 0, orig_rlen; 900 int rlen = 0, orig_rlen;
896 int memno = 0; 901 int memno = 0;
897 struct resource *res; 902 struct resource *res;
898 int np, na = prom_n_addr_cells(dev); 903 int np, na = of_n_addr_cells(dev);
899 np = na + 5; 904 np = na + 5;
900 905
901 /* First we try to merge ranges to fix a problem with some pmacs 906 /* First we try to merge ranges to fix a problem with some pmacs
902 * that can have more than 3 ranges, fortunately using contiguous 907 * that can have more than 3 ranges, fortunately using contiguous
903 * addresses -- BenH 908 * addresses -- BenH
904 */ 909 */
905 dt_ranges = get_property(dev, "ranges", &rlen); 910 dt_ranges = of_get_property(dev, "ranges", &rlen);
906 if (!dt_ranges) 911 if (!dt_ranges)
907 return; 912 return;
908 /* Sanity check, though hopefully that never happens */ 913 /* Sanity check, though hopefully that never happens */
@@ -1006,14 +1011,19 @@ void __init
1006pci_create_OF_bus_map(void) 1011pci_create_OF_bus_map(void)
1007{ 1012{
1008 struct property* of_prop; 1013 struct property* of_prop;
1009 1014 struct device_node *dn;
1015
1010 of_prop = (struct property*) alloc_bootmem(sizeof(struct property) + 256); 1016 of_prop = (struct property*) alloc_bootmem(sizeof(struct property) + 256);
1011 if (of_prop && find_path_device("/")) { 1017 if (!of_prop)
1018 return;
1019 dn = of_find_node_by_path("/");
1020 if (dn) {
1012 memset(of_prop, -1, sizeof(struct property) + 256); 1021 memset(of_prop, -1, sizeof(struct property) + 256);
1013 of_prop->name = "pci-OF-bus-map"; 1022 of_prop->name = "pci-OF-bus-map";
1014 of_prop->length = 256; 1023 of_prop->length = 256;
1015 of_prop->value = (unsigned char *)&of_prop[1]; 1024 of_prop->value = &of_prop[1];
1016 prom_add_property(find_path_device("/"), of_prop); 1025 prom_add_property(dn, of_prop);
1026 of_node_put(dn);
1017 } 1027 }
1018} 1028}
1019 1029
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 7e97d71a5f8f..60d7d4baa227 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -61,8 +61,7 @@ void iSeries_pcibios_init(void);
61 61
62LIST_HEAD(hose_list); 62LIST_HEAD(hose_list);
63 63
64struct dma_mapping_ops *pci_dma_ops; 64static struct dma_mapping_ops *pci_dma_ops;
65EXPORT_SYMBOL(pci_dma_ops);
66 65
67int global_phb_number; /* Global phb counter */ 66int global_phb_number; /* Global phb counter */
68 67
@@ -70,6 +69,17 @@ int global_phb_number; /* Global phb counter */
70struct pci_dev *ppc64_isabridge_dev = NULL; 69struct pci_dev *ppc64_isabridge_dev = NULL;
71EXPORT_SYMBOL_GPL(ppc64_isabridge_dev); 70EXPORT_SYMBOL_GPL(ppc64_isabridge_dev);
72 71
72void set_pci_dma_ops(struct dma_mapping_ops *dma_ops)
73{
74 pci_dma_ops = dma_ops;
75}
76
77struct dma_mapping_ops *get_pci_dma_ops(void)
78{
79 return pci_dma_ops;
80}
81EXPORT_SYMBOL(get_pci_dma_ops);
82
73static void fixup_broken_pcnet32(struct pci_dev* dev) 83static void fixup_broken_pcnet32(struct pci_dev* dev)
74{ 84{
75 if ((dev->class>>8 == PCI_CLASS_NETWORK_ETHERNET)) { 85 if ((dev->class>>8 == PCI_CLASS_NETWORK_ETHERNET)) {
@@ -258,7 +268,7 @@ static u32 get_int_prop(struct device_node *np, const char *name, u32 def)
258 const u32 *prop; 268 const u32 *prop;
259 int len; 269 int len;
260 270
261 prop = get_property(np, name, &len); 271 prop = of_get_property(np, name, &len);
262 if (prop && len >= 4) 272 if (prop && len >= 4)
263 return *prop; 273 return *prop;
264 return def; 274 return def;
@@ -291,7 +301,7 @@ static void pci_parse_of_addrs(struct device_node *node, struct pci_dev *dev)
291 u32 i; 301 u32 i;
292 int proplen; 302 int proplen;
293 303
294 addrs = get_property(node, "assigned-addresses", &proplen); 304 addrs = of_get_property(node, "assigned-addresses", &proplen);
295 if (!addrs) 305 if (!addrs)
296 return; 306 return;
297 DBG(" parse addresses (%d bytes) @ %p\n", proplen, addrs); 307 DBG(" parse addresses (%d bytes) @ %p\n", proplen, addrs);
@@ -333,7 +343,7 @@ struct pci_dev *of_create_pci_dev(struct device_node *node,
333 dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL); 343 dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL);
334 if (!dev) 344 if (!dev)
335 return NULL; 345 return NULL;
336 type = get_property(node, "device_type", NULL); 346 type = of_get_property(node, "device_type", NULL);
337 if (type == NULL) 347 if (type == NULL)
338 type = ""; 348 type = "";
339 349
@@ -397,7 +407,7 @@ void __devinit of_scan_bus(struct device_node *node,
397 407
398 while ((child = of_get_next_child(node, child)) != NULL) { 408 while ((child = of_get_next_child(node, child)) != NULL) {
399 DBG(" * %s\n", child->full_name); 409 DBG(" * %s\n", child->full_name);
400 reg = get_property(child, "reg", &reglen); 410 reg = of_get_property(child, "reg", &reglen);
401 if (reg == NULL || reglen < 20) 411 if (reg == NULL || reglen < 20)
402 continue; 412 continue;
403 devfn = (reg[0] >> 8) & 0xff; 413 devfn = (reg[0] >> 8) & 0xff;
@@ -430,13 +440,13 @@ void __devinit of_scan_pci_bridge(struct device_node *node,
430 DBG("of_scan_pci_bridge(%s)\n", node->full_name); 440 DBG("of_scan_pci_bridge(%s)\n", node->full_name);
431 441
432 /* parse bus-range property */ 442 /* parse bus-range property */
433 busrange = get_property(node, "bus-range", &len); 443 busrange = of_get_property(node, "bus-range", &len);
434 if (busrange == NULL || len != 8) { 444 if (busrange == NULL || len != 8) {
435 printk(KERN_DEBUG "Can't get bus-range for PCI-PCI bridge %s\n", 445 printk(KERN_DEBUG "Can't get bus-range for PCI-PCI bridge %s\n",
436 node->full_name); 446 node->full_name);
437 return; 447 return;
438 } 448 }
439 ranges = get_property(node, "ranges", &len); 449 ranges = of_get_property(node, "ranges", &len);
440 if (ranges == NULL) { 450 if (ranges == NULL) {
441 printk(KERN_DEBUG "Can't get ranges for PCI-PCI bridge %s\n", 451 printk(KERN_DEBUG "Can't get ranges for PCI-PCI bridge %s\n",
442 node->full_name); 452 node->full_name);
@@ -900,7 +910,7 @@ static void __devinit pci_process_ISA_OF_ranges(struct device_node *isa_node,
900 unsigned int size; 910 unsigned int size;
901 int rlen = 0; 911 int rlen = 0;
902 912
903 range = get_property(isa_node, "ranges", &rlen); 913 range = of_get_property(isa_node, "ranges", &rlen);
904 if (range == NULL || (rlen < sizeof(struct isa_range))) { 914 if (range == NULL || (rlen < sizeof(struct isa_range))) {
905 printk(KERN_ERR "no ISA ranges or unexpected isa range size," 915 printk(KERN_ERR "no ISA ranges or unexpected isa range size,"
906 "mapping 64k\n"); 916 "mapping 64k\n");
@@ -947,7 +957,7 @@ void __devinit pci_process_bridge_OF_ranges(struct pci_controller *hose,
947 int rlen = 0; 957 int rlen = 0;
948 int memno = 0; 958 int memno = 0;
949 struct resource *res; 959 struct resource *res;
950 int np, na = prom_n_addr_cells(dev); 960 int np, na = of_n_addr_cells(dev);
951 unsigned long pci_addr, cpu_phys_addr; 961 unsigned long pci_addr, cpu_phys_addr;
952 962
953 np = na + 5; 963 np = na + 5;
@@ -960,7 +970,7 @@ void __devinit pci_process_bridge_OF_ranges(struct pci_controller *hose,
960 * (size depending on dev->n_addr_cells) 970 * (size depending on dev->n_addr_cells)
961 * cells 4+5 or 5+6: the size of the range 971 * cells 4+5 or 5+6: the size of the range
962 */ 972 */
963 ranges = get_property(dev, "ranges", &rlen); 973 ranges = of_get_property(dev, "ranges", &rlen);
964 if (ranges == NULL) 974 if (ranges == NULL)
965 return; 975 return;
966 hose->io_base_phys = 0; 976 hose->io_base_phys = 0;
diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c
index 68df018dae0e..d7d36df9c053 100644
--- a/arch/powerpc/kernel/pci_dn.c
+++ b/arch/powerpc/kernel/pci_dn.c
@@ -40,7 +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 const int *type = get_property(dn, "ibm,pci-config-space-type", NULL); 43 const int *type =
44 of_get_property(dn, "ibm,pci-config-space-type", NULL);
44 const u32 *regs; 45 const u32 *regs;
45 struct pci_dn *pdn; 46 struct pci_dn *pdn;
46 47
@@ -54,14 +55,14 @@ static void * __devinit update_dn_pci_info(struct device_node *dn, void *data)
54 dn->data = pdn; 55 dn->data = pdn;
55 pdn->node = dn; 56 pdn->node = dn;
56 pdn->phb = phb; 57 pdn->phb = phb;
57 regs = get_property(dn, "reg", NULL); 58 regs = of_get_property(dn, "reg", NULL);
58 if (regs) { 59 if (regs) {
59 /* First register entry is addr (00BBSS00) */ 60 /* First register entry is addr (00BBSS00) */
60 pdn->busno = (regs[0] >> 16) & 0xff; 61 pdn->busno = (regs[0] >> 16) & 0xff;
61 pdn->devfn = (regs[0] >> 8) & 0xff; 62 pdn->devfn = (regs[0] >> 8) & 0xff;
62 } 63 }
63 if (firmware_has_feature(FW_FEATURE_ISERIES)) { 64 if (firmware_has_feature(FW_FEATURE_ISERIES)) {
64 const u32 *busp = get_property(dn, "linux,subbus", NULL); 65 const u32 *busp = of_get_property(dn, "linux,subbus", NULL);
65 if (busp) 66 if (busp)
66 pdn->bussubno = *busp; 67 pdn->bussubno = *busp;
67 } 68 }
@@ -100,7 +101,7 @@ void *traverse_pci_devices(struct device_node *start, traverse_func pre,
100 u32 class; 101 u32 class;
101 102
102 nextdn = NULL; 103 nextdn = NULL;
103 classp = get_property(dn, "class-code", NULL); 104 classp = of_get_property(dn, "class-code", NULL);
104 class = classp ? *classp : 0; 105 class = classp ? *classp : 0;
105 106
106 if (pre && ((ret = pre(dn, data)) != NULL)) 107 if (pre && ((ret = pre(dn, data)) != NULL))
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 2f8e9c02c92a..ff252aaead12 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -20,7 +20,6 @@
20#include <asm/processor.h> 20#include <asm/processor.h>
21#include <asm/uaccess.h> 21#include <asm/uaccess.h>
22#include <asm/io.h> 22#include <asm/io.h>
23#include <asm/ide.h>
24#include <asm/atomic.h> 23#include <asm/atomic.h>
25#include <asm/checksum.h> 24#include <asm/checksum.h>
26#include <asm/pgtable.h> 25#include <asm/pgtable.h>
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index e53b2988d1bf..e509aae2feb3 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -305,9 +305,7 @@ struct task_struct *__switch_to(struct task_struct *prev,
305 set_dabr(new->thread.dabr); 305 set_dabr(new->thread.dabr);
306 __get_cpu_var(current_dabr) = new->thread.dabr; 306 __get_cpu_var(current_dabr) = new->thread.dabr;
307 } 307 }
308 308#endif /* CONFIG_PPC64 */
309 flush_tlb_pending();
310#endif
311 309
312 new_thread = &new->thread; 310 new_thread = &new->thread;
313 old_thread = &current->thread; 311 old_thread = &current->thread;
@@ -402,11 +400,11 @@ static void printbits(unsigned long val, struct regbit *bits)
402} 400}
403 401
404#ifdef CONFIG_PPC64 402#ifdef CONFIG_PPC64
405#define REG "%016lX" 403#define REG "%016lx"
406#define REGS_PER_LINE 4 404#define REGS_PER_LINE 4
407#define LAST_VOLATILE 13 405#define LAST_VOLATILE 13
408#else 406#else
409#define REG "%08lX" 407#define REG "%08lx"
410#define REGS_PER_LINE 8 408#define REGS_PER_LINE 8
411#define LAST_VOLATILE 12 409#define LAST_VOLATILE 12
412#endif 410#endif
@@ -421,7 +419,7 @@ void show_regs(struct pt_regs * regs)
421 regs, regs->trap, print_tainted(), init_utsname()->release); 419 regs, regs->trap, print_tainted(), init_utsname()->release);
422 printk("MSR: "REG" ", regs->msr); 420 printk("MSR: "REG" ", regs->msr);
423 printbits(regs->msr, msr_bits); 421 printbits(regs->msr, msr_bits);
424 printk(" CR: %08lX XER: %08lX\n", regs->ccr, regs->xer); 422 printk(" CR: %08lx XER: %08lx\n", regs->ccr, regs->xer);
425 trap = TRAP(regs); 423 trap = TRAP(regs);
426 if (trap == 0x300 || trap == 0x600) 424 if (trap == 0x300 || trap == 0x600)
427 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr); 425 printk("DAR: "REG", DSISR: "REG"\n", regs->dar, regs->dsisr);
@@ -572,7 +570,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
572 kregs->nip = *((unsigned long *)ret_from_fork); 570 kregs->nip = *((unsigned long *)ret_from_fork);
573#else 571#else
574 kregs->nip = (unsigned long)ret_from_fork; 572 kregs->nip = (unsigned long)ret_from_fork;
575 p->thread.last_syscall = -1;
576#endif 573#endif
577 574
578 return 0; 575 return 0;
@@ -823,6 +820,35 @@ out:
823 return error; 820 return error;
824} 821}
825 822
823#ifdef CONFIG_IRQSTACKS
824static inline int valid_irq_stack(unsigned long sp, struct task_struct *p,
825 unsigned long nbytes)
826{
827 unsigned long stack_page;
828 unsigned long cpu = task_cpu(p);
829
830 /*
831 * Avoid crashing if the stack has overflowed and corrupted
832 * task_cpu(p), which is in the thread_info struct.
833 */
834 if (cpu < NR_CPUS && cpu_possible(cpu)) {
835 stack_page = (unsigned long) hardirq_ctx[cpu];
836 if (sp >= stack_page + sizeof(struct thread_struct)
837 && sp <= stack_page + THREAD_SIZE - nbytes)
838 return 1;
839
840 stack_page = (unsigned long) softirq_ctx[cpu];
841 if (sp >= stack_page + sizeof(struct thread_struct)
842 && sp <= stack_page + THREAD_SIZE - nbytes)
843 return 1;
844 }
845 return 0;
846}
847
848#else
849#define valid_irq_stack(sp, p, nb) 0
850#endif /* CONFIG_IRQSTACKS */
851
826int validate_sp(unsigned long sp, struct task_struct *p, 852int validate_sp(unsigned long sp, struct task_struct *p,
827 unsigned long nbytes) 853 unsigned long nbytes)
828{ 854{
@@ -832,19 +858,7 @@ int validate_sp(unsigned long sp, struct task_struct *p,
832 && sp <= stack_page + THREAD_SIZE - nbytes) 858 && sp <= stack_page + THREAD_SIZE - nbytes)
833 return 1; 859 return 1;
834 860
835#ifdef CONFIG_IRQSTACKS 861 return valid_irq_stack(sp, p, nbytes);
836 stack_page = (unsigned long) hardirq_ctx[task_cpu(p)];
837 if (sp >= stack_page + sizeof(struct thread_struct)
838 && sp <= stack_page + THREAD_SIZE - nbytes)
839 return 1;
840
841 stack_page = (unsigned long) softirq_ctx[task_cpu(p)];
842 if (sp >= stack_page + sizeof(struct thread_struct)
843 && sp <= stack_page + THREAD_SIZE - nbytes)
844 return 1;
845#endif
846
847 return 0;
848} 862}
849 863
850#ifdef CONFIG_PPC64 864#ifdef CONFIG_PPC64
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 8d52b23348bd..caef555f2dc0 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -390,18 +390,19 @@ static unsigned long __init unflatten_dt_node(unsigned long mem,
390 if (allnextpp) { 390 if (allnextpp) {
391 pp->name = "name"; 391 pp->name = "name";
392 pp->length = sz; 392 pp->length = sz;
393 pp->value = (unsigned char *)(pp + 1); 393 pp->value = pp + 1;
394 *prev_pp = pp; 394 *prev_pp = pp;
395 prev_pp = &pp->next; 395 prev_pp = &pp->next;
396 memcpy(pp->value, ps, sz - 1); 396 memcpy(pp->value, ps, sz - 1);
397 ((char *)pp->value)[sz - 1] = 0; 397 ((char *)pp->value)[sz - 1] = 0;
398 DBG("fixed up name for %s -> %s\n", pathp, pp->value); 398 DBG("fixed up name for %s -> %s\n", pathp,
399 (char *)pp->value);
399 } 400 }
400 } 401 }
401 if (allnextpp) { 402 if (allnextpp) {
402 *prev_pp = NULL; 403 *prev_pp = NULL;
403 np->name = get_property(np, "name", NULL); 404 np->name = of_get_property(np, "name", NULL);
404 np->type = get_property(np, "device_type", NULL); 405 np->type = of_get_property(np, "device_type", NULL);
405 406
406 if (!np->name) 407 if (!np->name)
407 np->name = "<NULL>"; 408 np->name = "<NULL>";
@@ -719,6 +720,7 @@ static int __init early_init_dt_scan_chosen(unsigned long node,
719 const char *uname, int depth, void *data) 720 const char *uname, int depth, void *data)
720{ 721{
721 unsigned long *lprop; 722 unsigned long *lprop;
723 u32 *prop;
722 unsigned long l; 724 unsigned long l;
723 char *p; 725 char *p;
724 726
@@ -760,6 +762,22 @@ static int __init early_init_dt_scan_chosen(unsigned long node,
760 crashk_res.end = crashk_res.start + *lprop - 1; 762 crashk_res.end = crashk_res.start + *lprop - 1;
761#endif 763#endif
762 764
765#ifdef CONFIG_BLK_DEV_INITRD
766 DBG("Looking for initrd properties... ");
767 prop = of_get_flat_dt_prop(node, "linux,initrd-start", &l);
768 if (prop) {
769 initrd_start = (unsigned long)__va(of_read_ulong(prop, l/4));
770 prop = of_get_flat_dt_prop(node, "linux,initrd-end", &l);
771 if (prop) {
772 initrd_end = (unsigned long)__va(of_read_ulong(prop, l/4));
773 initrd_below_start_ok = 1;
774 } else {
775 initrd_start = 0;
776 }
777 }
778 DBG("initrd_start=0x%lx initrd_end=0x%lx\n", initrd_start, initrd_end);
779#endif /* CONFIG_BLK_DEV_INITRD */
780
763 /* Retreive command line */ 781 /* Retreive command line */
764 p = of_get_flat_dt_prop(node, "bootargs", &l); 782 p = of_get_flat_dt_prop(node, "bootargs", &l);
765 if (p != NULL && l > 0) 783 if (p != NULL && l > 0)
@@ -926,6 +944,12 @@ static void __init early_reserve_mem(void)
926 self_size = initial_boot_params->totalsize; 944 self_size = initial_boot_params->totalsize;
927 lmb_reserve(self_base, self_size); 945 lmb_reserve(self_base, self_size);
928 946
947#ifdef CONFIG_BLK_DEV_INITRD
948 /* then reserve the initrd, if any */
949 if (initrd_start && (initrd_end > initrd_start))
950 lmb_reserve(__pa(initrd_start), initrd_end - initrd_start);
951#endif /* CONFIG_BLK_DEV_INITRD */
952
929#ifdef CONFIG_PPC32 953#ifdef CONFIG_PPC32
930 /* 954 /*
931 * Handle the case where we might be booting from an old kexec 955 * Handle the case where we might be booting from an old kexec
@@ -954,9 +978,6 @@ static void __init early_reserve_mem(void)
954 size = *(reserve_map++); 978 size = *(reserve_map++);
955 if (size == 0) 979 if (size == 0)
956 break; 980 break;
957 /* skip if the reservation is for the blob */
958 if (base == self_base && size == self_size)
959 continue;
960 DBG("reserving: %llx -> %llx\n", base, size); 981 DBG("reserving: %llx -> %llx\n", base, size);
961 lmb_reserve(base, size); 982 lmb_reserve(base, size);
962 } 983 }
@@ -1021,102 +1042,46 @@ void __init early_init_devtree(void *params)
1021 1042
1022#undef printk 1043#undef printk
1023 1044
1024int 1045int of_n_addr_cells(struct device_node* np)
1025prom_n_addr_cells(struct device_node* np)
1026{ 1046{
1027 const int *ip; 1047 const int *ip;
1028 do { 1048 do {
1029 if (np->parent) 1049 if (np->parent)
1030 np = np->parent; 1050 np = np->parent;
1031 ip = get_property(np, "#address-cells", NULL); 1051 ip = of_get_property(np, "#address-cells", NULL);
1032 if (ip != NULL) 1052 if (ip != NULL)
1033 return *ip; 1053 return *ip;
1034 } while (np->parent); 1054 } while (np->parent);
1035 /* No #address-cells property for the root node, default to 1 */ 1055 /* No #address-cells property for the root node, default to 1 */
1036 return 1; 1056 return 1;
1037} 1057}
1038EXPORT_SYMBOL(prom_n_addr_cells); 1058EXPORT_SYMBOL(of_n_addr_cells);
1039 1059
1040int 1060int of_n_size_cells(struct device_node* np)
1041prom_n_size_cells(struct device_node* np)
1042{ 1061{
1043 const int* ip; 1062 const int* ip;
1044 do { 1063 do {
1045 if (np->parent) 1064 if (np->parent)
1046 np = np->parent; 1065 np = np->parent;
1047 ip = get_property(np, "#size-cells", NULL); 1066 ip = of_get_property(np, "#size-cells", NULL);
1048 if (ip != NULL) 1067 if (ip != NULL)
1049 return *ip; 1068 return *ip;
1050 } while (np->parent); 1069 } while (np->parent);
1051 /* No #size-cells property for the root node, default to 1 */ 1070 /* No #size-cells property for the root node, default to 1 */
1052 return 1; 1071 return 1;
1053} 1072}
1054EXPORT_SYMBOL(prom_n_size_cells); 1073EXPORT_SYMBOL(of_n_size_cells);
1055
1056/**
1057 * Construct and return a list of the device_nodes with a given name.
1058 */
1059struct device_node *find_devices(const char *name)
1060{
1061 struct device_node *head, **prevp, *np;
1062
1063 prevp = &head;
1064 for (np = allnodes; np != 0; np = np->allnext) {
1065 if (np->name != 0 && strcasecmp(np->name, name) == 0) {
1066 *prevp = np;
1067 prevp = &np->next;
1068 }
1069 }
1070 *prevp = NULL;
1071 return head;
1072}
1073EXPORT_SYMBOL(find_devices);
1074
1075/**
1076 * Construct and return a list of the device_nodes with a given type.
1077 */
1078struct device_node *find_type_devices(const char *type)
1079{
1080 struct device_node *head, **prevp, *np;
1081
1082 prevp = &head;
1083 for (np = allnodes; np != 0; np = np->allnext) {
1084 if (np->type != 0 && strcasecmp(np->type, type) == 0) {
1085 *prevp = np;
1086 prevp = &np->next;
1087 }
1088 }
1089 *prevp = NULL;
1090 return head;
1091}
1092EXPORT_SYMBOL(find_type_devices);
1093
1094/**
1095 * Returns all nodes linked together
1096 */
1097struct device_node *find_all_nodes(void)
1098{
1099 struct device_node *head, **prevp, *np;
1100
1101 prevp = &head;
1102 for (np = allnodes; np != 0; np = np->allnext) {
1103 *prevp = np;
1104 prevp = &np->next;
1105 }
1106 *prevp = NULL;
1107 return head;
1108}
1109EXPORT_SYMBOL(find_all_nodes);
1110 1074
1111/** Checks if the given "compat" string matches one of the strings in 1075/** Checks if the given "compat" string matches one of the strings in
1112 * the device's "compatible" property 1076 * the device's "compatible" property
1113 */ 1077 */
1114int device_is_compatible(const struct device_node *device, const char *compat) 1078int of_device_is_compatible(const struct device_node *device,
1079 const char *compat)
1115{ 1080{
1116 const char* cp; 1081 const char* cp;
1117 int cplen, l; 1082 int cplen, l;
1118 1083
1119 cp = get_property(device, "compatible", &cplen); 1084 cp = of_get_property(device, "compatible", &cplen);
1120 if (cp == NULL) 1085 if (cp == NULL)
1121 return 0; 1086 return 0;
1122 while (cplen > 0) { 1087 while (cplen > 0) {
@@ -1129,7 +1094,7 @@ int device_is_compatible(const struct device_node *device, const char *compat)
1129 1094
1130 return 0; 1095 return 0;
1131} 1096}
1132EXPORT_SYMBOL(device_is_compatible); 1097EXPORT_SYMBOL(of_device_is_compatible);
1133 1098
1134 1099
1135/** 1100/**
@@ -1143,51 +1108,13 @@ int machine_is_compatible(const char *compat)
1143 1108
1144 root = of_find_node_by_path("/"); 1109 root = of_find_node_by_path("/");
1145 if (root) { 1110 if (root) {
1146 rc = device_is_compatible(root, compat); 1111 rc = of_device_is_compatible(root, compat);
1147 of_node_put(root); 1112 of_node_put(root);
1148 } 1113 }
1149 return rc; 1114 return rc;
1150} 1115}
1151EXPORT_SYMBOL(machine_is_compatible); 1116EXPORT_SYMBOL(machine_is_compatible);
1152 1117
1153/**
1154 * Construct and return a list of the device_nodes with a given type
1155 * and compatible property.
1156 */
1157struct device_node *find_compatible_devices(const char *type,
1158 const char *compat)
1159{
1160 struct device_node *head, **prevp, *np;
1161
1162 prevp = &head;
1163 for (np = allnodes; np != 0; np = np->allnext) {
1164 if (type != NULL
1165 && !(np->type != 0 && strcasecmp(np->type, type) == 0))
1166 continue;
1167 if (device_is_compatible(np, compat)) {
1168 *prevp = np;
1169 prevp = &np->next;
1170 }
1171 }
1172 *prevp = NULL;
1173 return head;
1174}
1175EXPORT_SYMBOL(find_compatible_devices);
1176
1177/**
1178 * Find the device_node with a given full_name.
1179 */
1180struct device_node *find_path_device(const char *path)
1181{
1182 struct device_node *np;
1183
1184 for (np = allnodes; np != 0; np = np->allnext)
1185 if (np->full_name != 0 && strcasecmp(np->full_name, path) == 0)
1186 return np;
1187 return NULL;
1188}
1189EXPORT_SYMBOL(find_path_device);
1190
1191/******* 1118/*******
1192 * 1119 *
1193 * New implementation of the OF "find" APIs, return a refcounted 1120 * New implementation of the OF "find" APIs, return a refcounted
@@ -1280,7 +1207,7 @@ struct device_node *of_find_compatible_node(struct device_node *from,
1280 if (type != NULL 1207 if (type != NULL
1281 && !(np->type != 0 && strcasecmp(np->type, type) == 0)) 1208 && !(np->type != 0 && strcasecmp(np->type, type) == 0))
1282 continue; 1209 continue;
1283 if (device_is_compatible(np, compatible) && of_node_get(np)) 1210 if (of_device_is_compatible(np, compatible) && of_node_get(np))
1284 break; 1211 break;
1285 } 1212 }
1286 of_node_put(from); 1213 of_node_put(from);
@@ -1527,8 +1454,8 @@ static int of_finish_dynamic_node(struct device_node *node)
1527 int err = 0; 1454 int err = 0;
1528 const phandle *ibm_phandle; 1455 const phandle *ibm_phandle;
1529 1456
1530 node->name = get_property(node, "name", NULL); 1457 node->name = of_get_property(node, "name", NULL);
1531 node->type = get_property(node, "device_type", NULL); 1458 node->type = of_get_property(node, "device_type", NULL);
1532 1459
1533 if (!parent) { 1460 if (!parent) {
1534 err = -ENODEV; 1461 err = -ENODEV;
@@ -1542,7 +1469,7 @@ static int of_finish_dynamic_node(struct device_node *node)
1542 return -ENODEV; 1469 return -ENODEV;
1543 1470
1544 /* fix up new node's linux_phandle field */ 1471 /* fix up new node's linux_phandle field */
1545 if ((ibm_phandle = get_property(node, "ibm,phandle", NULL))) 1472 if ((ibm_phandle = of_get_property(node, "ibm,phandle", NULL)))
1546 node->linux_phandle = *ibm_phandle; 1473 node->linux_phandle = *ibm_phandle;
1547 1474
1548out: 1475out:
@@ -1605,13 +1532,13 @@ EXPORT_SYMBOL(of_find_property);
1605 * Find a property with a given name for a given node 1532 * Find a property with a given name for a given node
1606 * and return the value. 1533 * and return the value.
1607 */ 1534 */
1608const void *get_property(const struct device_node *np, const char *name, 1535const void *of_get_property(const struct device_node *np, const char *name,
1609 int *lenp) 1536 int *lenp)
1610{ 1537{
1611 struct property *pp = of_find_property(np,name,lenp); 1538 struct property *pp = of_find_property(np,name,lenp);
1612 return pp ? pp->value : NULL; 1539 return pp ? pp->value : NULL;
1613} 1540}
1614EXPORT_SYMBOL(get_property); 1541EXPORT_SYMBOL(of_get_property);
1615 1542
1616/* 1543/*
1617 * Add a property to a node 1544 * Add a property to a node
@@ -1742,10 +1669,10 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
1742 /* Check for ibm,ppc-interrupt-server#s. If it doesn't exist 1669 /* Check for ibm,ppc-interrupt-server#s. If it doesn't exist
1743 * fallback to "reg" property and assume no threads 1670 * fallback to "reg" property and assume no threads
1744 */ 1671 */
1745 intserv = get_property(np, "ibm,ppc-interrupt-server#s", 1672 intserv = of_get_property(np, "ibm,ppc-interrupt-server#s",
1746 &plen); 1673 &plen);
1747 if (intserv == NULL) { 1674 if (intserv == NULL) {
1748 const u32 *reg = get_property(np, "reg", NULL); 1675 const u32 *reg = of_get_property(np, "reg", NULL);
1749 if (reg == NULL) 1676 if (reg == NULL)
1750 continue; 1677 continue;
1751 if (*reg == hardid) { 1678 if (*reg == hardid) {
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 4fb5938ce6d3..e27d9d1b6e67 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -2035,39 +2035,50 @@ static void __init fixup_device_tree_maple(void)
2035#endif 2035#endif
2036 2036
2037#ifdef CONFIG_PPC_CHRP 2037#ifdef CONFIG_PPC_CHRP
2038/* Pegasos and BriQ lacks the "ranges" property in the isa node */ 2038/*
2039 * Pegasos and BriQ lacks the "ranges" property in the isa node
2040 * Pegasos needs decimal IRQ 14/15, not hexadecimal
2041 */
2039static void __init fixup_device_tree_chrp(void) 2042static void __init fixup_device_tree_chrp(void)
2040{ 2043{
2041 phandle isa; 2044 phandle ph;
2042 u32 isa_ranges[6]; 2045 u32 prop[6];
2043 u32 rloc = 0x01006000; /* IO space; PCI device = 12 */ 2046 u32 rloc = 0x01006000; /* IO space; PCI device = 12 */
2044 char *name; 2047 char *name;
2045 int rc; 2048 int rc;
2046 2049
2047 name = "/pci@80000000/isa@c"; 2050 name = "/pci@80000000/isa@c";
2048 isa = call_prom("finddevice", 1, 1, ADDR(name)); 2051 ph = call_prom("finddevice", 1, 1, ADDR(name));
2049 if (!PHANDLE_VALID(isa)) { 2052 if (!PHANDLE_VALID(ph)) {
2050 name = "/pci@ff500000/isa@6"; 2053 name = "/pci@ff500000/isa@6";
2051 isa = call_prom("finddevice", 1, 1, ADDR(name)); 2054 ph = call_prom("finddevice", 1, 1, ADDR(name));
2052 rloc = 0x01003000; /* IO space; PCI device = 6 */ 2055 rloc = 0x01003000; /* IO space; PCI device = 6 */
2053 } 2056 }
2054 if (!PHANDLE_VALID(isa)) 2057 if (PHANDLE_VALID(ph)) {
2055 return; 2058 rc = prom_getproplen(ph, "ranges");
2056 2059 if (rc == 0 || rc == PROM_ERROR) {
2057 rc = prom_getproplen(isa, "ranges"); 2060 prom_printf("Fixing up missing ISA range on Pegasos...\n");
2058 if (rc != 0 && rc != PROM_ERROR) 2061
2059 return; 2062 prop[0] = 0x1;
2060 2063 prop[1] = 0x0;
2061 prom_printf("Fixing up missing ISA range on Pegasos...\n"); 2064 prop[2] = rloc;
2065 prop[3] = 0x0;
2066 prop[4] = 0x0;
2067 prop[5] = 0x00010000;
2068 prom_setprop(ph, name, "ranges", prop, sizeof(prop));
2069 }
2070 }
2062 2071
2063 isa_ranges[0] = 0x1; 2072 name = "/pci@80000000/ide@C,1";
2064 isa_ranges[1] = 0x0; 2073 ph = call_prom("finddevice", 1, 1, ADDR(name));
2065 isa_ranges[2] = rloc; 2074 if (PHANDLE_VALID(ph)) {
2066 isa_ranges[3] = 0x0; 2075 prom_printf("Fixing up IDE interrupt on Pegasos...\n");
2067 isa_ranges[4] = 0x0; 2076 prop[0] = 14;
2068 isa_ranges[5] = 0x00010000; 2077 prop[1] = 0x0;
2069 prom_setprop(isa, name, "ranges", 2078 prop[2] = 15;
2070 isa_ranges, sizeof(isa_ranges)); 2079 prop[3] = 0x0;
2080 prom_setprop(ph, name, "interrupts", prop, 4*sizeof(u32));
2081 }
2071} 2082}
2072#else 2083#else
2073#define fixup_device_tree_chrp() 2084#define fixup_device_tree_chrp()
diff --git a/arch/powerpc/kernel/prom_parse.c b/arch/powerpc/kernel/prom_parse.c
index 91b443c9a488..aa40a5307294 100644
--- a/arch/powerpc/kernel/prom_parse.c
+++ b/arch/powerpc/kernel/prom_parse.c
@@ -68,9 +68,9 @@ static void of_bus_default_count_cells(struct device_node *dev,
68 int *addrc, int *sizec) 68 int *addrc, int *sizec)
69{ 69{
70 if (addrc) 70 if (addrc)
71 *addrc = prom_n_addr_cells(dev); 71 *addrc = of_n_addr_cells(dev);
72 if (sizec) 72 if (sizec)
73 *sizec = prom_n_size_cells(dev); 73 *sizec = of_n_size_cells(dev);
74} 74}
75 75
76static u64 of_bus_default_map(u32 *addr, const u32 *range, 76static u64 of_bus_default_map(u32 *addr, const u32 *range,
@@ -196,7 +196,7 @@ const u32 *of_get_pci_address(struct device_node *dev, int bar_no, u64 *size,
196 return NULL; 196 return NULL;
197 197
198 /* Get "reg" or "assigned-addresses" property */ 198 /* Get "reg" or "assigned-addresses" property */
199 prop = get_property(dev, bus->addresses, &psize); 199 prop = of_get_property(dev, bus->addresses, &psize);
200 if (prop == NULL) 200 if (prop == NULL)
201 return NULL; 201 return NULL;
202 psize /= 4; 202 psize /= 4;
@@ -438,7 +438,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
438 * to translate addresses that aren't supposed to be translated in 438 * to translate addresses that aren't supposed to be translated in
439 * the first place. --BenH. 439 * the first place. --BenH.
440 */ 440 */
441 ranges = get_property(parent, "ranges", &rlen); 441 ranges = of_get_property(parent, "ranges", &rlen);
442 if (ranges == NULL || rlen == 0) { 442 if (ranges == NULL || rlen == 0) {
443 offset = of_read_number(addr, na); 443 offset = of_read_number(addr, na);
444 memset(addr, 0, pna * 4); 444 memset(addr, 0, pna * 4);
@@ -578,7 +578,7 @@ const u32 *of_get_address(struct device_node *dev, int index, u64 *size,
578 return NULL; 578 return NULL;
579 579
580 /* Get "reg" or "assigned-addresses" property */ 580 /* Get "reg" or "assigned-addresses" property */
581 prop = get_property(dev, bus->addresses, &psize); 581 prop = of_get_property(dev, bus->addresses, &psize);
582 if (prop == NULL) 582 if (prop == NULL)
583 return NULL; 583 return NULL;
584 psize /= 4; 584 psize /= 4;
@@ -650,17 +650,17 @@ void of_parse_dma_window(struct device_node *dn, const void *dma_window_prop,
650 /* busno is always one cell */ 650 /* busno is always one cell */
651 *busno = *(dma_window++); 651 *busno = *(dma_window++);
652 652
653 prop = get_property(dn, "ibm,#dma-address-cells", NULL); 653 prop = of_get_property(dn, "ibm,#dma-address-cells", NULL);
654 if (!prop) 654 if (!prop)
655 prop = get_property(dn, "#address-cells", NULL); 655 prop = of_get_property(dn, "#address-cells", NULL);
656 656
657 cells = prop ? *(u32 *)prop : prom_n_addr_cells(dn); 657 cells = prop ? *(u32 *)prop : of_n_addr_cells(dn);
658 *phys = of_read_number(dma_window, cells); 658 *phys = of_read_number(dma_window, cells);
659 659
660 dma_window += cells; 660 dma_window += cells;
661 661
662 prop = get_property(dn, "ibm,#dma-size-cells", NULL); 662 prop = of_get_property(dn, "ibm,#dma-size-cells", NULL);
663 cells = prop ? *(u32 *)prop : prom_n_size_cells(dn); 663 cells = prop ? *(u32 *)prop : of_n_size_cells(dn);
664 *size = of_read_number(dma_window, cells); 664 *size = of_read_number(dma_window, cells);
665} 665}
666 666
@@ -680,7 +680,7 @@ static struct device_node *of_irq_find_parent(struct device_node *child)
680 return NULL; 680 return NULL;
681 681
682 do { 682 do {
683 parp = get_property(child, "interrupt-parent", NULL); 683 parp = of_get_property(child, "interrupt-parent", NULL);
684 if (parp == NULL) 684 if (parp == NULL)
685 p = of_get_parent(child); 685 p = of_get_parent(child);
686 else { 686 else {
@@ -691,7 +691,7 @@ static struct device_node *of_irq_find_parent(struct device_node *child)
691 } 691 }
692 of_node_put(child); 692 of_node_put(child);
693 child = p; 693 child = p;
694 } while (p && get_property(p, "#interrupt-cells", NULL) == NULL); 694 } while (p && of_get_property(p, "#interrupt-cells", NULL) == NULL);
695 695
696 return p; 696 return p;
697} 697}
@@ -716,7 +716,7 @@ void of_irq_map_init(unsigned int flags)
716 struct device_node *np; 716 struct device_node *np;
717 717
718 for(np = NULL; (np = of_find_all_nodes(np)) != NULL;) { 718 for(np = NULL; (np = of_find_all_nodes(np)) != NULL;) {
719 if (get_property(np, "interrupt-controller", NULL) 719 if (of_get_property(np, "interrupt-controller", NULL)
720 == NULL) 720 == NULL)
721 continue; 721 continue;
722 /* Skip /chosen/interrupt-controller */ 722 /* Skip /chosen/interrupt-controller */
@@ -755,7 +755,7 @@ int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize,
755 * is none, we are nice and just walk up the tree 755 * is none, we are nice and just walk up the tree
756 */ 756 */
757 do { 757 do {
758 tmp = get_property(ipar, "#interrupt-cells", NULL); 758 tmp = of_get_property(ipar, "#interrupt-cells", NULL);
759 if (tmp != NULL) { 759 if (tmp != NULL) {
760 intsize = *tmp; 760 intsize = *tmp;
761 break; 761 break;
@@ -779,7 +779,7 @@ int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize,
779 */ 779 */
780 old = of_node_get(ipar); 780 old = of_node_get(ipar);
781 do { 781 do {
782 tmp = get_property(old, "#address-cells", NULL); 782 tmp = of_get_property(old, "#address-cells", NULL);
783 tnode = of_get_parent(old); 783 tnode = of_get_parent(old);
784 of_node_put(old); 784 of_node_put(old);
785 old = tnode; 785 old = tnode;
@@ -795,7 +795,8 @@ int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize,
795 /* Now check if cursor is an interrupt-controller and if it is 795 /* Now check if cursor is an interrupt-controller and if it is
796 * then we are done 796 * then we are done
797 */ 797 */
798 if (get_property(ipar, "interrupt-controller", NULL) != NULL) { 798 if (of_get_property(ipar, "interrupt-controller", NULL) !=
799 NULL) {
799 DBG(" -> got it !\n"); 800 DBG(" -> got it !\n");
800 memcpy(out_irq->specifier, intspec, 801 memcpy(out_irq->specifier, intspec,
801 intsize * sizeof(u32)); 802 intsize * sizeof(u32));
@@ -806,7 +807,7 @@ int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize,
806 } 807 }
807 808
808 /* Now look for an interrupt-map */ 809 /* Now look for an interrupt-map */
809 imap = get_property(ipar, "interrupt-map", &imaplen); 810 imap = of_get_property(ipar, "interrupt-map", &imaplen);
810 /* No interrupt map, check for an interrupt parent */ 811 /* No interrupt map, check for an interrupt parent */
811 if (imap == NULL) { 812 if (imap == NULL) {
812 DBG(" -> no map, getting parent\n"); 813 DBG(" -> no map, getting parent\n");
@@ -816,7 +817,7 @@ int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize,
816 imaplen /= sizeof(u32); 817 imaplen /= sizeof(u32);
817 818
818 /* Look for a mask */ 819 /* Look for a mask */
819 imask = get_property(ipar, "interrupt-map-mask", NULL); 820 imask = of_get_property(ipar, "interrupt-map-mask", NULL);
820 821
821 /* If we were passed no "reg" property and we attempt to parse 822 /* If we were passed no "reg" property and we attempt to parse
822 * an interrupt-map, then #address-cells must be 0. 823 * an interrupt-map, then #address-cells must be 0.
@@ -863,15 +864,13 @@ int of_irq_map_raw(struct device_node *parent, const u32 *intspec, u32 ointsize,
863 /* Get #interrupt-cells and #address-cells of new 864 /* Get #interrupt-cells and #address-cells of new
864 * parent 865 * parent
865 */ 866 */
866 tmp = get_property(newpar, "#interrupt-cells", 867 tmp = of_get_property(newpar, "#interrupt-cells", NULL);
867 NULL);
868 if (tmp == NULL) { 868 if (tmp == NULL) {
869 DBG(" -> parent lacks #interrupt-cells !\n"); 869 DBG(" -> parent lacks #interrupt-cells !\n");
870 goto fail; 870 goto fail;
871 } 871 }
872 newintsize = *tmp; 872 newintsize = *tmp;
873 tmp = get_property(newpar, "#address-cells", 873 tmp = of_get_property(newpar, "#address-cells", NULL);
874 NULL);
875 newaddrsize = (tmp == NULL) ? 0 : *tmp; 874 newaddrsize = (tmp == NULL) ? 0 : *tmp;
876 875
877 DBG(" -> newintsize=%d, newaddrsize=%d\n", 876 DBG(" -> newintsize=%d, newaddrsize=%d\n",
@@ -928,7 +927,7 @@ static int of_irq_map_oldworld(struct device_node *device, int index,
928 * everything together on these) 927 * everything together on these)
929 */ 928 */
930 while (device) { 929 while (device) {
931 ints = get_property(device, "AAPL,interrupts", &intlen); 930 ints = of_get_property(device, "AAPL,interrupts", &intlen);
932 if (ints != NULL) 931 if (ints != NULL)
933 break; 932 break;
934 device = device->parent; 933 device = device->parent;
@@ -970,13 +969,13 @@ int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq
970 return of_irq_map_oldworld(device, index, out_irq); 969 return of_irq_map_oldworld(device, index, out_irq);
971 970
972 /* Get the interrupts property */ 971 /* Get the interrupts property */
973 intspec = get_property(device, "interrupts", &intlen); 972 intspec = of_get_property(device, "interrupts", &intlen);
974 if (intspec == NULL) 973 if (intspec == NULL)
975 return -EINVAL; 974 return -EINVAL;
976 intlen /= sizeof(u32); 975 intlen /= sizeof(u32);
977 976
978 /* Get the reg property (if any) */ 977 /* Get the reg property (if any) */
979 addr = get_property(device, "reg", NULL); 978 addr = of_get_property(device, "reg", NULL);
980 979
981 /* Look for the interrupt parent. */ 980 /* Look for the interrupt parent. */
982 p = of_irq_find_parent(device); 981 p = of_irq_find_parent(device);
@@ -984,7 +983,7 @@ int of_irq_map_one(struct device_node *device, int index, struct of_irq *out_irq
984 return -EINVAL; 983 return -EINVAL;
985 984
986 /* Get size of interrupt specifier */ 985 /* Get size of interrupt specifier */
987 tmp = get_property(p, "#interrupt-cells", NULL); 986 tmp = of_get_property(p, "#interrupt-cells", NULL);
988 if (tmp == NULL) { 987 if (tmp == NULL) {
989 of_node_put(p); 988 of_node_put(p);
990 return -EINVAL; 989 return -EINVAL;
diff --git a/arch/powerpc/kernel/rtas-proc.c b/arch/powerpc/kernel/rtas-proc.c
index 6cbf2ae5d7aa..190b7ed1dbfb 100644
--- a/arch/powerpc/kernel/rtas-proc.c
+++ b/arch/powerpc/kernel/rtas-proc.c
@@ -450,7 +450,7 @@ static int ppc_rtas_sensors_show(struct seq_file *m, void *v)
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 = get_property(rtas_node, rstr, &llen); 453 loc = of_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++) {
@@ -477,7 +477,7 @@ static int ppc_rtas_find_all_sensors(void)
477 const unsigned int *utmp; 477 const unsigned int *utmp;
478 int len, i; 478 int len, i;
479 479
480 utmp = get_property(rtas_node, "rtas-sensors", &len); 480 utmp = of_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;
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 9d0735a54564..214780798289 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -192,18 +192,19 @@ void rtas_progress(char *s, unsigned short hex)
192 192
193 if (display_width == 0) { 193 if (display_width == 0) {
194 display_width = 0x10; 194 display_width = 0x10;
195 if ((root = find_path_device("/rtas"))) { 195 if ((root = of_find_node_by_path("/rtas"))) {
196 if ((p = get_property(root, 196 if ((p = of_get_property(root,
197 "ibm,display-line-length", NULL))) 197 "ibm,display-line-length", NULL)))
198 display_width = *p; 198 display_width = *p;
199 if ((p = get_property(root, 199 if ((p = of_get_property(root,
200 "ibm,form-feed", NULL))) 200 "ibm,form-feed", NULL)))
201 form_feed = *p; 201 form_feed = *p;
202 if ((p = get_property(root, 202 if ((p = of_get_property(root,
203 "ibm,display-number-of-lines", NULL))) 203 "ibm,display-number-of-lines", NULL)))
204 display_lines = *p; 204 display_lines = *p;
205 row_width = get_property(root, 205 row_width = of_get_property(root,
206 "ibm,display-truncation-length", NULL); 206 "ibm,display-truncation-length", NULL);
207 of_node_put(root);
207 } 208 }
208 display_character = rtas_token("display-character"); 209 display_character = rtas_token("display-character");
209 set_indicator = rtas_token("set-indicator"); 210 set_indicator = rtas_token("set-indicator");
@@ -298,7 +299,7 @@ int rtas_token(const char *service)
298 const int *tokp; 299 const int *tokp;
299 if (rtas.dev == NULL) 300 if (rtas.dev == NULL)
300 return RTAS_UNKNOWN_SERVICE; 301 return RTAS_UNKNOWN_SERVICE;
301 tokp = get_property(rtas.dev, service, NULL); 302 tokp = of_get_property(rtas.dev, service, NULL);
302 return tokp ? *tokp : RTAS_UNKNOWN_SERVICE; 303 return tokp ? *tokp : RTAS_UNKNOWN_SERVICE;
303} 304}
304EXPORT_SYMBOL(rtas_token); 305EXPORT_SYMBOL(rtas_token);
@@ -832,12 +833,12 @@ void __init rtas_initialize(void)
832 if (rtas.dev) { 833 if (rtas.dev) {
833 const u32 *basep, *entryp, *sizep; 834 const u32 *basep, *entryp, *sizep;
834 835
835 basep = get_property(rtas.dev, "linux,rtas-base", NULL); 836 basep = of_get_property(rtas.dev, "linux,rtas-base", NULL);
836 sizep = get_property(rtas.dev, "rtas-size", NULL); 837 sizep = of_get_property(rtas.dev, "rtas-size", NULL);
837 if (basep != NULL && sizep != NULL) { 838 if (basep != NULL && sizep != NULL) {
838 rtas.base = *basep; 839 rtas.base = *basep;
839 rtas.size = *sizep; 840 rtas.size = *sizep;
840 entryp = get_property(rtas.dev, 841 entryp = of_get_property(rtas.dev,
841 "linux,rtas-entry", NULL); 842 "linux,rtas-entry", NULL);
842 if (entryp == NULL) /* Ugh */ 843 if (entryp == NULL) /* Ugh */
843 rtas.entry = rtas.base; 844 rtas.entry = rtas.base;
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
index ace9f4c86e67..f2286822be09 100644
--- a/arch/powerpc/kernel/rtas_pci.c
+++ b/arch/powerpc/kernel/rtas_pci.c
@@ -60,7 +60,7 @@ static int of_device_available(struct device_node * dn)
60{ 60{
61 const char *status; 61 const char *status;
62 62
63 status = get_property(dn, "status", NULL); 63 status = of_get_property(dn, "status", NULL);
64 64
65 if (!status) 65 if (!status)
66 return 1; 66 return 1;
@@ -177,7 +177,7 @@ struct pci_ops rtas_pci_ops = {
177 177
178int is_python(struct device_node *dev) 178int is_python(struct device_node *dev)
179{ 179{
180 const char *model = get_property(dev, "model", NULL); 180 const char *model = of_get_property(dev, "model", NULL);
181 181
182 if (model && strstr(model, "Python")) 182 if (model && strstr(model, "Python"))
183 return 1; 183 return 1;
@@ -247,7 +247,7 @@ static int phb_set_bus_ranges(struct device_node *dev,
247 const int *bus_range; 247 const int *bus_range;
248 unsigned int len; 248 unsigned int len;
249 249
250 bus_range = get_property(dev, "bus-range", &len); 250 bus_range = of_get_property(dev, "bus-range", &len);
251 if (bus_range == NULL || len < 2 * sizeof(int)) { 251 if (bus_range == NULL || len < 2 * sizeof(int)) {
252 return 1; 252 return 1;
253 } 253 }
@@ -274,7 +274,7 @@ int __devinit rtas_setup_phb(struct pci_controller *phb)
274 return 0; 274 return 0;
275} 275}
276 276
277unsigned long __init find_and_init_phbs(void) 277void __init find_and_init_phbs(void)
278{ 278{
279 struct device_node *node; 279 struct device_node *node;
280 struct pci_controller *phb; 280 struct pci_controller *phb;
@@ -309,18 +309,16 @@ unsigned long __init find_and_init_phbs(void)
309 if (of_chosen) { 309 if (of_chosen) {
310 const int *prop; 310 const int *prop;
311 311
312 prop = get_property(of_chosen, 312 prop = of_get_property(of_chosen,
313 "linux,pci-probe-only", NULL); 313 "linux,pci-probe-only", NULL);
314 if (prop) 314 if (prop)
315 pci_probe_only = *prop; 315 pci_probe_only = *prop;
316 316
317 prop = get_property(of_chosen, 317 prop = of_get_property(of_chosen,
318 "linux,pci-assign-all-buses", NULL); 318 "linux,pci-assign-all-buses", NULL);
319 if (prop) 319 if (prop)
320 pci_assign_all_buses = *prop; 320 pci_assign_all_buses = *prop;
321 } 321 }
322
323 return 0;
324} 322}
325 323
326/* RPA-specific bits for removing PHBs */ 324/* RPA-specific bits for removing PHBs */
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 89cfaf49d3de..370803722e47 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -21,7 +21,6 @@
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/initrd.h> 22#include <linux/initrd.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/ide.h>
25#include <linux/seq_file.h> 24#include <linux/seq_file.h>
26#include <linux/ioport.h> 25#include <linux/ioport.h>
27#include <linux/console.h> 26#include <linux/console.h>
@@ -304,26 +303,8 @@ struct seq_operations cpuinfo_op = {
304void __init check_for_initrd(void) 303void __init check_for_initrd(void)
305{ 304{
306#ifdef CONFIG_BLK_DEV_INITRD 305#ifdef CONFIG_BLK_DEV_INITRD
307 const unsigned int *prop; 306 DBG(" -> check_for_initrd() initrd_start=0x%lx initrd_end=0x%lx\n",
308 int len; 307 initrd_start, initrd_end);
309
310 DBG(" -> check_for_initrd()\n");
311
312 if (of_chosen) {
313 prop = get_property(of_chosen, "linux,initrd-start", &len);
314 if (prop != NULL) {
315 initrd_start = (unsigned long)
316 __va(of_read_ulong(prop, len / 4));
317 prop = get_property(of_chosen,
318 "linux,initrd-end", &len);
319 if (prop != NULL) {
320 initrd_end = (unsigned long)
321 __va(of_read_ulong(prop, len / 4));
322 initrd_below_start_ok = 1;
323 } else
324 initrd_start = 0;
325 }
326 }
327 308
328 /* If we were passed an initrd, set the ROOT_DEV properly if the values 309 /* If we were passed an initrd, set the ROOT_DEV properly if the values
329 * look sensible. If not, clear initrd reference. 310 * look sensible. If not, clear initrd reference.
@@ -371,11 +352,12 @@ void __init smp_setup_cpu_maps(void)
371 const int *intserv; 352 const int *intserv;
372 int j, len = sizeof(u32), nthreads = 1; 353 int j, len = sizeof(u32), nthreads = 1;
373 354
374 intserv = get_property(dn, "ibm,ppc-interrupt-server#s", &len); 355 intserv = of_get_property(dn, "ibm,ppc-interrupt-server#s",
356 &len);
375 if (intserv) 357 if (intserv)
376 nthreads = len / sizeof(int); 358 nthreads = len / sizeof(int);
377 else { 359 else {
378 intserv = get_property(dn, "reg", NULL); 360 intserv = of_get_property(dn, "reg", NULL);
379 if (!intserv) 361 if (!intserv)
380 intserv = &cpu; /* assume logical == phys */ 362 intserv = &cpu; /* assume logical == phys */
381 } 363 }
@@ -398,10 +380,10 @@ void __init smp_setup_cpu_maps(void)
398 int num_addr_cell, num_size_cell, maxcpus; 380 int num_addr_cell, num_size_cell, maxcpus;
399 const unsigned int *ireg; 381 const unsigned int *ireg;
400 382
401 num_addr_cell = prom_n_addr_cells(dn); 383 num_addr_cell = of_n_addr_cells(dn);
402 num_size_cell = prom_n_size_cells(dn); 384 num_size_cell = of_n_size_cells(dn);
403 385
404 ireg = get_property(dn, "ibm,lrdr-capacity", NULL); 386 ireg = of_get_property(dn, "ibm,lrdr-capacity", NULL);
405 387
406 if (!ireg) 388 if (!ireg)
407 goto out; 389 goto out;
@@ -496,11 +478,39 @@ void probe_machine(void)
496 printk(KERN_INFO "Using %s machine description\n", ppc_md.name); 478 printk(KERN_INFO "Using %s machine description\n", ppc_md.name);
497} 479}
498 480
481/* Match a class of boards, not a specific device configuration. */
499int check_legacy_ioport(unsigned long base_port) 482int check_legacy_ioport(unsigned long base_port)
500{ 483{
501 if (ppc_md.check_legacy_ioport == NULL) 484 struct device_node *parent, *np = NULL;
502 return 0; 485 int ret = -ENODEV;
503 return ppc_md.check_legacy_ioport(base_port); 486
487 switch(base_port) {
488 case I8042_DATA_REG:
489 np = of_find_node_by_type(NULL, "8042");
490 break;
491 case FDC_BASE: /* FDC1 */
492 np = of_find_node_by_type(NULL, "fdc");
493 break;
494#ifdef CONFIG_PPC_PREP
495 case _PIDXR:
496 case _PNPWRP:
497 case PNPBIOS_BASE:
498 /* implement me */
499#endif
500 default:
501 /* ipmi is supposed to fail here */
502 break;
503 }
504 if (!np)
505 return ret;
506 parent = of_get_parent(np);
507 if (parent) {
508 if (strcmp(parent->type, "isa") == 0)
509 ret = 0;
510 of_node_put(parent);
511 }
512 of_node_put(np);
513 return ret;
504} 514}
505EXPORT_SYMBOL(check_legacy_ioport); 515EXPORT_SYMBOL(check_legacy_ioport);
506 516
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 44a6a3c47feb..35f8f443c14f 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -92,7 +92,8 @@ unsigned long __init early_init(unsigned long dt_ptr)
92 92
93 /* First zero the BSS -- use memset_io, some platforms don't have 93 /* First zero the BSS -- use memset_io, some platforms don't have
94 * caches on yet */ 94 * caches on yet */
95 memset_io((void __iomem *)PTRRELOC(&__bss_start), 0, _end - __bss_start); 95 memset_io((void __iomem *)PTRRELOC(&__bss_start), 0,
96 __bss_stop - __bss_start);
96 97
97 /* 98 /*
98 * Identify the CPU type and fix up code sections 99 * Identify the CPU type and fix up code sections
@@ -195,18 +196,22 @@ EXPORT_SYMBOL(nvram_sync);
195 196
196#endif /* CONFIG_NVRAM */ 197#endif /* CONFIG_NVRAM */
197 198
198static struct cpu cpu_devices[NR_CPUS]; 199static DEFINE_PER_CPU(struct cpu, cpu_devices);
199 200
200int __init ppc_init(void) 201int __init ppc_init(void)
201{ 202{
202 int i; 203 int cpu;
203 204
204 /* clear the progress line */ 205 /* clear the progress line */
205 if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff); 206 if (ppc_md.progress)
207 ppc_md.progress(" ", 0xffff);
206 208
207 /* register CPU devices */ 209 /* register CPU devices */
208 for_each_possible_cpu(i) 210 for_each_possible_cpu(cpu) {
209 register_cpu(&cpu_devices[i], i); 211 struct cpu *c = &per_cpu(cpu_devices, cpu);
212 c->hotpluggable = 1;
213 register_cpu(c, cpu);
214 }
210 215
211 /* call platform init */ 216 /* call platform init */
212 if (ppc_md.init != NULL) { 217 if (ppc_md.init != NULL) {
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 3733de30e84d..22083ce3cc30 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -20,7 +20,6 @@
20#include <linux/reboot.h> 20#include <linux/reboot.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/initrd.h> 22#include <linux/initrd.h>
23#include <linux/ide.h>
24#include <linux/seq_file.h> 23#include <linux/seq_file.h>
25#include <linux/ioport.h> 24#include <linux/ioport.h>
26#include <linux/console.h> 25#include <linux/console.h>
@@ -110,7 +109,7 @@ static void check_smt_enabled(void)
110 dn = of_find_node_by_path("/options"); 109 dn = of_find_node_by_path("/options");
111 110
112 if (dn) { 111 if (dn) {
113 smt_option = get_property(dn, "ibm,smt-enabled", NULL); 112 smt_option = of_get_property(dn, "ibm,smt-enabled", NULL);
114 113
115 if (smt_option) { 114 if (smt_option) {
116 if (!strcmp(smt_option, "on")) 115 if (!strcmp(smt_option, "on"))
@@ -305,10 +304,10 @@ static void __init initialize_cache_info(void)
305 304
306 size = 0; 305 size = 0;
307 lsize = cur_cpu_spec->dcache_bsize; 306 lsize = cur_cpu_spec->dcache_bsize;
308 sizep = get_property(np, "d-cache-size", NULL); 307 sizep = of_get_property(np, "d-cache-size", NULL);
309 if (sizep != NULL) 308 if (sizep != NULL)
310 size = *sizep; 309 size = *sizep;
311 lsizep = get_property(np, dc, NULL); 310 lsizep = of_get_property(np, dc, NULL);
312 if (lsizep != NULL) 311 if (lsizep != NULL)
313 lsize = *lsizep; 312 lsize = *lsizep;
314 if (sizep == 0 || lsizep == 0) 313 if (sizep == 0 || lsizep == 0)
@@ -322,10 +321,10 @@ static void __init initialize_cache_info(void)
322 321
323 size = 0; 322 size = 0;
324 lsize = cur_cpu_spec->icache_bsize; 323 lsize = cur_cpu_spec->icache_bsize;
325 sizep = get_property(np, "i-cache-size", NULL); 324 sizep = of_get_property(np, "i-cache-size", NULL);
326 if (sizep != NULL) 325 if (sizep != NULL)
327 size = *sizep; 326 size = *sizep;
328 lsizep = get_property(np, ic, NULL); 327 lsizep = of_get_property(np, ic, NULL);
329 if (lsizep != NULL) 328 if (lsizep != NULL)
330 lsize = *lsizep; 329 lsize = *lsizep;
331 if (sizep == 0 || lsizep == 0) 330 if (sizep == 0 || lsizep == 0)
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 924d692bc8f9..d8e503b2e1af 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -428,10 +428,6 @@ void generic_mach_cpu_die(void)
428 smp_wmb(); 428 smp_wmb();
429 while (__get_cpu_var(cpu_state) != CPU_UP_PREPARE) 429 while (__get_cpu_var(cpu_state) != CPU_UP_PREPARE)
430 cpu_relax(); 430 cpu_relax();
431
432#ifdef CONFIG_PPC64
433 flush_tlb_pending();
434#endif
435 cpu_set(cpu, cpu_online_map); 431 cpu_set(cpu, cpu_online_map);
436 local_irq_enable(); 432 local_irq_enable();
437} 433}
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index 673e8d9df7f5..047246ad4f65 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -53,10 +53,6 @@
53#include <asm/ppc-pci.h> 53#include <asm/ppc-pci.h>
54#include <asm/syscalls.h> 54#include <asm/syscalls.h>
55 55
56/* readdir & getdents */
57#define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
58#define ROUND_UP(x) (((x)+sizeof(u32)-1) & ~(sizeof(u32)-1))
59
60struct old_linux_dirent32 { 56struct old_linux_dirent32 {
61 u32 d_ino; 57 u32 d_ino;
62 u32 d_offset; 58 u32 d_offset;
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index d57818aea081..933e214c33e8 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -66,16 +66,17 @@ static int __init smt_setup(void)
66 if (!cpu_has_feature(CPU_FTR_SMT)) 66 if (!cpu_has_feature(CPU_FTR_SMT))
67 return -ENODEV; 67 return -ENODEV;
68 68
69 options = find_path_device("/options"); 69 options = of_find_node_by_path("/options");
70 if (!options) 70 if (!options)
71 return -ENODEV; 71 return -ENODEV;
72 72
73 val = get_property(options, "ibm,smt-snooze-delay", NULL); 73 val = of_get_property(options, "ibm,smt-snooze-delay", NULL);
74 if (!smt_snooze_cmdline && val) { 74 if (!smt_snooze_cmdline && val) {
75 for_each_possible_cpu(cpu) 75 for_each_possible_cpu(cpu)
76 per_cpu(smt_snooze_delay, cpu) = *val; 76 per_cpu(smt_snooze_delay, cpu) = *val;
77 } 77 }
78 78
79 of_node_put(options);
79 return 0; 80 return 0;
80} 81}
81__initcall(smt_setup); 82__initcall(smt_setup);
@@ -189,12 +190,12 @@ SYSFS_PMCSETUP(purr, SPRN_PURR);
189SYSFS_PMCSETUP(spurr, SPRN_SPURR); 190SYSFS_PMCSETUP(spurr, SPRN_SPURR);
190SYSFS_PMCSETUP(dscr, SPRN_DSCR); 191SYSFS_PMCSETUP(dscr, SPRN_DSCR);
191 192
192SYSFS_PMCSETUP(pa6t_pmc0, PA6T_SPRN_PMC0); 193SYSFS_PMCSETUP(pa6t_pmc0, SPRN_PA6T_PMC0);
193SYSFS_PMCSETUP(pa6t_pmc1, PA6T_SPRN_PMC1); 194SYSFS_PMCSETUP(pa6t_pmc1, SPRN_PA6T_PMC1);
194SYSFS_PMCSETUP(pa6t_pmc2, PA6T_SPRN_PMC2); 195SYSFS_PMCSETUP(pa6t_pmc2, SPRN_PA6T_PMC2);
195SYSFS_PMCSETUP(pa6t_pmc3, PA6T_SPRN_PMC3); 196SYSFS_PMCSETUP(pa6t_pmc3, SPRN_PA6T_PMC3);
196SYSFS_PMCSETUP(pa6t_pmc4, PA6T_SPRN_PMC4); 197SYSFS_PMCSETUP(pa6t_pmc4, SPRN_PA6T_PMC4);
197SYSFS_PMCSETUP(pa6t_pmc5, PA6T_SPRN_PMC5); 198SYSFS_PMCSETUP(pa6t_pmc5, SPRN_PA6T_PMC5);
198 199
199 200
200static SYSDEV_ATTR(mmcra, 0600, show_mmcra, store_mmcra); 201static SYSDEV_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index f6f0c6b07c4c..7cedef8f5f70 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -834,7 +834,7 @@ static int __init get_freq(char *name, int cells, unsigned long *val)
834 cpu = of_find_node_by_type(NULL, "cpu"); 834 cpu = of_find_node_by_type(NULL, "cpu");
835 835
836 if (cpu) { 836 if (cpu) {
837 fp = get_property(cpu, name, NULL); 837 fp = of_get_property(cpu, name, NULL);
838 if (fp) { 838 if (fp) {
839 found = 1; 839 found = 1;
840 *val = of_read_ulong(fp, cells); 840 *val = of_read_ulong(fp, cells);
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 17724fb2067f..f7862224fe85 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -90,21 +90,11 @@ EXPORT_SYMBOL(unregister_die_notifier);
90 * Trap & Exception support 90 * Trap & Exception support
91 */ 91 */
92 92
93static DEFINE_SPINLOCK(die_lock);
94
95int die(const char *str, struct pt_regs *regs, long err)
96{
97 static int die_counter;
98
99 if (debugger(regs))
100 return 1;
101
102 console_verbose();
103 spin_lock_irq(&die_lock);
104 bust_spinlocks(1);
105#ifdef CONFIG_PMAC_BACKLIGHT 93#ifdef CONFIG_PMAC_BACKLIGHT
94static void pmac_backlight_unblank(void)
95{
106 mutex_lock(&pmac_backlight_mutex); 96 mutex_lock(&pmac_backlight_mutex);
107 if (machine_is(powermac) && pmac_backlight) { 97 if (pmac_backlight) {
108 struct backlight_properties *props; 98 struct backlight_properties *props;
109 99
110 props = &pmac_backlight->props; 100 props = &pmac_backlight->props;
@@ -113,26 +103,67 @@ int die(const char *str, struct pt_regs *regs, long err)
113 backlight_update_status(pmac_backlight); 103 backlight_update_status(pmac_backlight);
114 } 104 }
115 mutex_unlock(&pmac_backlight_mutex); 105 mutex_unlock(&pmac_backlight_mutex);
106}
107#else
108static inline void pmac_backlight_unblank(void) { }
116#endif 109#endif
117 printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter); 110
111int die(const char *str, struct pt_regs *regs, long err)
112{
113 static struct {
114 spinlock_t lock;
115 u32 lock_owner;
116 int lock_owner_depth;
117 } die = {
118 .lock = __SPIN_LOCK_UNLOCKED(die.lock),
119 .lock_owner = -1,
120 .lock_owner_depth = 0
121 };
122 static int die_counter;
123 unsigned long flags;
124
125 if (debugger(regs))
126 return 1;
127
128 oops_enter();
129
130 if (die.lock_owner != raw_smp_processor_id()) {
131 console_verbose();
132 spin_lock_irqsave(&die.lock, flags);
133 die.lock_owner = smp_processor_id();
134 die.lock_owner_depth = 0;
135 bust_spinlocks(1);
136 if (machine_is(powermac))
137 pmac_backlight_unblank();
138 } else {
139 local_save_flags(flags);
140 }
141
142 if (++die.lock_owner_depth < 3) {
143 printk("Oops: %s, sig: %ld [#%d]\n", str, err, ++die_counter);
118#ifdef CONFIG_PREEMPT 144#ifdef CONFIG_PREEMPT
119 printk("PREEMPT "); 145 printk("PREEMPT ");
120#endif 146#endif
121#ifdef CONFIG_SMP 147#ifdef CONFIG_SMP
122 printk("SMP NR_CPUS=%d ", NR_CPUS); 148 printk("SMP NR_CPUS=%d ", NR_CPUS);
123#endif 149#endif
124#ifdef CONFIG_DEBUG_PAGEALLOC 150#ifdef CONFIG_DEBUG_PAGEALLOC
125 printk("DEBUG_PAGEALLOC "); 151 printk("DEBUG_PAGEALLOC ");
126#endif 152#endif
127#ifdef CONFIG_NUMA 153#ifdef CONFIG_NUMA
128 printk("NUMA "); 154 printk("NUMA ");
129#endif 155#endif
130 printk("%s\n", ppc_md.name ? "" : ppc_md.name); 156 printk("%s\n", ppc_md.name ? ppc_md.name : "");
157
158 print_modules();
159 show_regs(regs);
160 } else {
161 printk("Recursive die() failure, output suppressed\n");
162 }
131 163
132 print_modules();
133 show_regs(regs);
134 bust_spinlocks(0); 164 bust_spinlocks(0);
135 spin_unlock_irq(&die_lock); 165 die.lock_owner = -1;
166 spin_unlock_irqrestore(&die.lock, flags);
136 167
137 if (kexec_should_crash(current) || 168 if (kexec_should_crash(current) ||
138 kexec_sr_activated(smp_processor_id())) 169 kexec_sr_activated(smp_processor_id()))
@@ -145,6 +176,7 @@ int die(const char *str, struct pt_regs *regs, long err)
145 if (panic_on_oops) 176 if (panic_on_oops)
146 panic("Fatal exception"); 177 panic("Fatal exception");
147 178
179 oops_exit();
148 do_exit(err); 180 do_exit(err);
149 181
150 return 0; 182 return 0;
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 2968ffeafdb6..9eaefac5053f 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -81,7 +81,7 @@ static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev)
81 struct iommu_table *tbl; 81 struct iommu_table *tbl;
82 unsigned long offset, size; 82 unsigned long offset, size;
83 83
84 dma_window = get_property(dev->dev.archdata.of_node, 84 dma_window = of_get_property(dev->dev.archdata.of_node,
85 "ibm,my-dma-window", NULL); 85 "ibm,my-dma-window", NULL);
86 if (!dma_window) 86 if (!dma_window)
87 return NULL; 87 return NULL;
@@ -226,7 +226,7 @@ struct vio_dev * __devinit vio_register_device_node(struct device_node *of_node)
226 return NULL; 226 return NULL;
227 } 227 }
228 228
229 unit_address = get_property(of_node, "reg", NULL); 229 unit_address = of_get_property(of_node, "reg", NULL);
230 if (unit_address == NULL) { 230 if (unit_address == NULL) {
231 printk(KERN_WARNING "%s: node %s missing 'reg'\n", 231 printk(KERN_WARNING "%s: node %s missing 'reg'\n",
232 __FUNCTION__, 232 __FUNCTION__,
@@ -246,7 +246,7 @@ struct vio_dev * __devinit vio_register_device_node(struct device_node *of_node)
246 viodev->type = of_node->type; 246 viodev->type = of_node->type;
247 viodev->unit_address = *unit_address; 247 viodev->unit_address = *unit_address;
248 if (firmware_has_feature(FW_FEATURE_ISERIES)) { 248 if (firmware_has_feature(FW_FEATURE_ISERIES)) {
249 unit_address = get_property(of_node, 249 unit_address = of_get_property(of_node,
250 "linux,unit_address", NULL); 250 "linux,unit_address", NULL);
251 if (unit_address != NULL) 251 if (unit_address != NULL)
252 viodev->unit_address = *unit_address; 252 viodev->unit_address = *unit_address;
@@ -308,7 +308,7 @@ static int __init vio_bus_init(void)
308 return err; 308 return err;
309 } 309 }
310 310
311 node_vroot = find_devices("vdevice"); 311 node_vroot = of_find_node_by_name(NULL, "vdevice");
312 if (node_vroot) { 312 if (node_vroot) {
313 struct device_node *of_node; 313 struct device_node *of_node;
314 314
@@ -322,6 +322,7 @@ static int __init vio_bus_init(void)
322 __FUNCTION__, of_node); 322 __FUNCTION__, of_node);
323 vio_register_device_node(of_node); 323 vio_register_device_node(of_node);
324 } 324 }
325 of_node_put(node_vroot);
325 } 326 }
326 327
327 return 0; 328 return 0;
@@ -377,7 +378,7 @@ static int vio_hotplug(struct device *dev, char **envp, int num_envp,
377 dn = dev->archdata.of_node; 378 dn = dev->archdata.of_node;
378 if (!dn) 379 if (!dn)
379 return -ENODEV; 380 return -ENODEV;
380 cp = get_property(dn, "compatible", &length); 381 cp = of_get_property(dn, "compatible", &length);
381 if (!cp) 382 if (!cp)
382 return -ENODEV; 383 return -ENODEV;
383 384
@@ -406,12 +407,12 @@ struct bus_type vio_bus_type = {
406 * @which: The property/attribute to be extracted. 407 * @which: The property/attribute to be extracted.
407 * @length: Pointer to length of returned data size (unused if NULL). 408 * @length: Pointer to length of returned data size (unused if NULL).
408 * 409 *
409 * Calls prom.c's get_property() to return the value of the 410 * Calls prom.c's of_get_property() to return the value of the
410 * attribute specified by @which 411 * attribute specified by @which
411*/ 412*/
412const void *vio_get_attribute(struct vio_dev *vdev, char *which, int *length) 413const void *vio_get_attribute(struct vio_dev *vdev, char *which, int *length)
413{ 414{
414 return get_property(vdev->dev.archdata.of_node, which, length); 415 return of_get_property(vdev->dev.archdata.of_node, which, length);
415} 416}
416EXPORT_SYMBOL(vio_get_attribute); 417EXPORT_SYMBOL(vio_get_attribute);
417 418
@@ -443,7 +444,7 @@ struct vio_dev *vio_find_node(struct device_node *vnode)
443 char kobj_name[BUS_ID_SIZE]; 444 char kobj_name[BUS_ID_SIZE];
444 445
445 /* construct the kobject name from the device node */ 446 /* construct the kobject name from the device node */
446 unit_address = get_property(vnode, "reg", NULL); 447 unit_address = of_get_property(vnode, "reg", NULL);
447 if (!unit_address) 448 if (!unit_address)
448 return NULL; 449 return NULL;
449 snprintf(kobj_name, BUS_ID_SIZE, "%x", *unit_address); 450 snprintf(kobj_name, BUS_ID_SIZE, "%x", *unit_address);
diff --git a/arch/powerpc/lib/copyuser_64.S b/arch/powerpc/lib/copyuser_64.S
index a6b54cb97c49..25ec5378afa4 100644
--- a/arch/powerpc/lib/copyuser_64.S
+++ b/arch/powerpc/lib/copyuser_64.S
@@ -24,7 +24,7 @@ _GLOBAL(__copy_tofrom_user)
24 dcbt 0,r4 24 dcbt 0,r4
25 beq .Lcopy_page_4K 25 beq .Lcopy_page_4K
26 andi. r6,r6,7 26 andi. r6,r6,7
27 mtcrf 0x01,r5 27 PPC_MTOCRF 0x01,r5
28 blt cr1,.Lshort_copy 28 blt cr1,.Lshort_copy
29 bne .Ldst_unaligned 29 bne .Ldst_unaligned
30.Ldst_aligned: 30.Ldst_aligned:
@@ -135,7 +135,7 @@ _GLOBAL(__copy_tofrom_user)
135 b .Ldo_tail 135 b .Ldo_tail
136 136
137.Ldst_unaligned: 137.Ldst_unaligned:
138 mtcrf 0x01,r6 /* put #bytes to 8B bdry into cr7 */ 138 PPC_MTOCRF 0x01,r6 /* put #bytes to 8B bdry into cr7 */
139 subf r5,r6,r5 139 subf r5,r6,r5
140 li r7,0 140 li r7,0
141 cmpldi r1,r5,16 141 cmpldi r1,r5,16
@@ -150,7 +150,7 @@ _GLOBAL(__copy_tofrom_user)
1502: bf cr7*4+1,3f 1502: bf cr7*4+1,3f
15137: lwzx r0,r7,r4 15137: lwzx r0,r7,r4
15283: stwx r0,r7,r3 15283: stwx r0,r7,r3
1533: mtcrf 0x01,r5 1533: PPC_MTOCRF 0x01,r5
154 add r4,r6,r4 154 add r4,r6,r4
155 add r3,r6,r3 155 add r3,r6,r3
156 b .Ldst_aligned 156 b .Ldst_aligned
diff --git a/arch/powerpc/lib/locks.c b/arch/powerpc/lib/locks.c
index 80b482ca30df..79d0fa3a470d 100644
--- a/arch/powerpc/lib/locks.c
+++ b/arch/powerpc/lib/locks.c
@@ -43,9 +43,11 @@ void __spin_yield(raw_spinlock_t *lock)
43 if (firmware_has_feature(FW_FEATURE_ISERIES)) 43 if (firmware_has_feature(FW_FEATURE_ISERIES))
44 HvCall2(HvCallBaseYieldProcessor, HvCall_YieldToProc, 44 HvCall2(HvCallBaseYieldProcessor, HvCall_YieldToProc,
45 ((u64)holder_cpu << 32) | yield_count); 45 ((u64)holder_cpu << 32) | yield_count);
46#ifdef CONFIG_PPC_SPLPAR
46 else 47 else
47 plpar_hcall_norets(H_CONFER, 48 plpar_hcall_norets(H_CONFER,
48 get_hard_smp_processor_id(holder_cpu), yield_count); 49 get_hard_smp_processor_id(holder_cpu), yield_count);
50#endif
49} 51}
50 52
51/* 53/*
@@ -72,9 +74,11 @@ void __rw_yield(raw_rwlock_t *rw)
72 if (firmware_has_feature(FW_FEATURE_ISERIES)) 74 if (firmware_has_feature(FW_FEATURE_ISERIES))
73 HvCall2(HvCallBaseYieldProcessor, HvCall_YieldToProc, 75 HvCall2(HvCallBaseYieldProcessor, HvCall_YieldToProc,
74 ((u64)holder_cpu << 32) | yield_count); 76 ((u64)holder_cpu << 32) | yield_count);
77#ifdef CONFIG_PPC_SPLPAR
75 else 78 else
76 plpar_hcall_norets(H_CONFER, 79 plpar_hcall_norets(H_CONFER,
77 get_hard_smp_processor_id(holder_cpu), yield_count); 80 get_hard_smp_processor_id(holder_cpu), yield_count);
81#endif
78} 82}
79#endif 83#endif
80 84
diff --git a/arch/powerpc/lib/mem_64.S b/arch/powerpc/lib/mem_64.S
index 68df20283ff5..11ce045e21fd 100644
--- a/arch/powerpc/lib/mem_64.S
+++ b/arch/powerpc/lib/mem_64.S
@@ -19,7 +19,7 @@ _GLOBAL(memset)
19 rlwimi r4,r4,16,0,15 19 rlwimi r4,r4,16,0,15
20 cmplw cr1,r5,r0 /* do we get that far? */ 20 cmplw cr1,r5,r0 /* do we get that far? */
21 rldimi r4,r4,32,0 21 rldimi r4,r4,32,0
22 mtcrf 1,r0 22 PPC_MTOCRF 1,r0
23 mr r6,r3 23 mr r6,r3
24 blt cr1,8f 24 blt cr1,8f
25 beq+ 3f /* if already 8-byte aligned */ 25 beq+ 3f /* if already 8-byte aligned */
@@ -49,7 +49,7 @@ _GLOBAL(memset)
49 bdnz 4b 49 bdnz 4b
505: srwi. r0,r5,3 505: srwi. r0,r5,3
51 clrlwi r5,r5,29 51 clrlwi r5,r5,29
52 mtcrf 1,r0 52 PPC_MTOCRF 1,r0
53 beq 8f 53 beq 8f
54 bf 29,6f 54 bf 29,6f
55 std r4,0(r6) 55 std r4,0(r6)
@@ -65,7 +65,7 @@ _GLOBAL(memset)
65 std r4,0(r6) 65 std r4,0(r6)
66 addi r6,r6,8 66 addi r6,r6,8
678: cmpwi r5,0 678: cmpwi r5,0
68 mtcrf 1,r5 68 PPC_MTOCRF 1,r5
69 beqlr+ 69 beqlr+
70 bf 29,9f 70 bf 29,9f
71 stw r4,0(r6) 71 stw r4,0(r6)
diff --git a/arch/powerpc/lib/memcpy_64.S b/arch/powerpc/lib/memcpy_64.S
index 7173ba98f427..3f131129d1c1 100644
--- a/arch/powerpc/lib/memcpy_64.S
+++ b/arch/powerpc/lib/memcpy_64.S
@@ -12,7 +12,7 @@
12 .align 7 12 .align 7
13_GLOBAL(memcpy) 13_GLOBAL(memcpy)
14 std r3,48(r1) /* save destination pointer for return value */ 14 std r3,48(r1) /* save destination pointer for return value */
15 mtcrf 0x01,r5 15 PPC_MTOCRF 0x01,r5
16 cmpldi cr1,r5,16 16 cmpldi cr1,r5,16
17 neg r6,r3 # LS 3 bits = # bytes to 8-byte dest bdry 17 neg r6,r3 # LS 3 bits = # bytes to 8-byte dest bdry
18 andi. r6,r6,7 18 andi. r6,r6,7
@@ -128,7 +128,7 @@ _GLOBAL(memcpy)
128 b .Ldo_tail 128 b .Ldo_tail
129 129
130.Ldst_unaligned: 130.Ldst_unaligned:
131 mtcrf 0x01,r6 # put #bytes to 8B bdry into cr7 131 PPC_MTOCRF 0x01,r6 # put #bytes to 8B bdry into cr7
132 subf r5,r6,r5 132 subf r5,r6,r5
133 li r7,0 133 li r7,0
134 cmpldi r1,r5,16 134 cmpldi r1,r5,16
@@ -143,7 +143,7 @@ _GLOBAL(memcpy)
1432: bf cr7*4+1,3f 1432: bf cr7*4+1,3f
144 lwzx r0,r7,r4 144 lwzx r0,r7,r4
145 stwx r0,r7,r3 145 stwx r0,r7,r3
1463: mtcrf 0x01,r5 1463: PPC_MTOCRF 0x01,r5
147 add r4,r6,r4 147 add r4,r6,r4
148 add r3,r6,r3 148 add r3,r6,r3
149 b .Ldst_aligned 149 b .Ldst_aligned
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 7e8ded051b5b..4aae0c387645 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -54,7 +54,7 @@ static int __kprobes branch_taken(unsigned int instr, struct pt_regs *regs)
54 */ 54 */
55int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr) 55int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr)
56{ 56{
57 unsigned int opcode, rd; 57 unsigned int opcode, rs, rb, rd, spr;
58 unsigned long int imm; 58 unsigned long int imm;
59 59
60 opcode = instr >> 26; 60 opcode = instr >> 26;
@@ -152,6 +152,49 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr)
152 regs->nip &= 0xffffffffUL; 152 regs->nip &= 0xffffffffUL;
153 return 1; 153 return 1;
154#endif 154#endif
155 case 0x26: /* mfcr */
156 regs->gpr[rd] = regs->ccr;
157 regs->gpr[rd] &= 0xffffffffUL;
158 goto mtspr_out;
159 case 0x2a6: /* mfspr */
160 spr = (instr >> 11) & 0x3ff;
161 switch (spr) {
162 case 0x20: /* mfxer */
163 regs->gpr[rd] = regs->xer;
164 regs->gpr[rd] &= 0xffffffffUL;
165 goto mtspr_out;
166 case 0x100: /* mflr */
167 regs->gpr[rd] = regs->link;
168 goto mtspr_out;
169 case 0x120: /* mfctr */
170 regs->gpr[rd] = regs->ctr;
171 goto mtspr_out;
172 }
173 break;
174 case 0x378: /* orx */
175 rs = (instr >> 21) & 0x1f;
176 rb = (instr >> 11) & 0x1f;
177 if (rs == rb) { /* mr */
178 rd = (instr >> 16) & 0x1f;
179 regs->gpr[rd] = regs->gpr[rs];
180 goto mtspr_out;
181 }
182 break;
183 case 0x3a6: /* mtspr */
184 spr = (instr >> 11) & 0x3ff;
185 switch (spr) {
186 case 0x20: /* mtxer */
187 regs->xer = (regs->gpr[rd] & 0xffffffffUL);
188 goto mtspr_out;
189 case 0x100: /* mtlr */
190 regs->link = regs->gpr[rd];
191 goto mtspr_out;
192 case 0x120: /* mtctr */
193 regs->ctr = regs->gpr[rd];
194mtspr_out:
195 regs->nip += 4;
196 return 1;
197 }
155 } 198 }
156 } 199 }
157 return 0; 200 return 0;
diff --git a/arch/powerpc/mm/hash_low_32.S b/arch/powerpc/mm/hash_low_32.S
index bd68df5fa78a..ddceefc06ecc 100644
--- a/arch/powerpc/mm/hash_low_32.S
+++ b/arch/powerpc/mm/hash_low_32.S
@@ -283,6 +283,7 @@ Hash_msk = (((1 << Hash_bits) - 1) * 64)
283#define PTEG_SIZE 64 283#define PTEG_SIZE 64
284#define LG_PTEG_SIZE 6 284#define LG_PTEG_SIZE 6
285#define LDPTEu lwzu 285#define LDPTEu lwzu
286#define LDPTE lwz
286#define STPTE stw 287#define STPTE stw
287#define CMPPTE cmpw 288#define CMPPTE cmpw
288#define PTE_H 0x40 289#define PTE_H 0x40
@@ -389,13 +390,30 @@ _GLOBAL(hash_page_patch_C)
389 * and we know there is a definite (although small) speed 390 * and we know there is a definite (although small) speed
390 * advantage to putting the PTE in the primary PTEG, we always 391 * advantage to putting the PTE in the primary PTEG, we always
391 * put the PTE in the primary PTEG. 392 * put the PTE in the primary PTEG.
393 *
394 * In addition, we skip any slot that is mapping kernel text in
395 * order to avoid a deadlock when not using BAT mappings if
396 * trying to hash in the kernel hash code itself after it has
397 * already taken the hash table lock. This works in conjunction
398 * with pre-faulting of the kernel text.
399 *
400 * If the hash table bucket is full of kernel text entries, we'll
401 * lockup here but that shouldn't happen
392 */ 402 */
393 addis r4,r7,next_slot@ha 403
4041: addis r4,r7,next_slot@ha /* get next evict slot */
394 lwz r6,next_slot@l(r4) 405 lwz r6,next_slot@l(r4)
395 addi r6,r6,PTE_SIZE 406 addi r6,r6,PTE_SIZE /* search for candidate */
396 andi. r6,r6,7*PTE_SIZE 407 andi. r6,r6,7*PTE_SIZE
397 stw r6,next_slot@l(r4) 408 stw r6,next_slot@l(r4)
398 add r4,r3,r6 409 add r4,r3,r6
410 LDPTE r0,PTE_SIZE/2(r4) /* get PTE second word */
411 clrrwi r0,r0,12
412 lis r6,etext@h
413 ori r6,r6,etext@l /* get etext */
414 tophys(r6,r6)
415 cmpl cr0,r0,r6 /* compare and try again */
416 blt 1b
399 417
400#ifndef CONFIG_SMP 418#ifndef CONFIG_SMP
401 /* Store PTE in PTEG */ 419 /* Store PTE in PTEG */
diff --git a/arch/powerpc/mm/hash_low_64.S b/arch/powerpc/mm/hash_low_64.S
index 9bc0a9c2b9bc..e64ce3eec36e 100644
--- a/arch/powerpc/mm/hash_low_64.S
+++ b/arch/powerpc/mm/hash_low_64.S
@@ -445,9 +445,12 @@ END_FTR_SECTION(CPU_FTR_NOEXECUTE|CPU_FTR_COHERENT_ICACHE, CPU_FTR_NOEXECUTE)
445 445
446htab_insert_pte: 446htab_insert_pte:
447 /* real page number in r5, PTE RPN value + index */ 447 /* real page number in r5, PTE RPN value + index */
448 rldicl r5,r31,64-PTE_RPN_SHIFT,PTE_RPN_SHIFT 448 andis. r0,r31,_PAGE_4K_PFN@h
449 srdi r5,r31,PTE_RPN_SHIFT
450 bne- htab_special_pfn
449 sldi r5,r5,PAGE_SHIFT-HW_PAGE_SHIFT 451 sldi r5,r5,PAGE_SHIFT-HW_PAGE_SHIFT
450 add r5,r5,r25 452 add r5,r5,r25
453htab_special_pfn:
451 sldi r5,r5,HW_PAGE_SHIFT 454 sldi r5,r5,HW_PAGE_SHIFT
452 455
453 /* Calculate primary group hash */ 456 /* Calculate primary group hash */
diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c
index 6f1016acdbf6..79aedaf36f2b 100644
--- a/arch/powerpc/mm/hash_native_64.c
+++ b/arch/powerpc/mm/hash_native_64.c
@@ -505,7 +505,7 @@ static inline int tlb_batching_enabled(void)
505 int enabled = 1; 505 int enabled = 1;
506 506
507 if (root) { 507 if (root) {
508 const char *model = get_property(root, "model", NULL); 508 const char *model = of_get_property(root, "model", NULL);
509 if (model && !strcmp(model, "IBM,9076-N81")) 509 if (model && !strcmp(model, "IBM,9076-N81"))
510 enabled = 0; 510 enabled = 0;
511 of_node_put(root); 511 of_node_put(root);
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 3c7fe2c65b5a..49618461defb 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -100,6 +100,11 @@ unsigned int HPAGE_SHIFT;
100#ifdef CONFIG_PPC_64K_PAGES 100#ifdef CONFIG_PPC_64K_PAGES
101int mmu_ci_restrictions; 101int mmu_ci_restrictions;
102#endif 102#endif
103#ifdef CONFIG_DEBUG_PAGEALLOC
104static u8 *linear_map_hash_slots;
105static unsigned long linear_map_hash_count;
106static spinlock_t linear_map_hash_lock;
107#endif /* CONFIG_DEBUG_PAGEALLOC */
103 108
104/* There are definitions of page sizes arrays to be used when none 109/* There are definitions of page sizes arrays to be used when none
105 * is provided by the firmware. 110 * is provided by the firmware.
@@ -152,11 +157,10 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
152 157
153 for (vaddr = vstart, paddr = pstart; vaddr < vend; 158 for (vaddr = vstart, paddr = pstart; vaddr < vend;
154 vaddr += step, paddr += step) { 159 vaddr += step, paddr += step) {
155 unsigned long vpn, hash, hpteg; 160 unsigned long hash, hpteg;
156 unsigned long vsid = get_kernel_vsid(vaddr); 161 unsigned long vsid = get_kernel_vsid(vaddr);
157 unsigned long va = (vsid << 28) | (vaddr & 0x0fffffff); 162 unsigned long va = (vsid << 28) | (vaddr & 0x0fffffff);
158 163
159 vpn = va >> shift;
160 tmp_mode = mode; 164 tmp_mode = mode;
161 165
162 /* Make non-kernel text non-executable */ 166 /* Make non-kernel text non-executable */
@@ -174,6 +178,10 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
174 178
175 if (ret < 0) 179 if (ret < 0)
176 break; 180 break;
181#ifdef CONFIG_DEBUG_PAGEALLOC
182 if ((paddr >> PAGE_SHIFT) < linear_map_hash_count)
183 linear_map_hash_slots[paddr >> PAGE_SHIFT] = ret | 0x80;
184#endif /* CONFIG_DEBUG_PAGEALLOC */
177 } 185 }
178 return ret < 0 ? ret : 0; 186 return ret < 0 ? ret : 0;
179} 187}
@@ -281,6 +289,7 @@ static void __init htab_init_page_sizes(void)
281 memcpy(mmu_psize_defs, mmu_psize_defaults_gp, 289 memcpy(mmu_psize_defs, mmu_psize_defaults_gp,
282 sizeof(mmu_psize_defaults_gp)); 290 sizeof(mmu_psize_defaults_gp));
283 found: 291 found:
292#ifndef CONFIG_DEBUG_PAGEALLOC
284 /* 293 /*
285 * Pick a size for the linear mapping. Currently, we only support 294 * Pick a size for the linear mapping. Currently, we only support
286 * 16M, 1M and 4K which is the default 295 * 16M, 1M and 4K which is the default
@@ -289,6 +298,7 @@ static void __init htab_init_page_sizes(void)
289 mmu_linear_psize = MMU_PAGE_16M; 298 mmu_linear_psize = MMU_PAGE_16M;
290 else if (mmu_psize_defs[MMU_PAGE_1M].shift) 299 else if (mmu_psize_defs[MMU_PAGE_1M].shift)
291 mmu_linear_psize = MMU_PAGE_1M; 300 mmu_linear_psize = MMU_PAGE_1M;
301#endif /* CONFIG_DEBUG_PAGEALLOC */
292 302
293#ifdef CONFIG_PPC_64K_PAGES 303#ifdef CONFIG_PPC_64K_PAGES
294 /* 304 /*
@@ -303,12 +313,14 @@ static void __init htab_init_page_sizes(void)
303 if (mmu_psize_defs[MMU_PAGE_64K].shift) { 313 if (mmu_psize_defs[MMU_PAGE_64K].shift) {
304 mmu_virtual_psize = MMU_PAGE_64K; 314 mmu_virtual_psize = MMU_PAGE_64K;
305 mmu_vmalloc_psize = MMU_PAGE_64K; 315 mmu_vmalloc_psize = MMU_PAGE_64K;
316 if (mmu_linear_psize == MMU_PAGE_4K)
317 mmu_linear_psize = MMU_PAGE_64K;
306 if (cpu_has_feature(CPU_FTR_CI_LARGE_PAGE)) 318 if (cpu_has_feature(CPU_FTR_CI_LARGE_PAGE))
307 mmu_io_psize = MMU_PAGE_64K; 319 mmu_io_psize = MMU_PAGE_64K;
308 else 320 else
309 mmu_ci_restrictions = 1; 321 mmu_ci_restrictions = 1;
310 } 322 }
311#endif 323#endif /* CONFIG_PPC_64K_PAGES */
312 324
313 printk(KERN_DEBUG "Page orders: linear mapping = %d, " 325 printk(KERN_DEBUG "Page orders: linear mapping = %d, "
314 "virtual = %d, io = %d\n", 326 "virtual = %d, io = %d\n",
@@ -476,6 +488,13 @@ void __init htab_initialize(void)
476 488
477 mode_rw = _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_COHERENT | PP_RWXX; 489 mode_rw = _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_COHERENT | PP_RWXX;
478 490
491#ifdef CONFIG_DEBUG_PAGEALLOC
492 linear_map_hash_count = lmb_end_of_DRAM() >> PAGE_SHIFT;
493 linear_map_hash_slots = __va(lmb_alloc_base(linear_map_hash_count,
494 1, lmb.rmo_size));
495 memset(linear_map_hash_slots, 0, linear_map_hash_count);
496#endif /* CONFIG_DEBUG_PAGEALLOC */
497
479 /* On U3 based machines, we need to reserve the DART area and 498 /* On U3 based machines, we need to reserve the DART area and
480 * _NOT_ map it to avoid cache paradoxes as it's remapped non 499 * _NOT_ map it to avoid cache paradoxes as it's remapped non
481 * cacheable later on 500 * cacheable later on
@@ -573,6 +592,27 @@ unsigned int hash_page_do_lazy_icache(unsigned int pp, pte_t pte, int trap)
573 return pp; 592 return pp;
574} 593}
575 594
595/*
596 * Demote a segment to using 4k pages.
597 * For now this makes the whole process use 4k pages.
598 */
599void demote_segment_4k(struct mm_struct *mm, unsigned long addr)
600{
601#ifdef CONFIG_PPC_64K_PAGES
602 if (mm->context.user_psize == MMU_PAGE_4K)
603 return;
604 mm->context.user_psize = MMU_PAGE_4K;
605 mm->context.sllp = SLB_VSID_USER | mmu_psize_defs[MMU_PAGE_4K].sllp;
606 get_paca()->context = mm->context;
607 slb_flush_and_rebolt();
608#ifdef CONFIG_SPE_BASE
609 spu_flush_all_slbs(mm);
610#endif
611#endif
612}
613
614EXPORT_SYMBOL_GPL(demote_segment_4k);
615
576/* Result code is: 616/* Result code is:
577 * 0 - handled 617 * 0 - handled
578 * 1 - normal page fault 618 * 1 - normal page fault
@@ -665,15 +705,19 @@ int hash_page(unsigned long ea, unsigned long access, unsigned long trap)
665#ifndef CONFIG_PPC_64K_PAGES 705#ifndef CONFIG_PPC_64K_PAGES
666 rc = __hash_page_4K(ea, access, vsid, ptep, trap, local); 706 rc = __hash_page_4K(ea, access, vsid, ptep, trap, local);
667#else 707#else
708 /* If _PAGE_4K_PFN is set, make sure this is a 4k segment */
709 if (pte_val(*ptep) & _PAGE_4K_PFN) {
710 demote_segment_4k(mm, ea);
711 psize = MMU_PAGE_4K;
712 }
713
668 if (mmu_ci_restrictions) { 714 if (mmu_ci_restrictions) {
669 /* If this PTE is non-cacheable, switch to 4k */ 715 /* If this PTE is non-cacheable, switch to 4k */
670 if (psize == MMU_PAGE_64K && 716 if (psize == MMU_PAGE_64K &&
671 (pte_val(*ptep) & _PAGE_NO_CACHE)) { 717 (pte_val(*ptep) & _PAGE_NO_CACHE)) {
672 if (user_region) { 718 if (user_region) {
719 demote_segment_4k(mm, ea);
673 psize = MMU_PAGE_4K; 720 psize = MMU_PAGE_4K;
674 mm->context.user_psize = MMU_PAGE_4K;
675 mm->context.sllp = SLB_VSID_USER |
676 mmu_psize_defs[MMU_PAGE_4K].sllp;
677 } else if (ea < VMALLOC_END) { 721 } else if (ea < VMALLOC_END) {
678 /* 722 /*
679 * some driver did a non-cacheable mapping 723 * some driver did a non-cacheable mapping
@@ -756,16 +800,8 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,
756 if (mmu_ci_restrictions) { 800 if (mmu_ci_restrictions) {
757 /* If this PTE is non-cacheable, switch to 4k */ 801 /* If this PTE is non-cacheable, switch to 4k */
758 if (mm->context.user_psize == MMU_PAGE_64K && 802 if (mm->context.user_psize == MMU_PAGE_64K &&
759 (pte_val(*ptep) & _PAGE_NO_CACHE)) { 803 (pte_val(*ptep) & _PAGE_NO_CACHE))
760 mm->context.user_psize = MMU_PAGE_4K; 804 demote_segment_4k(mm, ea);
761 mm->context.sllp = SLB_VSID_USER |
762 mmu_psize_defs[MMU_PAGE_4K].sllp;
763 get_paca()->context = mm->context;
764 slb_flush_and_rebolt();
765#ifdef CONFIG_SPE_BASE
766 spu_flush_all_slbs(mm);
767#endif
768 }
769 } 805 }
770 if (mm->context.user_psize == MMU_PAGE_64K) 806 if (mm->context.user_psize == MMU_PAGE_64K)
771 __hash_page_64K(ea, access, vsid, ptep, trap, local); 807 __hash_page_64K(ea, access, vsid, ptep, trap, local);
@@ -825,3 +861,62 @@ void low_hash_fault(struct pt_regs *regs, unsigned long address)
825 } 861 }
826 bad_page_fault(regs, address, SIGBUS); 862 bad_page_fault(regs, address, SIGBUS);
827} 863}
864
865#ifdef CONFIG_DEBUG_PAGEALLOC
866static void kernel_map_linear_page(unsigned long vaddr, unsigned long lmi)
867{
868 unsigned long hash, hpteg, vsid = get_kernel_vsid(vaddr);
869 unsigned long va = (vsid << 28) | (vaddr & 0x0fffffff);
870 unsigned long mode = _PAGE_ACCESSED | _PAGE_DIRTY |
871 _PAGE_COHERENT | PP_RWXX | HPTE_R_N;
872 int ret;
873
874 hash = hpt_hash(va, PAGE_SHIFT);
875 hpteg = ((hash & htab_hash_mask) * HPTES_PER_GROUP);
876
877 ret = ppc_md.hpte_insert(hpteg, va, __pa(vaddr),
878 mode, HPTE_V_BOLTED, mmu_linear_psize);
879 BUG_ON (ret < 0);
880 spin_lock(&linear_map_hash_lock);
881 BUG_ON(linear_map_hash_slots[lmi] & 0x80);
882 linear_map_hash_slots[lmi] = ret | 0x80;
883 spin_unlock(&linear_map_hash_lock);
884}
885
886static void kernel_unmap_linear_page(unsigned long vaddr, unsigned long lmi)
887{
888 unsigned long hash, hidx, slot, vsid = get_kernel_vsid(vaddr);
889 unsigned long va = (vsid << 28) | (vaddr & 0x0fffffff);
890
891 hash = hpt_hash(va, PAGE_SHIFT);
892 spin_lock(&linear_map_hash_lock);
893 BUG_ON(!(linear_map_hash_slots[lmi] & 0x80));
894 hidx = linear_map_hash_slots[lmi] & 0x7f;
895 linear_map_hash_slots[lmi] = 0;
896 spin_unlock(&linear_map_hash_lock);
897 if (hidx & _PTEIDX_SECONDARY)
898 hash = ~hash;
899 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
900 slot += hidx & _PTEIDX_GROUP_IX;
901 ppc_md.hpte_invalidate(slot, va, mmu_linear_psize, 0);
902}
903
904void kernel_map_pages(struct page *page, int numpages, int enable)
905{
906 unsigned long flags, vaddr, lmi;
907 int i;
908
909 local_irq_save(flags);
910 for (i = 0; i < numpages; i++, page++) {
911 vaddr = (unsigned long)page_address(page);
912 lmi = __pa(vaddr) >> PAGE_SHIFT;
913 if (lmi >= linear_map_hash_count)
914 continue;
915 if (enable)
916 kernel_map_linear_page(vaddr, lmi);
917 else
918 kernel_unmap_linear_page(vaddr, lmi);
919 }
920 local_irq_restore(flags);
921}
922#endif /* CONFIG_DEBUG_PAGEALLOC */
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index f6ffaaa7a5bf..8508f973d9cc 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -316,12 +316,11 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
316{ 316{
317 if (pte_present(*ptep)) { 317 if (pte_present(*ptep)) {
318 /* We open-code pte_clear because we need to pass the right 318 /* We open-code pte_clear because we need to pass the right
319 * argument to hpte_update (huge / !huge) 319 * argument to hpte_need_flush (huge / !huge). Might not be
320 * necessary anymore if we make hpte_need_flush() get the
321 * page size from the slices
320 */ 322 */
321 unsigned long old = pte_update(ptep, ~0UL); 323 pte_update(mm, addr & HPAGE_MASK, ptep, ~0UL, 1);
322 if (old & _PAGE_HASHPTE)
323 hpte_update(mm, addr & HPAGE_MASK, ptep, old, 1);
324 flush_tlb_pending();
325 } 324 }
326 *ptep = __pte(pte_val(pte) & ~_PAGE_HPTEFLAGS); 325 *ptep = __pte(pte_val(pte) & ~_PAGE_HPTEFLAGS);
327} 326}
@@ -329,12 +328,7 @@ void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
329pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, 328pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
330 pte_t *ptep) 329 pte_t *ptep)
331{ 330{
332 unsigned long old = pte_update(ptep, ~0UL); 331 unsigned long old = pte_update(mm, addr, ptep, ~0UL, 1);
333
334 if (old & _PAGE_HASHPTE)
335 hpte_update(mm, addr & HPAGE_MASK, ptep, old, 1);
336 *ptep = __pte(0);
337
338 return __pte(old); 332 return __pte(old);
339} 333}
340 334
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index 0e53ca8f02fb..5fce6ccecb8d 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -115,6 +115,10 @@ void MMU_setup(void)
115 if (strstr(cmd_line, "noltlbs")) { 115 if (strstr(cmd_line, "noltlbs")) {
116 __map_without_ltlbs = 1; 116 __map_without_ltlbs = 1;
117 } 117 }
118#ifdef CONFIG_DEBUG_PAGEALLOC
119 __map_without_bats = 1;
120 __map_without_ltlbs = 1;
121#endif
118} 122}
119 123
120/* 124/*
diff --git a/arch/powerpc/mm/lmb.c b/arch/powerpc/mm/lmb.c
index 716a2906a24d..e3a1e8dc536a 100644
--- a/arch/powerpc/mm/lmb.c
+++ b/arch/powerpc/mm/lmb.c
@@ -146,6 +146,10 @@ static long __init lmb_add_region(struct lmb_region *rgn, unsigned long base,
146 unsigned long rgnbase = rgn->region[i].base; 146 unsigned long rgnbase = rgn->region[i].base;
147 unsigned long rgnsize = rgn->region[i].size; 147 unsigned long rgnsize = rgn->region[i].size;
148 148
149 if ((rgnbase == base) && (rgnsize == size))
150 /* Already have this region, so we're done */
151 return 0;
152
149 adjacent = lmb_addrs_adjacent(base,size,rgnbase,rgnsize); 153 adjacent = lmb_addrs_adjacent(base,size,rgnbase,rgnsize);
150 if ( adjacent > 0 ) { 154 if ( adjacent > 0 ) {
151 rgn->region[i].base -= size; 155 rgn->region[i].base -= size;
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 52f397c108a7..c4bcd7546424 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -58,9 +58,6 @@ int init_bootmem_done;
58int mem_init_done; 58int mem_init_done;
59unsigned long memory_limit; 59unsigned long memory_limit;
60 60
61extern void hash_preload(struct mm_struct *mm, unsigned long ea,
62 unsigned long access, unsigned long trap);
63
64int page_is_ram(unsigned long pfn) 61int page_is_ram(unsigned long pfn)
65{ 62{
66 unsigned long paddr = (pfn << PAGE_SHIFT); 63 unsigned long paddr = (pfn << PAGE_SHIFT);
diff --git a/arch/powerpc/mm/mmu_decl.h b/arch/powerpc/mm/mmu_decl.h
index bea2d21ac6f7..9c4538bb04b0 100644
--- a/arch/powerpc/mm/mmu_decl.h
+++ b/arch/powerpc/mm/mmu_decl.h
@@ -19,9 +19,14 @@
19 * 2 of the License, or (at your option) any later version. 19 * 2 of the License, or (at your option) any later version.
20 * 20 *
21 */ 21 */
22#include <linux/mm.h>
22#include <asm/tlbflush.h> 23#include <asm/tlbflush.h>
23#include <asm/mmu.h> 24#include <asm/mmu.h>
24 25
26extern void hash_preload(struct mm_struct *mm, unsigned long ea,
27 unsigned long access, unsigned long trap);
28
29
25#ifdef CONFIG_PPC32 30#ifdef CONFIG_PPC32
26extern void mapin_ram(void); 31extern void mapin_ram(void);
27extern int map_page(unsigned long va, phys_addr_t pa, int flags); 32extern int map_page(unsigned long va, phys_addr_t pa, int flags);
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index e86c37c82cfd..b3a592b25ab3 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -74,7 +74,7 @@ static struct device_node * __cpuinit find_cpu_node(unsigned int cpu)
74 74
75 while ((cpu_node = of_find_node_by_type(cpu_node, "cpu")) != NULL) { 75 while ((cpu_node = of_find_node_by_type(cpu_node, "cpu")) != NULL) {
76 /* Try interrupt server first */ 76 /* Try interrupt server first */
77 interrupt_server = get_property(cpu_node, 77 interrupt_server = of_get_property(cpu_node,
78 "ibm,ppc-interrupt-server#s", &len); 78 "ibm,ppc-interrupt-server#s", &len);
79 79
80 len = len / sizeof(u32); 80 len = len / sizeof(u32);
@@ -85,7 +85,7 @@ static struct device_node * __cpuinit find_cpu_node(unsigned int cpu)
85 return cpu_node; 85 return cpu_node;
86 } 86 }
87 } else { 87 } else {
88 reg = get_property(cpu_node, "reg", &len); 88 reg = of_get_property(cpu_node, "reg", &len);
89 if (reg && (len > 0) && (reg[0] == hw_cpuid)) 89 if (reg && (len > 0) && (reg[0] == hw_cpuid))
90 return cpu_node; 90 return cpu_node;
91 } 91 }
@@ -97,7 +97,7 @@ static struct device_node * __cpuinit find_cpu_node(unsigned int cpu)
97/* must hold reference to node during call */ 97/* must hold reference to node during call */
98static const int *of_get_associativity(struct device_node *dev) 98static const int *of_get_associativity(struct device_node *dev)
99{ 99{
100 return get_property(dev, "ibm,associativity", NULL); 100 return of_get_property(dev, "ibm,associativity", NULL);
101} 101}
102 102
103/* Returns nid in the range [0..MAX_NUMNODES-1], or -1 if no useful numa 103/* Returns nid in the range [0..MAX_NUMNODES-1], or -1 if no useful numa
@@ -179,7 +179,7 @@ static int __init find_min_common_depth(void)
179 * configuration (should be all 0's) and the second is for a normal 179 * configuration (should be all 0's) and the second is for a normal
180 * NUMA configuration. 180 * NUMA configuration.
181 */ 181 */
182 ref_points = get_property(rtas_root, 182 ref_points = of_get_property(rtas_root,
183 "ibm,associativity-reference-points", &len); 183 "ibm,associativity-reference-points", &len);
184 184
185 if ((len >= 1) && ref_points) { 185 if ((len >= 1) && ref_points) {
@@ -201,8 +201,8 @@ static void __init get_n_mem_cells(int *n_addr_cells, int *n_size_cells)
201 if (!memory) 201 if (!memory)
202 panic("numa.c: No memory nodes found!"); 202 panic("numa.c: No memory nodes found!");
203 203
204 *n_addr_cells = prom_n_addr_cells(memory); 204 *n_addr_cells = of_n_addr_cells(memory);
205 *n_size_cells = prom_n_size_cells(memory); 205 *n_size_cells = of_n_size_cells(memory);
206 of_node_put(memory); 206 of_node_put(memory);
207} 207}
208 208
@@ -308,9 +308,9 @@ static void __init parse_drconf_memory(struct device_node *memory)
308 int nid, default_nid = 0; 308 int nid, default_nid = 0;
309 unsigned int start, ai, flags; 309 unsigned int start, ai, flags;
310 310
311 lm = get_property(memory, "ibm,lmb-size", &ls); 311 lm = of_get_property(memory, "ibm,lmb-size", &ls);
312 dm = get_property(memory, "ibm,dynamic-memory", &ld); 312 dm = of_get_property(memory, "ibm,dynamic-memory", &ld);
313 aa = get_property(memory, "ibm,associativity-lookup-arrays", &la); 313 aa = of_get_property(memory, "ibm,associativity-lookup-arrays", &la);
314 if (!lm || !dm || !aa || 314 if (!lm || !dm || !aa ||
315 ls < sizeof(unsigned int) || ld < sizeof(unsigned int) || 315 ls < sizeof(unsigned int) || ld < sizeof(unsigned int) ||
316 la < 2 * sizeof(unsigned int)) 316 la < 2 * sizeof(unsigned int))
@@ -404,10 +404,10 @@ static int __init parse_numa_properties(void)
404 const unsigned int *memcell_buf; 404 const unsigned int *memcell_buf;
405 unsigned int len; 405 unsigned int len;
406 406
407 memcell_buf = get_property(memory, 407 memcell_buf = of_get_property(memory,
408 "linux,usable-memory", &len); 408 "linux,usable-memory", &len);
409 if (!memcell_buf || len <= 0) 409 if (!memcell_buf || len <= 0)
410 memcell_buf = get_property(memory, "reg", &len); 410 memcell_buf = of_get_property(memory, "reg", &len);
411 if (!memcell_buf || len <= 0) 411 if (!memcell_buf || len <= 0)
412 continue; 412 continue;
413 413
@@ -725,7 +725,7 @@ int hot_add_scn_to_nid(unsigned long scn_addr)
725 const unsigned int *memcell_buf; 725 const unsigned int *memcell_buf;
726 unsigned int len; 726 unsigned int len;
727 727
728 memcell_buf = get_property(memory, "reg", &len); 728 memcell_buf = of_get_property(memory, "reg", &len);
729 if (!memcell_buf || len <= 0) 729 if (!memcell_buf || len <= 0)
730 continue; 730 continue;
731 731
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index c284bdac9947..bca560374927 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -183,8 +183,8 @@ __ioremap(phys_addr_t addr, unsigned long size, unsigned long flags)
183 * mem_init() sets high_memory so only do the check after that. 183 * mem_init() sets high_memory so only do the check after that.
184 */ 184 */
185 if (mem_init_done && (p < virt_to_phys(high_memory))) { 185 if (mem_init_done && (p < virt_to_phys(high_memory))) {
186 printk("__ioremap(): phys addr "PHYS_FMT" is RAM lr %p\n", p, 186 printk("__ioremap(): phys addr 0x%llx is RAM lr %p\n",
187 __builtin_return_address(0)); 187 (unsigned long long)p, __builtin_return_address(0));
188 return NULL; 188 return NULL;
189 } 189 }
190 190
@@ -266,9 +266,12 @@ int map_page(unsigned long va, phys_addr_t pa, int flags)
266 pg = pte_alloc_kernel(pd, va); 266 pg = pte_alloc_kernel(pd, va);
267 if (pg != 0) { 267 if (pg != 0) {
268 err = 0; 268 err = 0;
269 set_pte_at(&init_mm, va, pg, pfn_pte(pa >> PAGE_SHIFT, __pgprot(flags))); 269 /* The PTE should never be already set nor present in the
270 if (mem_init_done) 270 * hash table
271 flush_HPTE(0, va, pmd_val(*pd)); 271 */
272 BUG_ON(pte_val(*pg) & (_PAGE_PRESENT | _PAGE_HASHPTE));
273 set_pte_at(&init_mm, va, pg, pfn_pte(pa >> PAGE_SHIFT,
274 __pgprot(flags)));
272 } 275 }
273 return err; 276 return err;
274} 277}
@@ -279,16 +282,19 @@ int map_page(unsigned long va, phys_addr_t pa, int flags)
279void __init mapin_ram(void) 282void __init mapin_ram(void)
280{ 283{
281 unsigned long v, p, s, f; 284 unsigned long v, p, s, f;
285 int ktext;
282 286
283 s = mmu_mapin_ram(); 287 s = mmu_mapin_ram();
284 v = KERNELBASE + s; 288 v = KERNELBASE + s;
285 p = PPC_MEMSTART + s; 289 p = PPC_MEMSTART + s;
286 for (; s < total_lowmem; s += PAGE_SIZE) { 290 for (; s < total_lowmem; s += PAGE_SIZE) {
287 if ((char *) v >= _stext && (char *) v < etext) 291 ktext = ((char *) v >= _stext && (char *) v < etext);
288 f = _PAGE_RAM_TEXT; 292 f = ktext ?_PAGE_RAM_TEXT : _PAGE_RAM;
289 else
290 f = _PAGE_RAM;
291 map_page(v, p, f); 293 map_page(v, p, f);
294#ifdef CONFIG_PPC_STD_MMU_32
295 if (ktext)
296 hash_preload(&init_mm, v, 0, 0x300);
297#endif
292 v += PAGE_SIZE; 298 v += PAGE_SIZE;
293 p += PAGE_SIZE; 299 p += PAGE_SIZE;
294 } 300 }
@@ -445,3 +451,55 @@ exit:
445 return ret; 451 return ret;
446} 452}
447 453
454#ifdef CONFIG_DEBUG_PAGEALLOC
455
456static int __change_page_attr(struct page *page, pgprot_t prot)
457{
458 pte_t *kpte;
459 pmd_t *kpmd;
460 unsigned long address;
461
462 BUG_ON(PageHighMem(page));
463 address = (unsigned long)page_address(page);
464
465 if (v_mapped_by_bats(address) || v_mapped_by_tlbcam(address))
466 return 0;
467 if (!get_pteptr(&init_mm, address, &kpte, &kpmd))
468 return -EINVAL;
469 set_pte_at(&init_mm, address, kpte, mk_pte(page, prot));
470 wmb();
471 flush_HPTE(0, address, pmd_val(*kpmd));
472 pte_unmap(kpte);
473
474 return 0;
475}
476
477/*
478 * Change the page attributes of an page in the linear mapping.
479 *
480 * THIS CONFLICTS WITH BAT MAPPINGS, DEBUG USE ONLY
481 */
482static int change_page_attr(struct page *page, int numpages, pgprot_t prot)
483{
484 int i, err = 0;
485 unsigned long flags;
486
487 local_irq_save(flags);
488 for (i = 0; i < numpages; i++, page++) {
489 err = __change_page_attr(page, prot);
490 if (err)
491 break;
492 }
493 local_irq_restore(flags);
494 return err;
495}
496
497
498void kernel_map_pages(struct page *page, int numpages, int enable)
499{
500 if (PageHighMem(page))
501 return;
502
503 change_page_attr(page, numpages, enable ? PAGE_KERNEL : __pgprot(0));
504}
505#endif /* CONFIG_DEBUG_PAGEALLOC */
diff --git a/arch/powerpc/mm/ppc_mmu_32.c b/arch/powerpc/mm/ppc_mmu_32.c
index 7cceb2c44cb9..05066674a7a0 100644
--- a/arch/powerpc/mm/ppc_mmu_32.c
+++ b/arch/powerpc/mm/ppc_mmu_32.c
@@ -85,8 +85,10 @@ unsigned long __init mmu_mapin_ram(void)
85 unsigned long max_size = (256<<20); 85 unsigned long max_size = (256<<20);
86 unsigned long align; 86 unsigned long align;
87 87
88 if (__map_without_bats) 88 if (__map_without_bats) {
89 printk(KERN_DEBUG "RAM mapped without BATs\n");
89 return 0; 90 return 0;
91 }
90 92
91 /* Set up BAT2 and if necessary BAT3 to cover RAM. */ 93 /* Set up BAT2 and if necessary BAT3 to cover RAM. */
92 94
diff --git a/arch/powerpc/mm/tlb_64.c b/arch/powerpc/mm/tlb_64.c
index b58baa65c4a7..fd8d08c325eb 100644
--- a/arch/powerpc/mm/tlb_64.c
+++ b/arch/powerpc/mm/tlb_64.c
@@ -120,17 +120,20 @@ void pgtable_free_tlb(struct mmu_gather *tlb, pgtable_free_t pgf)
120} 120}
121 121
122/* 122/*
123 * Update the MMU hash table to correspond with a change to 123 * A linux PTE was changed and the corresponding hash table entry
124 * a Linux PTE. If wrprot is true, it is permissible to 124 * neesd to be flushed. This function will either perform the flush
125 * change the existing HPTE to read-only rather than removing it 125 * immediately or will batch it up if the current CPU has an active
126 * (if we remove it we should clear the _PTE_HPTEFLAGS bits). 126 * batch on it.
127 *
128 * Must be called from within some kind of spinlock/non-preempt region...
127 */ 129 */
128void hpte_update(struct mm_struct *mm, unsigned long addr, 130void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
129 pte_t *ptep, unsigned long pte, int huge) 131 pte_t *ptep, unsigned long pte, int huge)
130{ 132{
131 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch); 133 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
132 unsigned long vsid; 134 unsigned long vsid, vaddr;
133 unsigned int psize; 135 unsigned int psize;
136 real_pte_t rpte;
134 int i; 137 int i;
135 138
136 i = batch->index; 139 i = batch->index;
@@ -151,6 +154,26 @@ void hpte_update(struct mm_struct *mm, unsigned long addr,
151 } else 154 } else
152 psize = pte_pagesize_index(pte); 155 psize = pte_pagesize_index(pte);
153 156
157 /* Build full vaddr */
158 if (!is_kernel_addr(addr)) {
159 vsid = get_vsid(mm->context.id, addr);
160 WARN_ON(vsid == 0);
161 } else
162 vsid = get_kernel_vsid(addr);
163 vaddr = (vsid << 28 ) | (addr & 0x0fffffff);
164 rpte = __real_pte(__pte(pte), ptep);
165
166 /*
167 * Check if we have an active batch on this CPU. If not, just
168 * flush now and return. For now, we don global invalidates
169 * in that case, might be worth testing the mm cpu mask though
170 * and decide to use local invalidates instead...
171 */
172 if (!batch->active) {
173 flush_hash_page(vaddr, rpte, psize, 0);
174 return;
175 }
176
154 /* 177 /*
155 * This can happen when we are in the middle of a TLB batch and 178 * This can happen when we are in the middle of a TLB batch and
156 * we encounter memory pressure (eg copy_page_range when it tries 179 * we encounter memory pressure (eg copy_page_range when it tries
@@ -162,47 +185,42 @@ void hpte_update(struct mm_struct *mm, unsigned long addr,
162 * batch 185 * batch
163 */ 186 */
164 if (i != 0 && (mm != batch->mm || batch->psize != psize)) { 187 if (i != 0 && (mm != batch->mm || batch->psize != psize)) {
165 flush_tlb_pending(); 188 __flush_tlb_pending(batch);
166 i = 0; 189 i = 0;
167 } 190 }
168 if (i == 0) { 191 if (i == 0) {
169 batch->mm = mm; 192 batch->mm = mm;
170 batch->psize = psize; 193 batch->psize = psize;
171 } 194 }
172 if (!is_kernel_addr(addr)) { 195 batch->pte[i] = rpte;
173 vsid = get_vsid(mm->context.id, addr); 196 batch->vaddr[i] = vaddr;
174 WARN_ON(vsid == 0);
175 } else
176 vsid = get_kernel_vsid(addr);
177 batch->vaddr[i] = (vsid << 28 ) | (addr & 0x0fffffff);
178 batch->pte[i] = __real_pte(__pte(pte), ptep);
179 batch->index = ++i; 197 batch->index = ++i;
180 if (i >= PPC64_TLB_BATCH_NR) 198 if (i >= PPC64_TLB_BATCH_NR)
181 flush_tlb_pending(); 199 __flush_tlb_pending(batch);
182} 200}
183 201
202/*
203 * This function is called when terminating an mmu batch or when a batch
204 * is full. It will perform the flush of all the entries currently stored
205 * in a batch.
206 *
207 * Must be called from within some kind of spinlock/non-preempt region...
208 */
184void __flush_tlb_pending(struct ppc64_tlb_batch *batch) 209void __flush_tlb_pending(struct ppc64_tlb_batch *batch)
185{ 210{
186 int i;
187 int cpu;
188 cpumask_t tmp; 211 cpumask_t tmp;
189 int local = 0; 212 int i, local = 0;
190 213
191 BUG_ON(in_interrupt());
192
193 cpu = get_cpu();
194 i = batch->index; 214 i = batch->index;
195 tmp = cpumask_of_cpu(cpu); 215 tmp = cpumask_of_cpu(smp_processor_id());
196 if (cpus_equal(batch->mm->cpu_vm_mask, tmp)) 216 if (cpus_equal(batch->mm->cpu_vm_mask, tmp))
197 local = 1; 217 local = 1;
198
199 if (i == 1) 218 if (i == 1)
200 flush_hash_page(batch->vaddr[0], batch->pte[0], 219 flush_hash_page(batch->vaddr[0], batch->pte[0],
201 batch->psize, local); 220 batch->psize, local);
202 else 221 else
203 flush_hash_range(i, local); 222 flush_hash_range(i, local);
204 batch->index = 0; 223 batch->index = 0;
205 put_cpu();
206} 224}
207 225
208void pte_free_finish(void) 226void pte_free_finish(void)
diff --git a/arch/powerpc/oprofile/Makefile b/arch/powerpc/oprofile/Makefile
index 4ccef2d5530c..4b5f9528218c 100644
--- a/arch/powerpc/oprofile/Makefile
+++ b/arch/powerpc/oprofile/Makefile
@@ -12,6 +12,6 @@ DRIVER_OBJS := $(addprefix ../../../drivers/oprofile/, \
12 12
13oprofile-y := $(DRIVER_OBJS) common.o backtrace.o 13oprofile-y := $(DRIVER_OBJS) common.o backtrace.o
14oprofile-$(CONFIG_PPC_CELL_NATIVE) += op_model_cell.o 14oprofile-$(CONFIG_PPC_CELL_NATIVE) += op_model_cell.o
15oprofile-$(CONFIG_PPC64) += op_model_rs64.o op_model_power4.o 15oprofile-$(CONFIG_PPC64) += op_model_rs64.o op_model_power4.o op_model_pa6t.o
16oprofile-$(CONFIG_FSL_BOOKE) += op_model_fsl_booke.o 16oprofile-$(CONFIG_FSL_BOOKE) += op_model_fsl_booke.o
17oprofile-$(CONFIG_6xx) += op_model_7450.o 17oprofile-$(CONFIG_6xx) += op_model_7450.o
diff --git a/arch/powerpc/oprofile/common.c b/arch/powerpc/oprofile/common.c
index fbd62eacfdf4..1a7ef7e246d2 100644
--- a/arch/powerpc/oprofile/common.c
+++ b/arch/powerpc/oprofile/common.c
@@ -160,6 +160,9 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
160 case PPC_OPROFILE_POWER4: 160 case PPC_OPROFILE_POWER4:
161 model = &op_model_power4; 161 model = &op_model_power4;
162 break; 162 break;
163 case PPC_OPROFILE_PA6T:
164 model = &op_model_pa6t;
165 break;
163#endif 166#endif
164#ifdef CONFIG_6xx 167#ifdef CONFIG_6xx
165 case PPC_OPROFILE_G4: 168 case PPC_OPROFILE_G4:
diff --git a/arch/powerpc/oprofile/op_model_cell.c b/arch/powerpc/oprofile/op_model_cell.c
index e08e1d7b3dc5..626b29f38304 100644
--- a/arch/powerpc/oprofile/op_model_cell.c
+++ b/arch/powerpc/oprofile/op_model_cell.c
@@ -37,6 +37,7 @@
37#include <asm/system.h> 37#include <asm/system.h>
38 38
39#include "../platforms/cell/interrupt.h" 39#include "../platforms/cell/interrupt.h"
40#include "../platforms/cell/cbe_regs.h"
40 41
41#define PPU_CYCLES_EVENT_NUM 1 /* event number for CYCLES */ 42#define PPU_CYCLES_EVENT_NUM 1 /* event number for CYCLES */
42#define PPU_CYCLES_GRP_NUM 1 /* special group number for identifying 43#define PPU_CYCLES_GRP_NUM 1 /* special group number for identifying
@@ -130,7 +131,7 @@ static int pm_rtas_token;
130static u32 reset_value[NR_PHYS_CTRS]; 131static u32 reset_value[NR_PHYS_CTRS];
131static int num_counters; 132static int num_counters;
132static int oprofile_running; 133static int oprofile_running;
133static spinlock_t virt_cntr_lock = SPIN_LOCK_UNLOCKED; 134static DEFINE_SPINLOCK(virt_cntr_lock);
134 135
135static u32 ctr_enabled; 136static u32 ctr_enabled;
136 137
diff --git a/arch/powerpc/oprofile/op_model_pa6t.c b/arch/powerpc/oprofile/op_model_pa6t.c
new file mode 100644
index 000000000000..e8a56b0adadc
--- /dev/null
+++ b/arch/powerpc/oprofile/op_model_pa6t.c
@@ -0,0 +1,234 @@
1/*
2 * Copyright (C) 2006-2007 PA Semi, Inc
3 *
4 * Author: Shashi Rao, PA Semi
5 *
6 * Maintained by: Olof Johansson <olof@lixom.net>
7 *
8 * Based on arch/powerpc/oprofile/op_model_power4.c
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#include <linux/oprofile.h>
25#include <linux/init.h>
26#include <linux/smp.h>
27#include <linux/percpu.h>
28#include <asm/processor.h>
29#include <asm/cputable.h>
30#include <asm/oprofile_impl.h>
31#include <asm/reg.h>
32
33static unsigned char oprofile_running;
34
35/* mmcr values are set in pa6t_reg_setup, used in pa6t_cpu_setup */
36static u64 mmcr0_val;
37static u64 mmcr1_val;
38
39/* inited in pa6t_reg_setup */
40static u64 reset_value[OP_MAX_COUNTER];
41
42static inline u64 ctr_read(unsigned int i)
43{
44 switch (i) {
45 case 0:
46 return mfspr(SPRN_PA6T_PMC0);
47 case 1:
48 return mfspr(SPRN_PA6T_PMC1);
49 case 2:
50 return mfspr(SPRN_PA6T_PMC2);
51 case 3:
52 return mfspr(SPRN_PA6T_PMC3);
53 case 4:
54 return mfspr(SPRN_PA6T_PMC4);
55 case 5:
56 return mfspr(SPRN_PA6T_PMC5);
57 default:
58 printk(KERN_ERR "ctr_read called with bad arg %u\n", i);
59 return 0;
60 }
61}
62
63static inline void ctr_write(unsigned int i, u64 val)
64{
65 switch (i) {
66 case 0:
67 mtspr(SPRN_PA6T_PMC0, val);
68 break;
69 case 1:
70 mtspr(SPRN_PA6T_PMC1, val);
71 break;
72 case 2:
73 mtspr(SPRN_PA6T_PMC2, val);
74 break;
75 case 3:
76 mtspr(SPRN_PA6T_PMC3, val);
77 break;
78 case 4:
79 mtspr(SPRN_PA6T_PMC4, val);
80 break;
81 case 5:
82 mtspr(SPRN_PA6T_PMC5, val);
83 break;
84 default:
85 printk(KERN_ERR "ctr_write called with bad arg %u\n", i);
86 break;
87 }
88}
89
90
91/* precompute the values to stuff in the hardware registers */
92static void pa6t_reg_setup(struct op_counter_config *ctr,
93 struct op_system_config *sys,
94 int num_ctrs)
95{
96 int pmc;
97
98 /*
99 * adjust the mmcr0.en[0-5] and mmcr0.inten[0-5] values obtained from the
100 * event_mappings file by turning off the counters that the user doesn't
101 * care about
102 *
103 * setup user and kernel profiling
104 */
105 for (pmc = 0; pmc < cur_cpu_spec->num_pmcs; pmc++)
106 if (!ctr[pmc].enabled) {
107 sys->mmcr0 &= ~(0x1UL << pmc);
108 sys->mmcr0 &= ~(0x1UL << (pmc+12));
109 pr_debug("turned off counter %u\n", pmc);
110 }
111
112 if (sys->enable_kernel)
113 sys->mmcr0 |= PA6T_MMCR0_SUPEN | PA6T_MMCR0_HYPEN;
114 else
115 sys->mmcr0 &= ~(PA6T_MMCR0_SUPEN | PA6T_MMCR0_HYPEN);
116
117 if (sys->enable_user)
118 sys->mmcr0 |= PA6T_MMCR0_PREN;
119 else
120 sys->mmcr0 &= ~PA6T_MMCR0_PREN;
121
122 /*
123 * The performance counter event settings are given in the mmcr0 and
124 * mmcr1 values passed from the user in the op_system_config
125 * structure (sys variable).
126 */
127 mmcr0_val = sys->mmcr0;
128 mmcr1_val = sys->mmcr1;
129 pr_debug("mmcr0_val inited to %016lx\n", sys->mmcr0);
130 pr_debug("mmcr1_val inited to %016lx\n", sys->mmcr1);
131
132 for (pmc = 0; pmc < cur_cpu_spec->num_pmcs; pmc++) {
133 /* counters are 40 bit. Move to cputable at some point? */
134 reset_value[pmc] = (0x1UL << 39) - ctr[pmc].count;
135 pr_debug("reset_value for pmc%u inited to 0x%lx\n",
136 pmc, reset_value[pmc]);
137 }
138}
139
140/* configure registers on this cpu */
141static void pa6t_cpu_setup(struct op_counter_config *ctr)
142{
143 u64 mmcr0 = mmcr0_val;
144 u64 mmcr1 = mmcr1_val;
145
146 /* Default is all PMCs off */
147 mmcr0 &= ~(0x3FUL);
148 mtspr(SPRN_PA6T_MMCR0, mmcr0);
149
150 /* program selected programmable events in */
151 mtspr(SPRN_PA6T_MMCR1, mmcr1);
152
153 pr_debug("setup on cpu %d, mmcr0 %016lx\n", smp_processor_id(),
154 mfspr(SPRN_PA6T_MMCR0));
155 pr_debug("setup on cpu %d, mmcr1 %016lx\n", smp_processor_id(),
156 mfspr(SPRN_PA6T_MMCR1));
157}
158
159static void pa6t_start(struct op_counter_config *ctr)
160{
161 int i;
162
163 /* Hold off event counting until rfid */
164 u64 mmcr0 = mmcr0_val | PA6T_MMCR0_HANDDIS;
165
166 for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
167 if (ctr[i].enabled)
168 ctr_write(i, reset_value[i]);
169 else
170 ctr_write(i, 0UL);
171
172 mtspr(SPRN_PA6T_MMCR0, mmcr0);
173
174 oprofile_running = 1;
175
176 pr_debug("start on cpu %d, mmcr0 %lx\n", smp_processor_id(), mmcr0);
177}
178
179static void pa6t_stop(void)
180{
181 u64 mmcr0;
182
183 /* freeze counters */
184 mmcr0 = mfspr(SPRN_PA6T_MMCR0);
185 mmcr0 |= PA6T_MMCR0_FCM0;
186 mtspr(SPRN_PA6T_MMCR0, mmcr0);
187
188 oprofile_running = 0;
189
190 pr_debug("stop on cpu %d, mmcr0 %lx\n", smp_processor_id(), mmcr0);
191}
192
193/* handle the perfmon overflow vector */
194static void pa6t_handle_interrupt(struct pt_regs *regs,
195 struct op_counter_config *ctr)
196{
197 unsigned long pc = mfspr(SPRN_PA6T_SIAR);
198 int is_kernel = is_kernel_addr(pc);
199 u64 val;
200 int i;
201 u64 mmcr0;
202
203 /* disable perfmon counting until rfid */
204 mmcr0 = mfspr(SPRN_PA6T_MMCR0);
205 mtspr(SPRN_PA6T_MMCR0, mmcr0 | PA6T_MMCR0_HANDDIS);
206
207 /* Record samples. We've got one global bit for whether a sample
208 * was taken, so add it for any counter that triggered overflow.
209 */
210 for (i = 0; i < cur_cpu_spec->num_pmcs; i++) {
211 val = ctr_read(i);
212 if (val & (0x1UL << 39)) { /* Overflow bit set */
213 if (oprofile_running && ctr[i].enabled) {
214 if (mmcr0 & PA6T_MMCR0_SIARLOG)
215 oprofile_add_ext_sample(pc, regs, i, is_kernel);
216 ctr_write(i, reset_value[i]);
217 } else {
218 ctr_write(i, 0UL);
219 }
220 }
221 }
222
223 /* Restore mmcr0 to a good known value since the PMI changes it */
224 mmcr0 = mmcr0_val | PA6T_MMCR0_HANDDIS;
225 mtspr(SPRN_PA6T_MMCR0, mmcr0);
226}
227
228struct op_powerpc_model op_model_pa6t = {
229 .reg_setup = pa6t_reg_setup,
230 .cpu_setup = pa6t_cpu_setup,
231 .start = pa6t_start,
232 .stop = pa6t_stop,
233 .handle_interrupt = pa6t_handle_interrupt,
234};
diff --git a/arch/powerpc/platforms/4xx/Kconfig b/arch/powerpc/platforms/4xx/Kconfig
index 2f2a13ed7667..ded357c17414 100644
--- a/arch/powerpc/platforms/4xx/Kconfig
+++ b/arch/powerpc/platforms/4xx/Kconfig
@@ -3,278 +3,206 @@ config 4xx
3 depends on 40x || 44x 3 depends on 40x || 44x
4 default y 4 default y
5 5
6config WANT_EARLY_SERIAL 6config BOOKE
7 bool 7 bool
8 select SERIAL_8250
9 default n
10
11menu "AMCC 4xx options"
12 depends on 4xx
13
14choice
15 prompt "Machine Type"
16 depends on 40x
17 default WALNUT
18
19config BUBINGA
20 bool "Bubinga"
21 select WANT_EARLY_SERIAL
22 help
23 This option enables support for the IBM 405EP evaluation board.
24
25config CPCI405
26 bool "CPCI405"
27 help
28 This option enables support for the CPCI405 board.
29
30config EP405
31 bool "EP405/EP405PC"
32 help
33 This option enables support for the EP405/EP405PC boards.
34
35config REDWOOD_5
36 bool "Redwood-5"
37 help
38 This option enables support for the IBM STB04 evaluation board.
39
40config REDWOOD_6
41 bool "Redwood-6"
42 help
43 This option enables support for the IBM STBx25xx evaluation board.
44
45config SYCAMORE
46 bool "Sycamore"
47 help
48 This option enables support for the IBM PPC405GPr evaluation board.
49
50config WALNUT
51 bool "Walnut"
52 help
53 This option enables support for the IBM PPC405GP evaluation board.
54
55config XILINX_ML300
56 bool "Xilinx-ML300"
57 help
58 This option enables support for the Xilinx ML300 evaluation board.
59
60endchoice
61
62choice
63 prompt "Machine Type"
64 depends on 44x 8 depends on 44x
65 default EBONY 9 default y
66
67config BAMBOO
68 bool "Bamboo"
69 select WANT_EARLY_SERIAL
70 help
71 This option enables support for the IBM PPC440EP evaluation board.
72
73config EBONY
74 bool "Ebony"
75 select WANT_EARLY_SERIAL
76 help
77 This option enables support for the IBM PPC440GP evaluation board.
78
79config LUAN
80 bool "Luan"
81 select WANT_EARLY_SERIAL
82 help
83 This option enables support for the IBM PPC440SP evaluation board.
84
85config OCOTEA
86 bool "Ocotea"
87 select WANT_EARLY_SERIAL
88 help
89 This option enables support for the IBM PPC440GX evaluation board.
90 10
91endchoice 11menu "AMCC 40x options"
12 depends on 40x
92 13
93config EP405PC 14#config BUBINGA
94 bool "EP405PC Support" 15# bool "Bubinga"
95 depends on EP405 16# depends on 40x
17# default n
18# select 405EP
19# help
20# This option enables support for the IBM 405EP evaluation board.
21
22#config CPCI405
23# bool "CPCI405"
24# depends on 40x
25# default n
26# select 405GP
27# help
28# This option enables support for the CPCI405 board.
29
30#config EP405
31# bool "EP405/EP405PC"
32# depends on 40x
33# default n
34# select 405GP
35# help
36# This option enables support for the EP405/EP405PC boards.
37
38#config EP405PC
39# bool "EP405PC Support"
40# depends on EP405
41# default y
42# help
43# This option enables support for the extra features of the EP405PC board.
44
45#config REDWOOD_5
46# bool "Redwood-5"
47# depends on 40x
48# default n
49# select STB03xxx
50# help
51# This option enables support for the IBM STB04 evaluation board.
52
53#config REDWOOD_6
54# bool "Redwood-6"
55# depends on 40x
56# default n
57# select STB03xxx
58# help
59# This option enables support for the IBM STBx25xx evaluation board.
60
61#config SYCAMORE
62# bool "Sycamore"
63# depends on 40x
64# default n
65# select 405GPR
66# help
67# This option enables support for the IBM PPC405GPr evaluation board.
68
69#config WALNUT
70# bool "Walnut"
71# depends on 40x
72# default y
73# select 405GP
74# help
75# This option enables support for the IBM PPC405GP evaluation board.
76
77#config XILINX_ML300
78# bool "Xilinx-ML300"
79# depends on 40x
80# default y
81# select VIRTEX_II_PRO
82# help
83# This option enables support for the Xilinx ML300 evaluation board.
96 84
85endmenu
97 86
98# It's often necessary to know the specific 4xx processor type. 87# 40x specific CPU modules, selected based on the board above.
99# Fortunately, it is impled (so far) from the board type, so we
100# don't need to ask more redundant questions.
101config NP405H 88config NP405H
102 bool 89 bool
103 depends on ASH 90 #depends on ASH
104 default y
105 91
106config 440EP 92# OAK doesn't exist but wanted to keep this around for any future 403GCX boards
93config 403GCX
107 bool 94 bool
108 depends on BAMBOO 95 #depends on OAK
109 select PPC_FPU 96 select IBM405_ERR51
110 default y
111 97
112config 440GP 98config 405GP
113 bool 99 bool
114 depends on EBONY 100 select IBM405_ERR77
115 default y 101 select IBM405_ERR51
116 102
117config 440GX 103config 405EP
118 bool 104 bool
119 depends on OCOTEA
120 default y
121 105
122config 440SP 106config 405GPR
123 bool 107 bool
124 depends on LUAN
125 default y
126 108
127config 440 109config VIRTEX_II_PRO
128 bool 110 bool
129 depends on 440GP || 440SP || 440EP 111 select IBM405_ERR77
130 default y 112 select IBM405_ERR51
131 113
132config 440A 114config STB03xxx
133 bool 115 bool
134 depends on 440GX 116 select IBM405_ERR77
135 default y 117 select IBM405_ERR51
136 118
137config IBM440EP_ERR42 119# 40x errata/workaround config symbols, selected by the CPU models above
138 bool
139 depends on 440EP
140 default y
141 120
142# All 405-based cores up until the 405GPR and 405EP have this errata. 121# All 405-based cores up until the 405GPR and 405EP have this errata.
143config IBM405_ERR77 122config IBM405_ERR77
144 bool 123 bool
145 depends on 40x && !403GCX && !405GPR && !405EP
146 default y
147 124
148# All 40x-based cores, up until the 405GPR and 405EP have this errata. 125# All 40x-based cores, up until the 405GPR and 405EP have this errata.
149config IBM405_ERR51 126config IBM405_ERR51
150 bool 127 bool
151 depends on 40x && !405GPR && !405EP
152 default y
153 128
154config BOOKE 129menu "AMCC 44x options"
155 bool
156 depends on 44x 130 depends on 44x
157 default y
158
159config IBM_OCP
160 bool
161 depends on ASH || BAMBOO || BUBINGA || CPCI405 || EBONY || EP405 || LUAN || OCOTEA || REDWOOD_5 || REDWOOD_6 || SYCAMORE || WALNUT
162 default y
163 131
164config XILINX_OCP 132#config BAMBOO
165 bool 133# bool "Bamboo"
166 depends on XILINX_ML300 134# depends on 44x
167 default y 135# default n
136# select 440EP
137# help
138# This option enables support for the IBM PPC440EP evaluation board.
168 139
169config IBM_EMAC4 140config EBONY
170 bool 141 bool "Ebony"
171 depends on 440GX || 440SP 142 depends on 44x
172 default y
173
174config BIOS_FIXUP
175 bool
176 depends on BUBINGA || EP405 || SYCAMORE || WALNUT
177 default y
178
179# OAK doesn't exist but wanted to keep this around for any future 403GCX boards
180config 403GCX
181 bool
182 depends on OAK
183 default y
184
185config 405EP
186 bool
187 depends on BUBINGA
188 default y
189
190config 405GP
191 bool
192 depends on CPCI405 || EP405 || WALNUT
193 default y
194
195config 405GPR
196 bool
197 depends on SYCAMORE
198 default y 143 default y
144 select 440GP
145 help
146 This option enables support for the IBM PPC440GP evaluation board.
199 147
200config VIRTEX_II_PRO 148#config LUAN
201 bool 149# bool "Luan"
202 depends on XILINX_ML300 150# depends on 44x
203 default y 151# default n
152# select 440SP
153# help
154# This option enables support for the IBM PPC440SP evaluation board.
155
156#config OCOTEA
157# bool "Ocotea"
158# depends on 44x
159# default n
160# select 440GX
161# help
162# This option enables support for the IBM PPC440GX evaluation board.
204 163
205config STB03xxx 164endmenu
206 bool
207 depends on REDWOOD_5 || REDWOOD_6
208 default y
209 165
210config EMBEDDEDBOOT 166# 44x specific CPU modules, selected based on the board above.
167config 440EP
211 bool 168 bool
212 depends on EP405 || XILINX_ML300 169 select PPC_FPU
213 default y 170 select IBM440EP_ERR42
214 171
215config IBM_OPENBIOS 172config 440GP
216 bool 173 bool
217 depends on ASH || BUBINGA || REDWOOD_5 || REDWOOD_6 || SYCAMORE || WALNUT 174 select IBM_NEW_EMAC_ZMII
218 default y
219 175
220config PPC4xx_DMA 176config 440GX
221 bool "PPC4xx DMA controller support"
222 depends on 4xx
223
224config PPC4xx_EDMA
225 bool 177 bool
226 depends on !STB03xxx && PPC4xx_DMA
227 default y
228 178
229config PPC_GEN550 179config 440SP
230 bool 180 bool
231 depends on 4xx
232 default y
233
234choice
235 prompt "TTYS0 device and default console"
236 depends on 40x
237 default UART0_TTYS0
238
239config UART0_TTYS0
240 bool "UART0"
241 181
242config UART0_TTYS1 182config 440A
243 bool "UART1"
244
245endchoice
246
247config SERIAL_SICC
248 bool "SICC Serial port support"
249 depends on STB03xxx
250
251config UART1_DFLT_CONSOLE
252 bool 183 bool
253 depends on SERIAL_SICC && UART0_TTYS1 184 depends on 440GX
254 default y 185 default y
255 186
256config SERIAL_SICC_CONSOLE 187# 44x errata/workaround config symbols, selected by the CPU models above
188config IBM440EP_ERR42
257 bool 189 bool
258 depends on SERIAL_SICC && UART0_TTYS1
259 default y
260endmenu
261 190
191#config XILINX_OCP
192# bool
193# depends on XILINX_ML300
194# default y
262 195
263menu "IBM 40x options" 196#config BIOS_FIXUP
264 depends on 40x 197# bool
265 198# depends on BUBINGA || EP405 || SYCAMORE || WALNUT
266config SERIAL_SICC 199# default y
267 bool "SICC Serial port"
268 depends on STB03xxx
269
270config UART1_DFLT_CONSOLE
271 bool
272 depends on SERIAL_SICC && UART0_TTYS1
273 default y
274 200
275config SERIAL_SICC_CONSOLE 201#config PPC4xx_DMA
276 bool 202# bool "PPC4xx DMA controller support"
277 depends on SERIAL_SICC && UART0_TTYS1 203# depends on 4xx
278 default y
279 204
280endmenu 205#config PPC4xx_EDMA
206# bool
207# depends on !STB03xxx && PPC4xx_DMA
208# default y
diff --git a/arch/powerpc/platforms/52xx/Kconfig b/arch/powerpc/platforms/52xx/Kconfig
new file mode 100644
index 000000000000..bc4aa4a80a12
--- /dev/null
+++ b/arch/powerpc/platforms/52xx/Kconfig
@@ -0,0 +1,35 @@
1config PPC_MPC52xx
2 bool
3 default n
4
5config PPC_MPC5200
6 bool
7 select PPC_MPC52xx
8 default n
9
10config PPC_MPC5200_BUGFIX
11 bool "MPC5200 (L25R) bugfix support"
12 depends on PPC_MPC5200
13 default n
14 help
15 Enable workarounds for original MPC5200 errata. This is not required
16 for MPC5200B based boards.
17
18 It is safe to say 'Y' here
19
20config PPC_EFIKA
21 bool "bPlan Efika 5k2. MPC5200B based computer"
22 depends on PPC_MULTIPLATFORM && PPC32
23 select PPC_RTAS
24 select RTAS_PROC
25 select PPC_MPC52xx
26 select PPC_NATIVE
27 default n
28
29config PPC_LITE5200
30 bool "Freescale Lite5200 Eval Board"
31 depends on PPC_MULTIPLATFORM && PPC32
32 select PPC_MPC5200
33 default n
34
35
diff --git a/arch/powerpc/platforms/52xx/efika.c b/arch/powerpc/platforms/52xx/efika.c
index 8de034116681..a6bba97314eb 100644
--- a/arch/powerpc/platforms/52xx/efika.c
+++ b/arch/powerpc/platforms/52xx/efika.c
@@ -112,7 +112,7 @@ void __init efika_pcisetup(void)
112 return; 112 return;
113 } 113 }
114 114
115 bus_range = get_property(pcictrl, "bus-range", &len); 115 bus_range = of_get_property(pcictrl, "bus-range", &len);
116 if (bus_range == NULL || len < 2 * sizeof(int)) { 116 if (bus_range == NULL || len < 2 * sizeof(int)) {
117 printk(KERN_WARNING EFIKA_PLATFORM_NAME 117 printk(KERN_WARNING EFIKA_PLATFORM_NAME
118 ": Can't get bus-range for %s\n", pcictrl->full_name); 118 ": Can't get bus-range for %s\n", pcictrl->full_name);
@@ -158,18 +158,17 @@ void __init efika_pcisetup(void)
158static void efika_show_cpuinfo(struct seq_file *m) 158static void efika_show_cpuinfo(struct seq_file *m)
159{ 159{
160 struct device_node *root; 160 struct device_node *root;
161 const char *revision = NULL; 161 const char *revision;
162 const char *codegendescription = NULL; 162 const char *codegendescription;
163 const char *codegenvendor = NULL; 163 const char *codegenvendor;
164 164
165 root = of_find_node_by_path("/"); 165 root = of_find_node_by_path("/");
166 if (!root) 166 if (!root)
167 return; 167 return;
168 168
169 revision = get_property(root, "revision", NULL); 169 revision = of_get_property(root, "revision", NULL);
170 codegendescription = 170 codegendescription = of_get_property(root, "CODEGEN,description", NULL);
171 get_property(root, "CODEGEN,description", NULL); 171 codegenvendor = of_get_property(root, "CODEGEN,vendor", NULL);
172 codegenvendor = get_property(root, "CODEGEN,vendor", NULL);
173 172
174 if (codegendescription) 173 if (codegendescription)
175 seq_printf(m, "machine\t\t: %s\n", codegendescription); 174 seq_printf(m, "machine\t\t: %s\n", codegendescription);
diff --git a/arch/powerpc/platforms/52xx/lite5200.c b/arch/powerpc/platforms/52xx/lite5200.c
index cc3b40de21dd..8e2646ac417b 100644
--- a/arch/powerpc/platforms/52xx/lite5200.c
+++ b/arch/powerpc/platforms/52xx/lite5200.c
@@ -94,8 +94,8 @@ static void __init lite5200_setup_arch(void)
94 94
95 np = of_find_node_by_type(NULL, "cpu"); 95 np = of_find_node_by_type(NULL, "cpu");
96 if (np) { 96 if (np) {
97 unsigned int *fp = 97 const unsigned int *fp =
98 (int *)get_property(np, "clock-frequency", NULL); 98 of_get_property(np, "clock-frequency", NULL);
99 if (fp != 0) 99 if (fp != 0)
100 loops_per_jiffy = *fp / HZ; 100 loops_per_jiffy = *fp / HZ;
101 else 101 else
@@ -108,9 +108,11 @@ static void __init lite5200_setup_arch(void)
108 lite5200_setup_cpu(); /* Platorm specific */ 108 lite5200_setup_cpu(); /* Platorm specific */
109 109
110#ifdef CONFIG_PCI 110#ifdef CONFIG_PCI
111 np = of_find_node_by_type(np, "pci"); 111 np = of_find_node_by_type(NULL, "pci");
112 if (np) 112 if (np) {
113 mpc52xx_add_bridge(np); 113 mpc52xx_add_bridge(np);
114 of_node_put(np);
115 }
114#endif 116#endif
115 117
116#ifdef CONFIG_BLK_DEV_INITRD 118#ifdef CONFIG_BLK_DEV_INITRD
@@ -132,7 +134,7 @@ void lite5200_show_cpuinfo(struct seq_file *m)
132 const char *model = NULL; 134 const char *model = NULL;
133 135
134 if (np) 136 if (np)
135 model = get_property(np, "model", NULL); 137 model = of_get_property(np, "model", NULL);
136 138
137 seq_printf(m, "vendor\t\t: Freescale Semiconductor\n"); 139 seq_printf(m, "vendor\t\t: Freescale Semiconductor\n");
138 seq_printf(m, "machine\t\t: %s\n", model ? model : "unknown"); 140 seq_printf(m, "machine\t\t: %s\n", model ? model : "unknown");
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_common.c b/arch/powerpc/platforms/52xx/mpc52xx_common.c
index ed0cb694aea8..2dd415ff55a9 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_common.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c
@@ -60,7 +60,7 @@ mpc52xx_find_ipb_freq(struct device_node *node)
60 60
61 of_node_get(node); 61 of_node_get(node);
62 while (node) { 62 while (node) {
63 p_ipb_freq = get_property(node, "bus-frequency", NULL); 63 p_ipb_freq = of_get_property(node, "bus-frequency", NULL);
64 if (p_ipb_freq) 64 if (p_ipb_freq)
65 break; 65 break;
66 66
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_pci.c b/arch/powerpc/platforms/52xx/mpc52xx_pci.c
index faf161bdbc1c..34d34a26d305 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_pci.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_pci.c
@@ -370,7 +370,7 @@ mpc52xx_add_bridge(struct device_node *node)
370 return -EINVAL; 370 return -EINVAL;
371 } 371 }
372 372
373 bus_range = get_property(node, "bus-range", &len); 373 bus_range = of_get_property(node, "bus-range", &len);
374 if (bus_range == NULL || len < 2 * sizeof(int)) { 374 if (bus_range == NULL || len < 2 * sizeof(int)) {
375 printk(KERN_WARNING "Can't get %s bus-range, assume bus 0\n", 375 printk(KERN_WARNING "Can't get %s bus-range, assume bus 0\n",
376 node->full_name); 376 node->full_name);
diff --git a/arch/powerpc/platforms/82xx/Kconfig b/arch/powerpc/platforms/82xx/Kconfig
index 47d841ecf2e2..de7fce9cb6eb 100644
--- a/arch/powerpc/platforms/82xx/Kconfig
+++ b/arch/powerpc/platforms/82xx/Kconfig
@@ -1,21 +1,36 @@
1menu "Platform support"
2 depends on PPC_82xx
3
4choice 1choice
5 prompt "Machine Type" 2 prompt "Machine Type"
6 default MPC82xx_ADS 3 depends on PPC_82xx
4 default MPC82xx_ADS
7 5
8config MPC82xx_ADS 6config MPC82xx_ADS
9 bool "Freescale MPC82xx ADS" 7 bool "Freescale MPC82xx ADS"
10 select DEFAULT_UIMAGE 8 select DEFAULT_UIMAGE
11 select PQ2ADS 9 select PQ2ADS
12 select 8272 10 select 8272
13 select 8260 11 select 8260
14 select CPM2 12 select FSL_SOC
15 select FSL_SOC 13 help
16 help 14 This option enables support for the MPC8272 ADS board
17 This option enables support for the MPC8272 ADS board
18 15
19endchoice 16endchoice
20 17
21endmenu 18config PQ2ADS
19 bool
20 default n
21
22config 8260
23 bool
24 depends on 6xx
25 select CPM2
26 help
27 The MPC8260 is a typical embedded CPU made by Freescale. Selecting
28 this option means that you wish to build a kernel for a machine with
29 an 8260 class CPU.
30
31config 8272
32 bool
33 select 8260
34 help
35 The MPC8272 CPM has a different internal dpram setup than other CPM2
36 devices
diff --git a/arch/powerpc/platforms/82xx/mpc82xx.c b/arch/powerpc/platforms/82xx/mpc82xx.c
index 74e7892cdfcf..cc9900d2e5ee 100644
--- a/arch/powerpc/platforms/82xx/mpc82xx.c
+++ b/arch/powerpc/platforms/82xx/mpc82xx.c
@@ -55,17 +55,17 @@
55static int __init get_freq(char *name, unsigned long *val) 55static int __init get_freq(char *name, unsigned long *val)
56{ 56{
57 struct device_node *cpu; 57 struct device_node *cpu;
58 unsigned int *fp; 58 const unsigned int *fp;
59 int found = 0; 59 int found = 0;
60 60
61 /* The cpu node should have timebase and clock frequency properties */ 61 /* The cpu node should have timebase and clock frequency properties */
62 cpu = of_find_node_by_type(NULL, "cpu"); 62 cpu = of_find_node_by_type(NULL, "cpu");
63 63
64 if (cpu) { 64 if (cpu) {
65 fp = (unsigned int *)get_property(cpu, name, NULL); 65 fp = of_get_property(cpu, name, NULL);
66 if (fp) { 66 if (fp) {
67 found = 1; 67 found = 1;
68 *val = *fp++; 68 *val = *fp;
69 } 69 }
70 70
71 of_node_put(cpu); 71 of_node_put(cpu);
diff --git a/arch/powerpc/platforms/82xx/mpc82xx_ads.c b/arch/powerpc/platforms/82xx/mpc82xx_ads.c
index 7334c1a15b90..47cb09f08052 100644
--- a/arch/powerpc/platforms/82xx/mpc82xx_ads.c
+++ b/arch/powerpc/platforms/82xx/mpc82xx_ads.c
@@ -456,7 +456,7 @@ void m82xx_pci_init_irq(void)
456 iounmap(immap); 456 iounmap(immap);
457 return; 457 return;
458 } 458 }
459 irq_map = get_property(np, "interrupt-map", &size); 459 irq_map = of_get_property(np, "interrupt-map", &size);
460 if ((!irq_map) || (size <= 7)) { 460 if ((!irq_map) || (size <= 7)) {
461 printk(KERN_INFO "No interrupt-map property of pci node\n"); 461 printk(KERN_INFO "No interrupt-map property of pci node\n");
462 iounmap(immap); 462 iounmap(immap);
@@ -481,7 +481,7 @@ void m82xx_pci_init_irq(void)
481 } 481 }
482 pci_pic_node = of_node_get(np); 482 pci_pic_node = of_node_get(np);
483 /* PCI interrupt controller registers: status and mask */ 483 /* PCI interrupt controller registers: status and mask */
484 regs = get_property(np, "reg", &size); 484 regs = of_get_property(np, "reg", &size);
485 if ((!regs) || (size <= 2)) { 485 if ((!regs) || (size <= 2)) {
486 printk(KERN_INFO "No reg property in pci pic node\n"); 486 printk(KERN_INFO "No reg property in pci pic node\n");
487 iounmap(immap); 487 iounmap(immap);
@@ -521,20 +521,20 @@ void __init add_bridge(struct device_node *np)
521 struct pci_controller *hose; 521 struct pci_controller *hose;
522 struct resource r; 522 struct resource r;
523 const int *bus_range; 523 const int *bus_range;
524 const void *ptr; 524 const uint *ptr;
525 525
526 memset(&r, 0, sizeof(r)); 526 memset(&r, 0, sizeof(r));
527 if (of_address_to_resource(np, 0, &r)) { 527 if (of_address_to_resource(np, 0, &r)) {
528 printk(KERN_INFO "No PCI reg property in device tree\n"); 528 printk(KERN_INFO "No PCI reg property in device tree\n");
529 return; 529 return;
530 } 530 }
531 if (!(ptr = get_property(np, "clock-frequency", NULL))) { 531 if (!(ptr = of_get_property(np, "clock-frequency", NULL))) {
532 printk(KERN_INFO "No clock-frequency property in PCI node"); 532 printk(KERN_INFO "No clock-frequency property in PCI node");
533 return; 533 return;
534 } 534 }
535 pci_clk_frq = *(uint *) ptr; 535 pci_clk_frq = *ptr;
536 of_node_put(np); 536 of_node_put(np);
537 bus_range = get_property(np, "bus-range", &len); 537 bus_range = of_get_property(np, "bus-range", &len);
538 if (bus_range == NULL || len < 2 * sizeof(int)) { 538 if (bus_range == NULL || len < 2 * sizeof(int)) {
539 printk(KERN_WARNING "Can't get bus-range for %s, assume" 539 printk(KERN_WARNING "Can't get bus-range for %s, assume"
540 " bus 0\n", np->full_name); 540 " bus 0\n", np->full_name);
diff --git a/arch/powerpc/platforms/83xx/Kconfig b/arch/powerpc/platforms/83xx/Kconfig
index 713b31a16ce9..19cafdf6df93 100644
--- a/arch/powerpc/platforms/83xx/Kconfig
+++ b/arch/powerpc/platforms/83xx/Kconfig
@@ -1,8 +1,6 @@
1menu "Platform support"
2 depends on PPC_83xx
3
4choice 1choice
5 prompt "Machine Type" 2 prompt "Machine Type"
3 depends on PPC_83xx
6 default MPC834x_MDS 4 default MPC834x_MDS
7 5
8config MPC8313_RDB 6config MPC8313_RDB
@@ -18,6 +16,13 @@ config MPC832x_MDS
18 help 16 help
19 This option enables support for the MPC832x MDS evaluation board. 17 This option enables support for the MPC832x MDS evaluation board.
20 18
19config MPC832x_RDB
20 bool "Freescale MPC832x RDB"
21 select DEFAULT_UIMAGE
22 select QUICC_ENGINE
23 help
24 This option enables support for the MPC8323 RDB board.
25
21config MPC834x_MDS 26config MPC834x_MDS
22 bool "Freescale MPC834x MDS" 27 bool "Freescale MPC834x MDS"
23 select DEFAULT_UIMAGE 28 select DEFAULT_UIMAGE
@@ -57,7 +62,7 @@ config PPC_MPC832x
57 bool 62 bool
58 select PPC_UDBG_16550 63 select PPC_UDBG_16550
59 select PPC_INDIRECT_PCI 64 select PPC_INDIRECT_PCI
60 default y if MPC832x_MDS 65 default y if MPC832x_MDS || MPC832x_RDB
61 66
62config MPC834x 67config MPC834x
63 bool 68 bool
@@ -70,5 +75,3 @@ config PPC_MPC836x
70 select PPC_UDBG_16550 75 select PPC_UDBG_16550
71 select PPC_INDIRECT_PCI 76 select PPC_INDIRECT_PCI
72 default y if MPC836x_MDS 77 default y if MPC836x_MDS
73
74endmenu
diff --git a/arch/powerpc/platforms/83xx/Makefile b/arch/powerpc/platforms/83xx/Makefile
index dfc970d0df10..31a91b53f528 100644
--- a/arch/powerpc/platforms/83xx/Makefile
+++ b/arch/powerpc/platforms/83xx/Makefile
@@ -4,6 +4,7 @@
4obj-y := misc.o 4obj-y := misc.o
5obj-$(CONFIG_PCI) += pci.o 5obj-$(CONFIG_PCI) += pci.o
6obj-$(CONFIG_MPC8313_RDB) += mpc8313_rdb.o 6obj-$(CONFIG_MPC8313_RDB) += mpc8313_rdb.o
7obj-$(CONFIG_MPC832x_RDB) += mpc832x_rdb.o
7obj-$(CONFIG_MPC834x_MDS) += mpc834x_mds.o 8obj-$(CONFIG_MPC834x_MDS) += mpc834x_mds.o
8obj-$(CONFIG_MPC834x_ITX) += mpc834x_itx.o 9obj-$(CONFIG_MPC834x_ITX) += mpc834x_itx.o
9obj-$(CONFIG_MPC836x_MDS) += mpc836x_mds.o 10obj-$(CONFIG_MPC836x_MDS) += mpc836x_mds.o
diff --git a/arch/powerpc/platforms/83xx/mpc832x_mds.c b/arch/powerpc/platforms/83xx/mpc832x_mds.c
index 17e3a3c6d8b4..fff09f5d6edf 100644
--- a/arch/powerpc/platforms/83xx/mpc832x_mds.c
+++ b/arch/powerpc/platforms/83xx/mpc832x_mds.c
@@ -41,7 +41,6 @@
41#include <asm/qe_ic.h> 41#include <asm/qe_ic.h>
42 42
43#include "mpc83xx.h" 43#include "mpc83xx.h"
44#include "mpc832x_mds.h"
45 44
46#undef DEBUG 45#undef DEBUG
47#ifdef DEBUG 46#ifdef DEBUG
diff --git a/arch/powerpc/platforms/83xx/mpc832x_mds.h b/arch/powerpc/platforms/83xx/mpc832x_mds.h
deleted file mode 100644
index a49588904f8a..000000000000
--- a/arch/powerpc/platforms/83xx/mpc832x_mds.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved.
3 *
4 * Description:
5 * MPC832x MDS board specific header.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 */
13
14#ifndef __MACH_MPC832x_MDS_H__
15#define __MACH_MPC832x_MDS_H__
16
17extern u8 *get_bcsr(void);
18
19#endif /* __MACH_MPC832x_MDS_H__ */
diff --git a/arch/powerpc/platforms/83xx/mpc832x_rdb.c b/arch/powerpc/platforms/83xx/mpc832x_rdb.c
new file mode 100644
index 000000000000..6b71e9ffb11a
--- /dev/null
+++ b/arch/powerpc/platforms/83xx/mpc832x_rdb.c
@@ -0,0 +1,138 @@
1/*
2 * arch/powerpc/platforms/83xx/mpc832x_rdb.c
3 *
4 * Copyright (C) Freescale Semiconductor, Inc. 2007. All rights reserved.
5 *
6 * Description:
7 * MPC832x RDB board specific routines.
8 * This file is based on mpc832x_mds.c and mpc8313_rdb.c
9 * Author: Michael Barkowski <michael.barkowski@freescale.com>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 */
16
17#include <linux/pci.h>
18
19#include <asm/of_platform.h>
20#include <asm/time.h>
21#include <asm/ipic.h>
22#include <asm/udbg.h>
23#include <asm/qe.h>
24#include <asm/qe_ic.h>
25
26#include "mpc83xx.h"
27
28#undef DEBUG
29#ifdef DEBUG
30#define DBG(fmt...) udbg_printf(fmt)
31#else
32#define DBG(fmt...)
33#endif
34
35#ifndef CONFIG_PCI
36unsigned long isa_io_base = 0;
37unsigned long isa_mem_base = 0;
38#endif
39
40/* ************************************************************************
41 *
42 * Setup the architecture
43 *
44 */
45static void __init mpc832x_rdb_setup_arch(void)
46{
47 struct device_node *np;
48
49 if (ppc_md.progress)
50 ppc_md.progress("mpc832x_rdb_setup_arch()", 0);
51
52#ifdef CONFIG_PCI
53 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
54 add_bridge(np);
55
56 ppc_md.pci_exclude_device = mpc83xx_exclude_device;
57#endif
58
59#ifdef CONFIG_QUICC_ENGINE
60 qe_reset();
61
62 if ((np = of_find_node_by_name(np, "par_io")) != NULL) {
63 par_io_init(np);
64 of_node_put(np);
65
66 for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)
67 par_io_of_config(np);
68 }
69#endif /* CONFIG_QUICC_ENGINE */
70}
71
72static struct of_device_id mpc832x_ids[] = {
73 { .type = "soc", },
74 { .compatible = "soc", },
75 { .type = "qe", },
76 {},
77};
78
79static int __init mpc832x_declare_of_platform_devices(void)
80{
81 if (!machine_is(mpc832x_rdb))
82 return 0;
83
84 /* Publish the QE devices */
85 of_platform_bus_probe(NULL, mpc832x_ids, NULL);
86
87 return 0;
88}
89device_initcall(mpc832x_declare_of_platform_devices);
90
91void __init mpc832x_rdb_init_IRQ(void)
92{
93
94 struct device_node *np;
95
96 np = of_find_node_by_type(NULL, "ipic");
97 if (!np)
98 return;
99
100 ipic_init(np, 0);
101
102 /* Initialize the default interrupt mapping priorities,
103 * in case the boot rom changed something on us.
104 */
105 ipic_set_default_priority();
106 of_node_put(np);
107
108#ifdef CONFIG_QUICC_ENGINE
109 np = of_find_node_by_type(NULL, "qeic");
110 if (!np)
111 return;
112
113 qe_ic_init(np, 0);
114 of_node_put(np);
115#endif /* CONFIG_QUICC_ENGINE */
116}
117
118/*
119 * Called very early, MMU is off, device-tree isn't unflattened
120 */
121static int __init mpc832x_rdb_probe(void)
122{
123 unsigned long root = of_get_flat_dt_root();
124
125 return of_flat_dt_is_compatible(root, "MPC832xRDB");
126}
127
128define_machine(mpc832x_rdb) {
129 .name = "MPC832x RDB",
130 .probe = mpc832x_rdb_probe,
131 .setup_arch = mpc832x_rdb_setup_arch,
132 .init_IRQ = mpc832x_rdb_init_IRQ,
133 .get_irq = ipic_get_irq,
134 .restart = mpc83xx_restart,
135 .time_init = mpc83xx_time_init,
136 .calibrate_decr = generic_calibrate_decr,
137 .progress = udbg_progress,
138};
diff --git a/arch/powerpc/platforms/83xx/mpc834x_itx.h b/arch/powerpc/platforms/83xx/mpc834x_itx.h
deleted file mode 100644
index 174ca4ef55f3..000000000000
--- a/arch/powerpc/platforms/83xx/mpc834x_itx.h
+++ /dev/null
@@ -1,23 +0,0 @@
1/*
2 * arch/powerpc/platforms/83xx/mpc834x_itx.h
3 *
4 * MPC834X ITX common board definitions
5 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 */
14
15#ifndef __MACH_MPC83XX_ITX_H__
16#define __MACH_MPC83XX_ITX_H__
17
18#define PIRQA MPC83xx_IRQ_EXT4
19#define PIRQB MPC83xx_IRQ_EXT5
20#define PIRQC MPC83xx_IRQ_EXT6
21#define PIRQD MPC83xx_IRQ_EXT7
22
23#endif /* __MACH_MPC83XX_ITX_H__ */
diff --git a/arch/powerpc/platforms/83xx/pci.c b/arch/powerpc/platforms/83xx/pci.c
index 9c3650555144..774457d09e94 100644
--- a/arch/powerpc/platforms/83xx/pci.c
+++ b/arch/powerpc/platforms/83xx/pci.c
@@ -60,7 +60,7 @@ int __init add_bridge(struct device_node *dev)
60 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0); 60 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
61 61
62 /* Get bus range if any */ 62 /* Get bus range if any */
63 bus_range = get_property(dev, "bus-range", &len); 63 bus_range = of_get_property(dev, "bus-range", &len);
64 if (bus_range == NULL || len < 2 * sizeof(int)) { 64 if (bus_range == NULL || len < 2 * sizeof(int)) {
65 printk(KERN_WARNING "Can't get bus-range for %s, assume" 65 printk(KERN_WARNING "Can't get bus-range for %s, assume"
66 " bus 0\n", dev->full_name); 66 " bus 0\n", dev->full_name);
diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
index e764c0aced88..629926e01e90 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -1,8 +1,6 @@
1menu "Platform support"
2 depends on PPC_85xx
3
4choice 1choice
5 prompt "Machine Type" 2 prompt "Machine Type"
3 depends on PPC_85xx
6 default MPC8540_ADS 4 default MPC8540_ADS
7 5
8config MPC8540_ADS 6config MPC8540_ADS
@@ -30,6 +28,12 @@ config MPC85xx_MDS
30 help 28 help
31 This option enables support for the MPC85xx MDS board 29 This option enables support for the MPC85xx MDS board
32 30
31config MPC8544_DS
32 bool "Freescale MPC8544 DS"
33 select DEFAULT_UIMAGE
34 help
35 This option enables support for the MPC8544 DS board
36
33endchoice 37endchoice
34 38
35config MPC8540 39config MPC8540
@@ -40,33 +44,15 @@ config MPC8540
40 44
41config MPC8560 45config MPC8560
42 bool 46 bool
43 select PPC_INDIRECT_PCI 47 select CPM2
44 default y if MPC8560_ADS 48 default y if MPC8560_ADS
45 49
46config MPC85xx 50config MPC85xx
47 bool 51 bool
48 select PPC_UDBG_16550 52 select PPC_UDBG_16550
49 select PPC_INDIRECT_PCI 53 select PPC_INDIRECT_PCI
54 select PPC_INDIRECT_PCI_BE
55 select MPIC
50 select SERIAL_8250_SHARE_IRQ if SERIAL_8250 56 select SERIAL_8250_SHARE_IRQ if SERIAL_8250
51 default y if MPC8540_ADS || MPC85xx_CDS || MPC8560_ADS || MPC85xx_MDS 57 default y if MPC8540_ADS || MPC85xx_CDS || MPC8560_ADS \
52 58 || MPC85xx_MDS || MPC8544_DS
53config PPC_INDIRECT_PCI_BE
54 bool
55 depends on PPC_85xx
56 default y
57
58config MPIC
59 bool
60 default y
61
62config CPM2
63 bool
64 depends on MPC8560
65 default y
66 help
67 The CPM2 (Communications Processor Module) is a coprocessor on
68 embedded CPUs made by Motorola. Selecting this option means that
69 you wish to build a kernel for a machine with a CPM2 coprocessor
70 on it.
71
72endmenu
diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index 4e63917ada9d..4e02cbb14cf7 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -5,4 +5,5 @@ obj-$(CONFIG_PPC_85xx) += misc.o pci.o
5obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o 5obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o
6obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o 6obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o
7obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o 7obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o
8obj-$(CONFIG_MPC8544_DS) += mpc8544_ds.o
8obj-$(CONFIG_MPC85xx_MDS) += mpc85xx_mds.o 9obj-$(CONFIG_MPC85xx_MDS) += mpc85xx_mds.o
diff --git a/arch/powerpc/platforms/85xx/mpc8544_ds.c b/arch/powerpc/platforms/85xx/mpc8544_ds.c
new file mode 100644
index 000000000000..2867f85e6325
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/mpc8544_ds.c
@@ -0,0 +1,144 @@
1/*
2 * MPC8544 DS Board Setup
3 *
4 * Author Xianghua Xiao (x.xiao@freescale.com)
5 * Copyright 2007 Freescale Semiconductor Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/stddef.h>
14#include <linux/kernel.h>
15#include <linux/kdev_t.h>
16#include <linux/delay.h>
17#include <linux/seq_file.h>
18
19#include <asm/system.h>
20#include <asm/time.h>
21#include <asm/machdep.h>
22#include <asm/mpc85xx.h>
23#include <mm/mmu_decl.h>
24#include <asm/prom.h>
25#include <asm/udbg.h>
26#include <asm/mpic.h>
27#include <asm/i8259.h>
28
29#include <sysdev/fsl_soc.h>
30#include "mpc85xx.h"
31
32#undef DEBUG
33
34#ifdef DEBUG
35#define DBG(fmt, args...) printk(KERN_ERR "%s: " fmt, __FUNCTION__, ## args)
36#else
37#define DBG(fmt, args...)
38#endif
39
40
41void __init mpc8544_ds_pic_init(void)
42{
43 struct mpic *mpic;
44 struct resource r;
45 struct device_node *np = NULL;
46#ifdef CONFIG_PPC_I8259
47 struct device_node *cascade_node = NULL;
48 int cascade_irq;
49#endif
50
51 np = of_find_node_by_type(np, "open-pic");
52
53 if (np == NULL) {
54 printk(KERN_ERR "Could not find open-pic node\n");
55 return;
56 }
57
58 if (of_address_to_resource(np, 0, &r)) {
59 printk(KERN_ERR "Failed to map mpic register space\n");
60 of_node_put(np);
61 return;
62 }
63
64 /* Alloc mpic structure and per isu has 16 INT entries. */
65 mpic = mpic_alloc(np, r.start,
66 MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
67 16, 64, " OPENPIC ");
68 BUG_ON(mpic == NULL);
69
70 /*
71 * 48 Internal Interrupts
72 */
73 mpic_assign_isu(mpic, 0, r.start + 0x10200);
74 mpic_assign_isu(mpic, 1, r.start + 0x10400);
75 mpic_assign_isu(mpic, 2, r.start + 0x10600);
76
77 /*
78 * 16 External interrupts
79 */
80 mpic_assign_isu(mpic, 3, r.start + 0x10000);
81
82 mpic_init(mpic);
83
84#ifdef CONFIG_PPC_I8259
85 /* Initialize the i8259 controller */
86 for_each_node_by_type(np, "interrupt-controller")
87 if (device_is_compatible(np, "chrp,iic")) {
88 cascade_node = np;
89 break;
90 }
91
92 if (cascade_node == NULL) {
93 printk(KERN_DEBUG "Could not find i8259 PIC\n");
94 return;
95 }
96
97 cascade_irq = irq_of_parse_and_map(cascade_node, 0);
98 if (cascade_irq == NO_IRQ) {
99 printk(KERN_ERR "Failed to map cascade interrupt\n");
100 return;
101 }
102
103 DBG("mpc8544ds: cascade mapped to irq %d\n", cascade_irq);
104
105 i8259_init(cascade_node, 0);
106 of_node_put(cascade_node);
107
108 set_irq_chained_handler(cascade_irq, mpc8544_8259_cascade);
109#endif /* CONFIG_PPC_I8259 */
110}
111
112
113/*
114 * Setup the architecture
115 */
116static void __init mpc8544_ds_setup_arch(void)
117{
118 if (ppc_md.progress)
119 ppc_md.progress("mpc8544_ds_setup_arch()", 0);
120
121 printk("MPC8544 DS board from Freescale Semiconductor\n");
122}
123
124
125/*
126 * Called very early, device-tree isn't unflattened
127 */
128static int __init mpc8544_ds_probe(void)
129{
130 unsigned long root = of_get_flat_dt_root();
131
132 return of_flat_dt_is_compatible(root, "MPC8544DS");
133}
134
135define_machine(mpc8544_ds) {
136 .name = "MPC8544 DS",
137 .probe = mpc8544_ds_probe,
138 .setup_arch = mpc8544_ds_setup_arch,
139 .init_IRQ = mpc8544_ds_pic_init,
140 .get_irq = mpic_get_irq,
141 .restart = mpc85xx_restart,
142 .calibrate_decr = generic_calibrate_decr,
143 .progress = udbg_progress,
144};
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
index 8ed034aeca5f..5d27621f0927 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ads.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -227,7 +227,7 @@ static void __init mpc85xx_ads_setup_arch(void)
227 if (cpu != 0) { 227 if (cpu != 0) {
228 const unsigned int *fp; 228 const unsigned int *fp;
229 229
230 fp = get_property(cpu, "clock-frequency", NULL); 230 fp = of_get_property(cpu, "clock-frequency", NULL);
231 if (fp != 0) 231 if (fp != 0)
232 loops_per_jiffy = *fp / HZ; 232 loops_per_jiffy = *fp / HZ;
233 else 233 else
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_cds.c b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
index 4232686be441..7e71636f9098 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_cds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_cds.c
@@ -237,7 +237,7 @@ static void __init mpc85xx_cds_setup_arch(void)
237 if (cpu != 0) { 237 if (cpu != 0) {
238 const unsigned int *fp; 238 const unsigned int *fp;
239 239
240 fp = get_property(cpu, "clock-frequency", NULL); 240 fp = of_get_property(cpu, "clock-frequency", NULL);
241 if (fp != 0) 241 if (fp != 0)
242 loops_per_jiffy = *fp / HZ; 242 loops_per_jiffy = *fp / HZ;
243 else 243 else
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 81144d2ae455..54db41689954 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -80,7 +80,7 @@ static void __init mpc85xx_mds_setup_arch(void)
80 np = of_find_node_by_type(NULL, "cpu"); 80 np = of_find_node_by_type(NULL, "cpu");
81 if (np != NULL) { 81 if (np != NULL) {
82 const unsigned int *fp = 82 const unsigned int *fp =
83 get_property(np, "clock-frequency", NULL); 83 of_get_property(np, "clock-frequency", NULL);
84 if (fp != NULL) 84 if (fp != NULL)
85 loops_per_jiffy = *fp / HZ; 85 loops_per_jiffy = *fp / HZ;
86 else 86 else
diff --git a/arch/powerpc/platforms/85xx/pci.c b/arch/powerpc/platforms/85xx/pci.c
index 05930eeb6e7f..48f17e23d771 100644
--- a/arch/powerpc/platforms/85xx/pci.c
+++ b/arch/powerpc/platforms/85xx/pci.c
@@ -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 = get_property(dev, "bus-range", &len); 54 bus_range = of_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/Kconfig b/arch/powerpc/platforms/86xx/Kconfig
index 0c70944d0e37..d1bcff500464 100644
--- a/arch/powerpc/platforms/86xx/Kconfig
+++ b/arch/powerpc/platforms/86xx/Kconfig
@@ -1,8 +1,6 @@
1menu "Platform Support"
2 depends on PPC_86xx
3
4choice 1choice
5 prompt "Machine Type" 2 prompt "Machine Type"
3 depends on PPC_86xx
6 default MPC8641_HPCN 4 default MPC8641_HPCN
7 5
8config MPC8641_HPCN 6config MPC8641_HPCN
@@ -14,20 +12,10 @@ config MPC8641_HPCN
14 12
15endchoice 13endchoice
16 14
17
18config MPC8641 15config MPC8641
19 bool 16 bool
20 select PPC_INDIRECT_PCI 17 select PPC_INDIRECT_PCI
18 select PPC_INDIRECT_PCI_BE
21 select PPC_UDBG_16550 19 select PPC_UDBG_16550
20 select MPIC
22 default y if MPC8641_HPCN 21 default y if MPC8641_HPCN
23
24config MPIC
25 bool
26 default y
27
28config PPC_INDIRECT_PCI_BE
29 bool
30 depends on PPC_86xx
31 default y
32
33endmenu
diff --git a/arch/powerpc/platforms/86xx/Makefile b/arch/powerpc/platforms/86xx/Makefile
index 476a6eeee710..418fd8f4d268 100644
--- a/arch/powerpc/platforms/86xx/Makefile
+++ b/arch/powerpc/platforms/86xx/Makefile
@@ -4,4 +4,4 @@
4 4
5obj-$(CONFIG_SMP) += mpc86xx_smp.o 5obj-$(CONFIG_SMP) += mpc86xx_smp.o
6obj-$(CONFIG_MPC8641_HPCN) += mpc86xx_hpcn.o 6obj-$(CONFIG_MPC8641_HPCN) += mpc86xx_hpcn.o
7obj-$(CONFIG_PCI) += pci.o mpc86xx_pcie.o 7obj-$(CONFIG_PCI) += pci.o
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index f42f801cf84e..3d3d98f5bd4a 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -349,7 +349,7 @@ mpc86xx_hpcn_setup_arch(void)
349 if (np != 0) { 349 if (np != 0) {
350 const unsigned int *fp; 350 const unsigned int *fp;
351 351
352 fp = get_property(np, "clock-frequency", NULL); 352 fp = of_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
@@ -384,7 +384,7 @@ mpc86xx_hpcn_show_cpuinfo(struct seq_file *m)
384 384
385 root = of_find_node_by_path("/"); 385 root = of_find_node_by_path("/");
386 if (root) 386 if (root)
387 model = get_property(root, "model", NULL); 387 model = of_get_property(root, "model", NULL);
388 seq_printf(m, "Machine\t\t: %s\n", model); 388 seq_printf(m, "Machine\t\t: %s\n", model);
389 of_node_put(root); 389 of_node_put(root);
390 390
diff --git a/arch/powerpc/platforms/86xx/pci.c b/arch/powerpc/platforms/86xx/pci.c
index 481e18ed5be9..8235c562661f 100644
--- a/arch/powerpc/platforms/86xx/pci.c
+++ b/arch/powerpc/platforms/86xx/pci.c
@@ -22,9 +22,9 @@
22#include <asm/atomic.h> 22#include <asm/atomic.h>
23#include <asm/io.h> 23#include <asm/io.h>
24#include <asm/prom.h> 24#include <asm/prom.h>
25#include <asm/immap_86xx.h>
26#include <asm/pci-bridge.h> 25#include <asm/pci-bridge.h>
27#include <sysdev/fsl_soc.h> 26#include <sysdev/fsl_soc.h>
27#include <sysdev/fsl_pcie.h>
28 28
29#include "mpc86xx.h" 29#include "mpc86xx.h"
30 30
@@ -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 = get_property(dev, "bus-range", &len); 166 bus_range = of_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/8xx/Kconfig b/arch/powerpc/platforms/8xx/Kconfig
index beea6834bb7e..39bb8c5ebe70 100644
--- a/arch/powerpc/platforms/8xx/Kconfig
+++ b/arch/powerpc/platforms/8xx/Kconfig
@@ -1,6 +1,3 @@
1menu "Platform support"
2 depends on PPC_8xx
3
4config FADS 1config FADS
5 bool 2 bool
6 3
@@ -9,6 +6,7 @@ config CPM1
9 6
10choice 7choice
11 prompt "8xx Machine Type" 8 prompt "8xx Machine Type"
9 depends on PPC_8xx
12 depends on 8xx 10 depends on 8xx
13 default MPC885ADS 11 default MPC885ADS
14 12
@@ -36,38 +34,36 @@ config MPC885ADS
36endchoice 34endchoice
37 35
38menu "Freescale Ethernet driver platform-specific options" 36menu "Freescale Ethernet driver platform-specific options"
39 depends on (FS_ENET && MPC885ADS) 37 depends on (FS_ENET && MPC885ADS)
40
41 config MPC8xx_SECOND_ETH
42 bool "Second Ethernet channel"
43 depends on MPC885ADS
44 default y
45 help
46 This enables support for second Ethernet on MPC885ADS and MPC86xADS boards.
47 The latter will use SCC1, for 885ADS you can select it below.
48
49 choice
50 prompt "Second Ethernet channel"
51 depends on MPC8xx_SECOND_ETH
52 default MPC8xx_SECOND_ETH_FEC2
53
54 config MPC8xx_SECOND_ETH_FEC2
55 bool "FEC2"
56 depends on MPC885ADS
57 help
58 Enable FEC2 to serve as 2-nd Ethernet channel. Note that SMC2
59 (often 2-nd UART) will not work if this is enabled.
60
61 config MPC8xx_SECOND_ETH_SCC3
62 bool "SCC3"
63 depends on MPC885ADS
64 help
65 Enable SCC3 to serve as 2-nd Ethernet channel. Note that SMC1
66 (often 1-nd UART) will not work if this is enabled.
67
68 endchoice
69 38
70endmenu 39 config MPC8xx_SECOND_ETH
40 bool "Second Ethernet channel"
41 depends on MPC885ADS
42 default y
43 help
44 This enables support for second Ethernet on MPC885ADS and MPC86xADS boards.
45 The latter will use SCC1, for 885ADS you can select it below.
46
47 choice
48 prompt "Second Ethernet channel"
49 depends on MPC8xx_SECOND_ETH
50 default MPC8xx_SECOND_ETH_FEC2
51
52 config MPC8xx_SECOND_ETH_FEC2
53 bool "FEC2"
54 depends on MPC885ADS
55 help
56 Enable FEC2 to serve as 2-nd Ethernet channel. Note that SMC2
57 (often 2-nd UART) will not work if this is enabled.
58
59 config MPC8xx_SECOND_ETH_SCC3
60 bool "SCC3"
61 depends on MPC885ADS
62 help
63 Enable SCC3 to serve as 2-nd Ethernet channel. Note that SMC1
64 (often 1-nd UART) will not work if this is enabled.
65
66 endchoice
71 67
72endmenu 68endmenu
73 69
@@ -98,7 +94,7 @@ config 8xx_CPU6
98 require workarounds for Linux (and most other OSes to work). If you 94 require workarounds for Linux (and most other OSes to work). If you
99 get a BUG() very early in boot, this might fix the problem. For 95 get a BUG() very early in boot, this might fix the problem. For
100 more details read the document entitled "MPC860 Family Device Errata 96 more details read the document entitled "MPC860 Family Device Errata
101 Reference" on Motorola's website. This option also incurs a 97 Reference" on Freescale's website. This option also incurs a
102 performance hit. 98 performance hit.
103 99
104 If in doubt, say N here. 100 If in doubt, say N here.
@@ -135,4 +131,3 @@ config UCODE_PATCH
135 depends on !NO_UCODE_PATCH 131 depends on !NO_UCODE_PATCH
136 132
137endmenu 133endmenu
138
diff --git a/arch/powerpc/platforms/8xx/m8xx_setup.c b/arch/powerpc/platforms/8xx/m8xx_setup.c
index 9ed7125f0150..0901dbada350 100644
--- a/arch/powerpc/platforms/8xx/m8xx_setup.c
+++ b/arch/powerpc/platforms/8xx/m8xx_setup.c
@@ -85,17 +85,17 @@ init_internal_rtc(void)
85static int __init get_freq(char *name, unsigned long *val) 85static int __init get_freq(char *name, unsigned long *val)
86{ 86{
87 struct device_node *cpu; 87 struct device_node *cpu;
88 unsigned int *fp; 88 const unsigned int *fp;
89 int found = 0; 89 int found = 0;
90 90
91 /* The cpu node should have timebase and clock frequency properties */ 91 /* The cpu node should have timebase and clock frequency properties */
92 cpu = of_find_node_by_type(NULL, "cpu"); 92 cpu = of_find_node_by_type(NULL, "cpu");
93 93
94 if (cpu) { 94 if (cpu) {
95 fp = (unsigned int *)get_property(cpu, name, NULL); 95 fp = of_get_property(cpu, name, NULL);
96 if (fp) { 96 if (fp) {
97 found = 1; 97 found = 1;
98 *val = *fp++; 98 *val = *fp;
99 } 99 }
100 100
101 of_node_put(cpu); 101 of_node_put(cpu);
@@ -262,7 +262,7 @@ void mpc8xx_show_cpuinfo(struct seq_file *m)
262 262
263 root = of_find_node_by_path("/"); 263 root = of_find_node_by_path("/");
264 if (root) 264 if (root)
265 model = get_property(root, "model", NULL); 265 model = of_get_property(root, "model", NULL);
266 seq_printf(m, "Machine\t\t: %s\n", model); 266 seq_printf(m, "Machine\t\t: %s\n", model);
267 of_node_put(root); 267 of_node_put(root);
268 268
diff --git a/arch/powerpc/platforms/8xx/mpc86xads.h b/arch/powerpc/platforms/8xx/mpc86xads.h
index b5d19dd0619c..59bad2f9ae51 100644
--- a/arch/powerpc/platforms/8xx/mpc86xads.h
+++ b/arch/powerpc/platforms/8xx/mpc86xads.h
@@ -37,7 +37,7 @@
37#define CPM_MAP_ADDR (get_immrbase() + MPC8xx_CPM_OFFSET) 37#define CPM_MAP_ADDR (get_immrbase() + MPC8xx_CPM_OFFSET)
38#define CPM_IRQ_OFFSET 16 // for compability with cpm_uart driver 38#define CPM_IRQ_OFFSET 16 // for compability with cpm_uart driver
39 39
40#define PCMCIA_MEM_ADDR (uint)0xff020000) 40#define PCMCIA_MEM_ADDR ((uint)0xff020000)
41#define PCMCIA_MEM_SIZE ((uint)(64 * 1024)) 41#define PCMCIA_MEM_SIZE ((uint)(64 * 1024))
42 42
43/* Bits of interest in the BCSRs. 43/* Bits of interest in the BCSRs.
diff --git a/arch/powerpc/platforms/8xx/mpc86xads_setup.c b/arch/powerpc/platforms/8xx/mpc86xads_setup.c
index ef52ce701b0e..a35315af5c53 100644
--- a/arch/powerpc/platforms/8xx/mpc86xads_setup.c
+++ b/arch/powerpc/platforms/8xx/mpc86xads_setup.c
@@ -247,7 +247,7 @@ void init_smc_ioports(struct fs_uart_platform_info *data)
247 } 247 }
248} 248}
249 249
250int platform_device_skip(char *model, int id) 250int platform_device_skip(const char *model, int id)
251{ 251{
252 return 0; 252 return 0;
253} 253}
@@ -260,7 +260,7 @@ static void __init mpc86xads_setup_arch(void)
260 if (cpu != 0) { 260 if (cpu != 0) {
261 const unsigned int *fp; 261 const unsigned int *fp;
262 262
263 fp = get_property(cpu, "clock-frequency", NULL); 263 fp = of_get_property(cpu, "clock-frequency", NULL);
264 if (fp != 0) 264 if (fp != 0)
265 loops_per_jiffy = *fp / HZ; 265 loops_per_jiffy = *fp / HZ;
266 else 266 else
diff --git a/arch/powerpc/platforms/8xx/mpc885ads.h b/arch/powerpc/platforms/8xx/mpc885ads.h
index 30cbebfe84c5..7c31aec284c2 100644
--- a/arch/powerpc/platforms/8xx/mpc885ads.h
+++ b/arch/powerpc/platforms/8xx/mpc885ads.h
@@ -37,7 +37,7 @@
37#define CPM_MAP_ADDR (get_immrbase() + MPC8xx_CPM_OFFSET) 37#define CPM_MAP_ADDR (get_immrbase() + MPC8xx_CPM_OFFSET)
38#define CPM_IRQ_OFFSET 16 // for compability with cpm_uart driver 38#define CPM_IRQ_OFFSET 16 // for compability with cpm_uart driver
39 39
40#define PCMCIA_MEM_ADDR (uint)0xff020000) 40#define PCMCIA_MEM_ADDR ((uint)0xff020000)
41#define PCMCIA_MEM_SIZE ((uint)(64 * 1024)) 41#define PCMCIA_MEM_SIZE ((uint)(64 * 1024))
42 42
43/* Bits of interest in the BCSRs. 43/* Bits of interest in the BCSRs.
diff --git a/arch/powerpc/platforms/8xx/mpc885ads_setup.c b/arch/powerpc/platforms/8xx/mpc885ads_setup.c
index c5fefdf66c0a..a57b57785acd 100644
--- a/arch/powerpc/platforms/8xx/mpc885ads_setup.c
+++ b/arch/powerpc/platforms/8xx/mpc885ads_setup.c
@@ -322,7 +322,7 @@ void init_smc_ioports(struct fs_uart_platform_info *data)
322 } 322 }
323} 323}
324 324
325int platform_device_skip(char *model, int id) 325int platform_device_skip(const char *model, int id)
326{ 326{
327#ifdef CONFIG_MPC8xx_SECOND_ETH_SCC3 327#ifdef CONFIG_MPC8xx_SECOND_ETH_SCC3
328 const char *dev = "FEC"; 328 const char *dev = "FEC";
@@ -346,7 +346,7 @@ static void __init mpc885ads_setup_arch(void)
346 if (cpu != 0) { 346 if (cpu != 0) {
347 const unsigned int *fp; 347 const unsigned int *fp;
348 348
349 fp = get_property(cpu, "clock-frequency", NULL); 349 fp = of_get_property(cpu, "clock-frequency", NULL);
350 if (fp != 0) 350 if (fp != 0)
351 loops_per_jiffy = *fp / HZ; 351 loops_per_jiffy = *fp / HZ;
352 else 352 else
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
new file mode 100644
index 000000000000..51e33347c147
--- /dev/null
+++ b/arch/powerpc/platforms/Kconfig
@@ -0,0 +1,259 @@
1menu "Platform support"
2
3choice
4 prompt "Machine type"
5 depends on PPC64 || CLASSIC32
6 default PPC_MULTIPLATFORM
7
8config PPC_MULTIPLATFORM
9 bool "Generic desktop/server/laptop"
10 help
11 Select this option if configuring for an IBM pSeries or
12 RS/6000 machine, an Apple machine, or a PReP, CHRP,
13 Maple or Cell-based machine.
14
15config EMBEDDED6xx
16 bool "Embedded 6xx/7xx/7xxx-based board"
17 depends on PPC32 && (BROKEN||BROKEN_ON_SMP)
18
19config APUS
20 bool "Amiga-APUS"
21 depends on PPC32 && BROKEN
22 help
23 Select APUS if configuring for a PowerUP Amiga.
24 More information is available at:
25 <http://linux-apus.sourceforge.net/>.
26endchoice
27
28source "arch/powerpc/platforms/pseries/Kconfig"
29source "arch/powerpc/platforms/iseries/Kconfig"
30source "arch/powerpc/platforms/chrp/Kconfig"
31source "arch/powerpc/platforms/52xx/Kconfig"
32source "arch/powerpc/platforms/powermac/Kconfig"
33source "arch/powerpc/platforms/prep/Kconfig"
34source "arch/powerpc/platforms/maple/Kconfig"
35source "arch/powerpc/platforms/pasemi/Kconfig"
36source "arch/powerpc/platforms/celleb/Kconfig"
37source "arch/powerpc/platforms/ps3/Kconfig"
38source "arch/powerpc/platforms/cell/Kconfig"
39source "arch/powerpc/platforms/8xx/Kconfig"
40source "arch/powerpc/platforms/82xx/Kconfig"
41source "arch/powerpc/platforms/83xx/Kconfig"
42source "arch/powerpc/platforms/85xx/Kconfig"
43source "arch/powerpc/platforms/86xx/Kconfig"
44source "arch/powerpc/platforms/embedded6xx/Kconfig"
45#source "arch/powerpc/platforms/4xx/Kconfig
46
47config PPC_NATIVE
48 bool
49 depends on PPC_MULTIPLATFORM
50 help
51 Support for running natively on the hardware, i.e. without
52 a hypervisor. This option is not user-selectable but should
53 be selected by all platforms that need it.
54
55config UDBG_RTAS_CONSOLE
56 bool "RTAS based debug console"
57 depends on PPC_RTAS
58 default n
59
60config PPC_UDBG_BEAT
61 bool "BEAT based debug console"
62 depends on PPC_CELLEB
63 default n
64
65config XICS
66 depends on PPC_PSERIES
67 bool
68 default y
69
70config MPIC
71 bool
72 default n
73
74config MPIC_WEIRD
75 bool
76 default n
77
78config PPC_I8259
79 bool
80 default n
81
82config U3_DART
83 bool
84 depends on PPC_MULTIPLATFORM && PPC64
85 default n
86
87config PPC_RTAS
88 bool
89 default n
90
91config RTAS_ERROR_LOGGING
92 bool
93 depends on PPC_RTAS
94 default n
95
96config RTAS_PROC
97 bool "Proc interface to RTAS"
98 depends on PPC_RTAS
99 default y
100
101config RTAS_FLASH
102 tristate "Firmware flash interface"
103 depends on PPC64 && RTAS_PROC
104
105config PPC_PMI
106 tristate "Support for PMI"
107 depends PPC_IBM_CELL_BLADE
108 help
109 PMI (Platform Management Interrupt) is a way to
110 communicate with the BMC (Baseboard Mangement Controller).
111 It is used in some IBM Cell blades.
112 default m
113
114config MMIO_NVRAM
115 bool
116 default n
117
118config MPIC_U3_HT_IRQS
119 bool
120 depends on PPC_MAPLE
121 default y
122
123config IBMVIO
124 depends on PPC_PSERIES || PPC_ISERIES
125 bool
126 default y
127
128config IBMEBUS
129 depends on PPC_PSERIES
130 bool "Support for GX bus based adapters"
131 help
132 Bus device driver for GX bus based adapters.
133
134config PPC_MPC106
135 bool
136 default n
137
138config PPC_970_NAP
139 bool
140 default n
141
142config PPC_INDIRECT_IO
143 bool
144 select GENERIC_IOMAP
145 default n
146
147config GENERIC_IOMAP
148 bool
149 default n
150
151source "drivers/cpufreq/Kconfig"
152
153menu "CPU Frequency drivers"
154 depends on CPU_FREQ
155
156config CPU_FREQ_PMAC
157 bool "Support for Apple PowerBooks"
158 depends on ADB_PMU && PPC32
159 select CPU_FREQ_TABLE
160 help
161 This adds support for frequency switching on Apple PowerBooks,
162 this currently includes some models of iBook & Titanium
163 PowerBook.
164
165config CPU_FREQ_PMAC64
166 bool "Support for some Apple G5s"
167 depends on PPC_PMAC && PPC64
168 select CPU_FREQ_TABLE
169 help
170 This adds support for frequency switching on Apple iMac G5,
171 and some of the more recent desktop G5 machines as well.
172
173config PPC_PASEMI_CPUFREQ
174 bool "Support for PA Semi PWRficient"
175 depends on PPC_PASEMI
176 default y
177 select CPU_FREQ_TABLE
178 help
179 This adds the support for frequency switching on PA Semi
180 PWRficient processors.
181
182endmenu
183
184config PPC601_SYNC_FIX
185 bool "Workarounds for PPC601 bugs"
186 depends on 6xx && (PPC_PREP || PPC_PMAC)
187 help
188 Some versions of the PPC601 (the first PowerPC chip) have bugs which
189 mean that extra synchronization instructions are required near
190 certain instructions, typically those that make major changes to the
191 CPU state. These extra instructions reduce performance slightly.
192 If you say N here, these extra instructions will not be included,
193 resulting in a kernel which will run faster but may not run at all
194 on some systems with the PPC601 chip.
195
196 If in doubt, say Y here.
197
198config TAU
199 bool "On-chip CPU temperature sensor support"
200 depends on CLASSIC32
201 help
202 G3 and G4 processors have an on-chip temperature sensor called the
203 'Thermal Assist Unit (TAU)', which, in theory, can measure the on-die
204 temperature within 2-4 degrees Celsius. This option shows the current
205 on-die temperature in /proc/cpuinfo if the cpu supports it.
206
207 Unfortunately, on some chip revisions, this sensor is very inaccurate
208 and in many cases, does not work at all, so don't assume the cpu
209 temp is actually what /proc/cpuinfo says it is.
210
211config TAU_INT
212 bool "Interrupt driven TAU driver (DANGEROUS)"
213 depends on TAU
214 ---help---
215 The TAU supports an interrupt driven mode which causes an interrupt
216 whenever the temperature goes out of range. This is the fastest way
217 to get notified the temp has exceeded a range. With this option off,
218 a timer is used to re-check the temperature periodically.
219
220 However, on some cpus it appears that the TAU interrupt hardware
221 is buggy and can cause a situation which would lead unexplained hard
222 lockups.
223
224 Unless you are extending the TAU driver, or enjoy kernel/hardware
225 debugging, leave this option off.
226
227config TAU_AVERAGE
228 bool "Average high and low temp"
229 depends on TAU
230 ---help---
231 The TAU hardware can compare the temperature to an upper and lower
232 bound. The default behavior is to show both the upper and lower
233 bound in /proc/cpuinfo. If the range is large, the temperature is
234 either changing a lot, or the TAU hardware is broken (likely on some
235 G4's). If the range is small (around 4 degrees), the temperature is
236 relatively stable. If you say Y here, a single temperature value,
237 halfway between the upper and lower bounds, will be reported in
238 /proc/cpuinfo.
239
240 If in doubt, say N here.
241
242config QUICC_ENGINE
243 bool
244 help
245 The QUICC Engine (QE) is a new generation of communications
246 coprocessors on Freescale embedded CPUs (akin to CPM in older chips).
247 Selecting this option means that you wish to build a kernel
248 for a machine with a QE coprocessor.
249
250config CPM2
251 bool
252 default n
253 help
254 The CPM2 (Communications Processor Module) is a coprocessor on
255 embedded CPUs made by Freescale. Selecting this option means that
256 you wish to build a kernel for a machine with a CPM2 coprocessor
257 on it (826x, 827x, 8560).
258
259endmenu
diff --git a/arch/powerpc/platforms/cell/Kconfig b/arch/powerpc/platforms/cell/Kconfig
index 06a85b704331..82551770917c 100644
--- a/arch/powerpc/platforms/cell/Kconfig
+++ b/arch/powerpc/platforms/cell/Kconfig
@@ -1,3 +1,26 @@
1config PPC_CELL
2 bool
3 default n
4
5config PPC_CELL_NATIVE
6 bool
7 select PPC_CELL
8 select PPC_DCR_MMIO
9 select PPC_OF_PLATFORM_PCI
10 select PPC_INDIRECT_IO
11 select PPC_NATIVE
12 select MPIC
13 default n
14
15config PPC_IBM_CELL_BLADE
16 bool "IBM Cell Blade"
17 depends on PPC_MULTIPLATFORM && PPC64
18 select PPC_CELL_NATIVE
19 select PPC_RTAS
20 select MMIO_NVRAM
21 select PPC_UDBG_16550
22 select UDBG_RTAS_CONSOLE
23
1menu "Cell Broadband Engine options" 24menu "Cell Broadband Engine options"
2 depends on PPC_CELL 25 depends on PPC_CELL
3 26
@@ -18,6 +41,7 @@ config SPU_BASE
18 41
19config CBE_RAS 42config CBE_RAS
20 bool "RAS features for bare metal Cell BE" 43 bool "RAS features for bare metal Cell BE"
44 depends on PPC_CELL_NATIVE
21 default y 45 default y
22 46
23config CBE_THERM 47config CBE_THERM
diff --git a/arch/powerpc/platforms/cell/cbe_cpufreq.c b/arch/powerpc/platforms/cell/cbe_cpufreq.c
index a3850fd1e94c..f9ac3fe3be97 100644
--- a/arch/powerpc/platforms/cell/cbe_cpufreq.c
+++ b/arch/powerpc/platforms/cell/cbe_cpufreq.c
@@ -25,9 +25,12 @@
25 25
26#include <asm/hw_irq.h> 26#include <asm/hw_irq.h>
27#include <asm/io.h> 27#include <asm/io.h>
28#include <asm/machdep.h>
28#include <asm/processor.h> 29#include <asm/processor.h>
29#include <asm/prom.h> 30#include <asm/prom.h>
30#include <asm/time.h> 31#include <asm/time.h>
32#include <asm/pmi.h>
33#include <asm/of_platform.h>
31 34
32#include "cbe_regs.h" 35#include "cbe_regs.h"
33 36
@@ -68,6 +71,38 @@ static u64 MIC_Slow_Next_Timer_table[] = {
68 * hardware specific functions 71 * hardware specific functions
69 */ 72 */
70 73
74static struct of_device *pmi_dev;
75
76static int set_pmode_pmi(int cpu, unsigned int pmode)
77{
78 int ret;
79 pmi_message_t pmi_msg;
80#ifdef DEBUG
81 u64 time;
82#endif
83
84 pmi_msg.type = PMI_TYPE_FREQ_CHANGE;
85 pmi_msg.data1 = cbe_cpu_to_node(cpu);
86 pmi_msg.data2 = pmode;
87
88#ifdef DEBUG
89 time = (u64) get_cycles();
90#endif
91
92 pmi_send_message(pmi_dev, pmi_msg);
93 ret = pmi_msg.data2;
94
95 pr_debug("PMI returned slow mode %d\n", ret);
96
97#ifdef DEBUG
98 time = (u64) get_cycles() - time; /* actual cycles (not cpu cycles!) */
99 time = 1000000000 * time / CLOCK_TICK_RATE; /* time in ns (10^-9) */
100 pr_debug("had to wait %lu ns for a transition\n", time);
101#endif
102 return ret;
103}
104
105
71static int get_pmode(int cpu) 106static int get_pmode(int cpu)
72{ 107{
73 int ret; 108 int ret;
@@ -79,7 +114,7 @@ static int get_pmode(int cpu)
79 return ret; 114 return ret;
80} 115}
81 116
82static int set_pmode(int cpu, unsigned int pmode) 117static int set_pmode_reg(int cpu, unsigned int pmode)
83{ 118{
84 struct cbe_pmd_regs __iomem *pmd_regs; 119 struct cbe_pmd_regs __iomem *pmd_regs;
85 struct cbe_mic_tm_regs __iomem *mic_tm_regs; 120 struct cbe_mic_tm_regs __iomem *mic_tm_regs;
@@ -120,37 +155,71 @@ static int set_pmode(int cpu, unsigned int pmode)
120 return 0; 155 return 0;
121} 156}
122 157
158static int set_pmode(int cpu, unsigned int slow_mode) {
159 if (pmi_dev)
160 return set_pmode_pmi(cpu, slow_mode);
161 else
162 return set_pmode_reg(cpu, slow_mode);
163}
164
165static void cbe_cpufreq_handle_pmi(struct of_device *dev, pmi_message_t pmi_msg)
166{
167 struct cpufreq_policy policy;
168 u8 cpu;
169 u8 cbe_pmode_new;
170
171 BUG_ON(pmi_msg.type != PMI_TYPE_FREQ_CHANGE);
172
173 cpu = cbe_node_to_cpu(pmi_msg.data1);
174 cbe_pmode_new = pmi_msg.data2;
175
176 cpufreq_get_policy(&policy, cpu);
177
178 policy.max = min(policy.max, cbe_freqs[cbe_pmode_new].frequency);
179 policy.min = min(policy.min, policy.max);
180
181 pr_debug("cbe_handle_pmi: new policy.min=%d policy.max=%d\n", policy.min, policy.max);
182 cpufreq_set_policy(&policy);
183}
184
185static struct pmi_handler cbe_pmi_handler = {
186 .type = PMI_TYPE_FREQ_CHANGE,
187 .handle_pmi_message = cbe_cpufreq_handle_pmi,
188};
189
190
123/* 191/*
124 * cpufreq functions 192 * cpufreq functions
125 */ 193 */
126 194
127static int cbe_cpufreq_cpu_init (struct cpufreq_policy *policy) 195static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)
128{ 196{
129 u32 *max_freq; 197 const u32 *max_freqp;
198 u32 max_freq;
130 int i, cur_pmode; 199 int i, cur_pmode;
131 struct device_node *cpu; 200 struct device_node *cpu;
132 201
133 cpu = of_get_cpu_node(policy->cpu, NULL); 202 cpu = of_get_cpu_node(policy->cpu, NULL);
134 203
135 if(!cpu) 204 if (!cpu)
136 return -ENODEV; 205 return -ENODEV;
137 206
138 pr_debug("init cpufreq on CPU %d\n", policy->cpu); 207 pr_debug("init cpufreq on CPU %d\n", policy->cpu);
139 208
140 max_freq = (u32*) get_property(cpu, "clock-frequency", NULL); 209 max_freqp = of_get_property(cpu, "clock-frequency", NULL);
141 210
142 if(!max_freq) 211 if (!max_freqp)
143 return -EINVAL; 212 return -EINVAL;
144 213
145 // we need the freq in kHz 214 /* we need the freq in kHz */
146 *max_freq /= 1000; 215 max_freq = *max_freqp / 1000;
147 216
148 pr_debug("max clock-frequency is at %u kHz\n", *max_freq); 217 pr_debug("max clock-frequency is at %u kHz\n", max_freq);
149 pr_debug("initializing frequency table\n"); 218 pr_debug("initializing frequency table\n");
150 219
151 // initialize frequency table 220 /* initialize frequency table */
152 for (i=0; cbe_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) { 221 for (i=0; cbe_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) {
153 cbe_freqs[i].frequency = *max_freq / cbe_freqs[i].index; 222 cbe_freqs[i].frequency = max_freq / cbe_freqs[i].index;
154 pr_debug("%d: %d\n", i, cbe_freqs[i].frequency); 223 pr_debug("%d: %d\n", i, cbe_freqs[i].frequency);
155 } 224 }
156 225
@@ -167,10 +236,10 @@ static int cbe_cpufreq_cpu_init (struct cpufreq_policy *policy)
167 policy->cpus = cpu_sibling_map[policy->cpu]; 236 policy->cpus = cpu_sibling_map[policy->cpu];
168#endif 237#endif
169 238
170 cpufreq_frequency_table_get_attr (cbe_freqs, policy->cpu); 239 cpufreq_frequency_table_get_attr(cbe_freqs, policy->cpu);
171 240
172 /* this ensures that policy->cpuinfo_min and policy->cpuinfo_max are set correctly */ 241 /* this ensures that policy->cpuinfo_min and policy->cpuinfo_max are set correctly */
173 return cpufreq_frequency_table_cpuinfo (policy, cbe_freqs); 242 return cpufreq_frequency_table_cpuinfo(policy, cbe_freqs);
174} 243}
175 244
176static int cbe_cpufreq_cpu_exit(struct cpufreq_policy *policy) 245static int cbe_cpufreq_cpu_exit(struct cpufreq_policy *policy)
@@ -202,7 +271,7 @@ static int cbe_cpufreq_target(struct cpufreq_policy *policy, unsigned int target
202 freqs.new = cbe_freqs[cbe_pmode_new].frequency; 271 freqs.new = cbe_freqs[cbe_pmode_new].frequency;
203 freqs.cpu = policy->cpu; 272 freqs.cpu = policy->cpu;
204 273
205 mutex_lock (&cbe_switch_mutex); 274 mutex_lock(&cbe_switch_mutex);
206 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 275 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
207 276
208 pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n", 277 pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n",
@@ -233,11 +302,26 @@ static struct cpufreq_driver cbe_cpufreq_driver = {
233 302
234static int __init cbe_cpufreq_init(void) 303static int __init cbe_cpufreq_init(void)
235{ 304{
305 struct device_node *np;
306
307 if (!machine_is(cell))
308 return -ENODEV;
309
310 np = of_find_node_by_type(NULL, "ibm,pmi");
311
312 pmi_dev = of_find_device_by_node(np);
313
314 if (pmi_dev)
315 pmi_register_handler(pmi_dev, &cbe_pmi_handler);
316
236 return cpufreq_register_driver(&cbe_cpufreq_driver); 317 return cpufreq_register_driver(&cbe_cpufreq_driver);
237} 318}
238 319
239static void __exit cbe_cpufreq_exit(void) 320static void __exit cbe_cpufreq_exit(void)
240{ 321{
322 if (pmi_dev)
323 pmi_unregister_handler(pmi_dev, &cbe_pmi_handler);
324
241 cpufreq_unregister_driver(&cbe_cpufreq_driver); 325 cpufreq_unregister_driver(&cbe_cpufreq_driver);
242} 326}
243 327
diff --git a/arch/powerpc/platforms/cell/cbe_regs.c b/arch/powerpc/platforms/cell/cbe_regs.c
index 9a0ee62691d5..12c9674b4b1f 100644
--- a/arch/powerpc/platforms/cell/cbe_regs.c
+++ b/arch/powerpc/platforms/cell/cbe_regs.c
@@ -14,6 +14,8 @@
14#include <asm/pgtable.h> 14#include <asm/pgtable.h>
15#include <asm/prom.h> 15#include <asm/prom.h>
16#include <asm/ptrace.h> 16#include <asm/ptrace.h>
17#include <asm/of_device.h>
18#include <asm/of_platform.h>
17 19
18#include "cbe_regs.h" 20#include "cbe_regs.h"
19 21
@@ -27,6 +29,7 @@
27static struct cbe_regs_map 29static struct cbe_regs_map
28{ 30{
29 struct device_node *cpu_node; 31 struct device_node *cpu_node;
32 struct device_node *be_node;
30 struct cbe_pmd_regs __iomem *pmd_regs; 33 struct cbe_pmd_regs __iomem *pmd_regs;
31 struct cbe_iic_regs __iomem *iic_regs; 34 struct cbe_iic_regs __iomem *iic_regs;
32 struct cbe_mic_tm_regs __iomem *mic_tm_regs; 35 struct cbe_mic_tm_regs __iomem *mic_tm_regs;
@@ -37,30 +40,43 @@ static int cbe_regs_map_count;
37static struct cbe_thread_map 40static struct cbe_thread_map
38{ 41{
39 struct device_node *cpu_node; 42 struct device_node *cpu_node;
43 struct device_node *be_node;
40 struct cbe_regs_map *regs; 44 struct cbe_regs_map *regs;
45 unsigned int thread_id;
46 unsigned int cbe_id;
41} cbe_thread_map[NR_CPUS]; 47} cbe_thread_map[NR_CPUS];
42 48
49static cpumask_t cbe_local_mask[MAX_CBE] = { [0 ... MAX_CBE-1] = CPU_MASK_NONE };
50static cpumask_t cbe_first_online_cpu = CPU_MASK_NONE;
51
43static struct cbe_regs_map *cbe_find_map(struct device_node *np) 52static struct cbe_regs_map *cbe_find_map(struct device_node *np)
44{ 53{
45 int i; 54 int i;
46 struct device_node *tmp_np; 55 struct device_node *tmp_np;
47 56
48 if (strcasecmp(np->type, "spe") == 0) { 57 if (strcasecmp(np->type, "spe")) {
49 if (np->data == NULL) { 58 for (i = 0; i < cbe_regs_map_count; i++)
50 /* walk up path until cpu node was found */ 59 if (cbe_regs_maps[i].cpu_node == np ||
51 tmp_np = np->parent; 60 cbe_regs_maps[i].be_node == np)
52 while (tmp_np != NULL && strcasecmp(tmp_np->type, "cpu") != 0) 61 return &cbe_regs_maps[i];
53 tmp_np = tmp_np->parent; 62 return NULL;
63 }
54 64
55 np->data = cbe_find_map(tmp_np); 65 if (np->data)
56 }
57 return np->data; 66 return np->data;
58 }
59 67
60 for (i = 0; i < cbe_regs_map_count; i++) 68 /* walk up path until cpu or be node was found */
61 if (cbe_regs_maps[i].cpu_node == np) 69 tmp_np = np;
62 return &cbe_regs_maps[i]; 70 do {
63 return NULL; 71 tmp_np = tmp_np->parent;
72 /* on a correct devicetree we wont get up to root */
73 BUG_ON(!tmp_np);
74 } while (strcasecmp(tmp_np->type, "cpu") &&
75 strcasecmp(tmp_np->type, "be"));
76
77 np->data = cbe_find_map(tmp_np);
78
79 return np->data;
64} 80}
65 81
66struct cbe_pmd_regs __iomem *cbe_get_pmd_regs(struct device_node *np) 82struct cbe_pmd_regs __iomem *cbe_get_pmd_regs(struct device_node *np)
@@ -130,38 +146,105 @@ struct cbe_mic_tm_regs __iomem *cbe_get_cpu_mic_tm_regs(int cpu)
130} 146}
131EXPORT_SYMBOL_GPL(cbe_get_cpu_mic_tm_regs); 147EXPORT_SYMBOL_GPL(cbe_get_cpu_mic_tm_regs);
132 148
133/* FIXME
134 * This is little more than a stub at the moment. It should be
135 * fleshed out so that it works for both SMT and non-SMT, no
136 * matter if the passed cpu is odd or even.
137 * For SMT enabled, returns 0 for even-numbered cpu; otherwise 1.
138 * For SMT disabled, returns 0 for all cpus.
139 */
140u32 cbe_get_hw_thread_id(int cpu) 149u32 cbe_get_hw_thread_id(int cpu)
141{ 150{
142 return (cpu & 1); 151 return cbe_thread_map[cpu].thread_id;
143} 152}
144EXPORT_SYMBOL_GPL(cbe_get_hw_thread_id); 153EXPORT_SYMBOL_GPL(cbe_get_hw_thread_id);
145 154
146void __init cbe_regs_init(void) 155u32 cbe_cpu_to_node(int cpu)
147{ 156{
148 int i; 157 return cbe_thread_map[cpu].cbe_id;
149 struct device_node *cpu; 158}
159EXPORT_SYMBOL_GPL(cbe_cpu_to_node);
150 160
151 /* Build local fast map of CPUs */ 161u32 cbe_node_to_cpu(int node)
152 for_each_possible_cpu(i) 162{
153 cbe_thread_map[i].cpu_node = of_get_cpu_node(i, NULL); 163 return find_first_bit( (unsigned long *) &cbe_local_mask[node], sizeof(cpumask_t));
164}
165EXPORT_SYMBOL_GPL(cbe_node_to_cpu);
154 166
155 /* Find maps for each device tree CPU */ 167static struct device_node *cbe_get_be_node(int cpu_id)
156 for_each_node_by_type(cpu, "cpu") { 168{
157 struct cbe_regs_map *map = &cbe_regs_maps[cbe_regs_map_count++]; 169 struct device_node *np;
170
171 for_each_node_by_type (np, "be") {
172 int len,i;
173 const phandle *cpu_handle;
174
175 cpu_handle = of_get_property(np, "cpus", &len);
176
177 for (i=0; i<len; i++)
178 if (of_find_node_by_phandle(cpu_handle[i]) == of_get_cpu_node(cpu_id, NULL))
179 return np;
180 }
181
182 return NULL;
183}
184
185void __init cbe_fill_regs_map(struct cbe_regs_map *map)
186{
187 if(map->be_node) {
188 struct device_node *be, *np;
189
190 be = map->be_node;
191
192 for_each_node_by_type(np, "pervasive")
193 if (of_get_parent(np) == be)
194 map->pmd_regs = of_iomap(np, 0);
195
196 for_each_node_by_type(np, "CBEA-Internal-Interrupt-Controller")
197 if (of_get_parent(np) == be)
198 map->iic_regs = of_iomap(np, 2);
158 199
200 for_each_node_by_type(np, "mic-tm")
201 if (of_get_parent(np) == be)
202 map->mic_tm_regs = of_iomap(np, 0);
203 } else {
204 struct device_node *cpu;
159 /* That hack must die die die ! */ 205 /* That hack must die die die ! */
160 const struct address_prop { 206 const struct address_prop {
161 unsigned long address; 207 unsigned long address;
162 unsigned int len; 208 unsigned int len;
163 } __attribute__((packed)) *prop; 209 } __attribute__((packed)) *prop;
164 210
211 cpu = map->cpu_node;
212
213 prop = of_get_property(cpu, "pervasive", NULL);
214 if (prop != NULL)
215 map->pmd_regs = ioremap(prop->address, prop->len);
216
217 prop = of_get_property(cpu, "iic", NULL);
218 if (prop != NULL)
219 map->iic_regs = ioremap(prop->address, prop->len);
220
221 prop = of_get_property(cpu, "mic-tm", NULL);
222 if (prop != NULL)
223 map->mic_tm_regs = ioremap(prop->address, prop->len);
224 }
225}
226
227
228void __init cbe_regs_init(void)
229{
230 int i;
231 unsigned int thread_id;
232 struct device_node *cpu;
233
234 /* Build local fast map of CPUs */
235 for_each_possible_cpu(i) {
236 cbe_thread_map[i].cpu_node = of_get_cpu_node(i, &thread_id);
237 cbe_thread_map[i].be_node = cbe_get_be_node(i);
238 cbe_thread_map[i].thread_id = thread_id;
239 }
240
241 /* Find maps for each device tree CPU */
242 for_each_node_by_type(cpu, "cpu") {
243 struct cbe_regs_map *map;
244 unsigned int cbe_id;
245
246 cbe_id = cbe_regs_map_count++;
247 map = &cbe_regs_maps[cbe_id];
165 248
166 if (cbe_regs_map_count > MAX_CBE) { 249 if (cbe_regs_map_count > MAX_CBE) {
167 printk(KERN_ERR "cbe_regs: More BE chips than supported" 250 printk(KERN_ERR "cbe_regs: More BE chips than supported"
@@ -170,22 +253,21 @@ void __init cbe_regs_init(void)
170 return; 253 return;
171 } 254 }
172 map->cpu_node = cpu; 255 map->cpu_node = cpu;
173 for_each_possible_cpu(i)
174 if (cbe_thread_map[i].cpu_node == cpu)
175 cbe_thread_map[i].regs = map;
176 256
177 prop = get_property(cpu, "pervasive", NULL); 257 for_each_possible_cpu(i) {
178 if (prop != NULL) 258 struct cbe_thread_map *thread = &cbe_thread_map[i];
179 map->pmd_regs = ioremap(prop->address, prop->len);
180 259
181 prop = get_property(cpu, "iic", NULL); 260 if (thread->cpu_node == cpu) {
182 if (prop != NULL) 261 thread->regs = map;
183 map->iic_regs = ioremap(prop->address, prop->len); 262 thread->cbe_id = cbe_id;
263 map->be_node = thread->be_node;
264 cpu_set(i, cbe_local_mask[cbe_id]);
265 if(thread->thread_id == 0)
266 cpu_set(i, cbe_first_online_cpu);
267 }
268 }
184 269
185 prop = (struct address_prop *)get_property(cpu, "mic-tm", 270 cbe_fill_regs_map(map);
186 NULL);
187 if (prop != NULL)
188 map->mic_tm_regs = ioremap(prop->address, prop->len);
189 } 271 }
190} 272}
191 273
diff --git a/arch/powerpc/platforms/cell/cbe_regs.h b/arch/powerpc/platforms/cell/cbe_regs.h
index 440a7ecc66ea..17d597144877 100644
--- a/arch/powerpc/platforms/cell/cbe_regs.h
+++ b/arch/powerpc/platforms/cell/cbe_regs.h
@@ -255,6 +255,11 @@ struct cbe_mic_tm_regs {
255extern struct cbe_mic_tm_regs __iomem *cbe_get_mic_tm_regs(struct device_node *np); 255extern struct cbe_mic_tm_regs __iomem *cbe_get_mic_tm_regs(struct device_node *np);
256extern struct cbe_mic_tm_regs __iomem *cbe_get_cpu_mic_tm_regs(int cpu); 256extern struct cbe_mic_tm_regs __iomem *cbe_get_cpu_mic_tm_regs(int cpu);
257 257
258/* some utility functions to deal with SMT */
259extern u32 cbe_get_hw_thread_id(int cpu);
260extern u32 cbe_cpu_to_node(int cpu);
261extern u32 cbe_node_to_cpu(int node);
262
258/* Init this module early */ 263/* Init this module early */
259extern void cbe_regs_init(void); 264extern void cbe_regs_init(void);
260 265
diff --git a/arch/powerpc/platforms/cell/cbe_thermal.c b/arch/powerpc/platforms/cell/cbe_thermal.c
index 70e0d968d30f..f370f0fa6f4c 100644
--- a/arch/powerpc/platforms/cell/cbe_thermal.c
+++ b/arch/powerpc/platforms/cell/cbe_thermal.c
@@ -1,6 +1,31 @@
1/* 1/*
2 * thermal support for the cell processor 2 * thermal support for the cell processor
3 * 3 *
4 * This module adds some sysfs attributes to cpu and spu nodes.
5 * Base for measurements are the digital thermal sensors (DTS)
6 * located on the chip.
7 * The accuracy is 2 degrees, starting from 65 up to 125 degrees celsius
8 * The attributes can be found under
9 * /sys/devices/system/cpu/cpuX/thermal
10 * /sys/devices/system/spu/spuX/thermal
11 *
12 * The following attributes are added for each node:
13 * temperature:
14 * contains the current temperature measured by the DTS
15 * throttle_begin:
16 * throttling begins when temperature is greater or equal to
17 * throttle_begin. Setting this value to 125 prevents throttling.
18 * throttle_end:
19 * throttling is being ceased, if the temperature is lower than
20 * throttle_end. Due to a delay between applying throttling and
21 * a reduced temperature this value should be less than throttle_begin.
22 * A value equal to throttle_begin provides only a very little hysteresis.
23 * throttle_full_stop:
24 * If the temperatrue is greater or equal to throttle_full_stop,
25 * full throttling is applied to the cpu or spu. This value should be
26 * greater than throttle_begin and throttle_end. Setting this value to
27 * 65 prevents the unit from running code at all.
28 *
4 * (C) Copyright IBM Deutschland Entwicklung GmbH 2005 29 * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
5 * 30 *
6 * Author: Christian Krafft <krafft@de.ibm.com> 31 * Author: Christian Krafft <krafft@de.ibm.com>
@@ -31,6 +56,26 @@
31#include "cbe_regs.h" 56#include "cbe_regs.h"
32#include "spu_priv1_mmio.h" 57#include "spu_priv1_mmio.h"
33 58
59#define TEMP_MIN 65
60#define TEMP_MAX 125
61
62#define SYSDEV_PREFIX_ATTR(_prefix,_name,_mode) \
63struct sysdev_attribute attr_ ## _prefix ## _ ## _name = { \
64 .attr = { .name = __stringify(_name), .mode = _mode }, \
65 .show = _prefix ## _show_ ## _name, \
66 .store = _prefix ## _store_ ## _name, \
67};
68
69static inline u8 reg_to_temp(u8 reg_value)
70{
71 return ((reg_value & 0x3f) << 1) + TEMP_MIN;
72}
73
74static inline u8 temp_to_reg(u8 temp)
75{
76 return ((temp - TEMP_MIN) >> 1) & 0x3f;
77}
78
34static struct cbe_pmd_regs __iomem *get_pmd_regs(struct sys_device *sysdev) 79static struct cbe_pmd_regs __iomem *get_pmd_regs(struct sys_device *sysdev)
35{ 80{
36 struct spu *spu; 81 struct spu *spu;
@@ -43,14 +88,14 @@ static struct cbe_pmd_regs __iomem *get_pmd_regs(struct sys_device *sysdev)
43/* returns the value for a given spu in a given register */ 88/* returns the value for a given spu in a given register */
44static u8 spu_read_register_value(struct sys_device *sysdev, union spe_reg __iomem *reg) 89static u8 spu_read_register_value(struct sys_device *sysdev, union spe_reg __iomem *reg)
45{ 90{
46 unsigned int *id; 91 const unsigned int *id;
47 union spe_reg value; 92 union spe_reg value;
48 struct spu *spu; 93 struct spu *spu;
49 94
50 /* getting the id from the reg attribute will not work on future device-tree layouts 95 /* getting the id from the reg attribute will not work on future device-tree layouts
51 * in future we should store the id to the spu struct and use it here */ 96 * in future we should store the id to the spu struct and use it here */
52 spu = container_of(sysdev, struct spu, sysdev); 97 spu = container_of(sysdev, struct spu, sysdev);
53 id = (unsigned int *)get_property(spu_devnode(spu), "reg", NULL); 98 id = of_get_property(spu_devnode(spu), "reg", NULL);
54 value.val = in_be64(&reg->val); 99 value.val = in_be64(&reg->val);
55 100
56 return value.spe[*id]; 101 return value.spe[*id];
@@ -58,20 +103,81 @@ static u8 spu_read_register_value(struct sys_device *sysdev, union spe_reg __iom
58 103
59static ssize_t spu_show_temp(struct sys_device *sysdev, char *buf) 104static ssize_t spu_show_temp(struct sys_device *sysdev, char *buf)
60{ 105{
61 int value; 106 u8 value;
62 struct cbe_pmd_regs __iomem *pmd_regs; 107 struct cbe_pmd_regs __iomem *pmd_regs;
63 108
64 pmd_regs = get_pmd_regs(sysdev); 109 pmd_regs = get_pmd_regs(sysdev);
65 110
66 value = spu_read_register_value(sysdev, &pmd_regs->ts_ctsr1); 111 value = spu_read_register_value(sysdev, &pmd_regs->ts_ctsr1);
67 /* clear all other bits */ 112
113 return sprintf(buf, "%d\n", reg_to_temp(value));
114}
115
116static ssize_t show_throttle(struct cbe_pmd_regs __iomem *pmd_regs, char *buf, int pos)
117{
118 u64 value;
119
120 value = in_be64(&pmd_regs->tm_tpr.val);
121 /* access the corresponding byte */
122 value >>= pos;
68 value &= 0x3F; 123 value &= 0x3F;
69 /* temp is stored in steps of 2 degrees */
70 value *= 2;
71 /* base temp is 65 degrees */
72 value += 65;
73 124
74 return sprintf(buf, "%d\n", (int) value); 125 return sprintf(buf, "%d\n", reg_to_temp(value));
126}
127
128static ssize_t store_throttle(struct cbe_pmd_regs __iomem *pmd_regs, const char *buf, size_t size, int pos)
129{
130 u64 reg_value;
131 int temp;
132 u64 new_value;
133 int ret;
134
135 ret = sscanf(buf, "%u", &temp);
136
137 if (ret != 1 || temp < TEMP_MIN || temp > TEMP_MAX)
138 return -EINVAL;
139
140 new_value = temp_to_reg(temp);
141
142 reg_value = in_be64(&pmd_regs->tm_tpr.val);
143
144 /* zero out bits for new value */
145 reg_value &= ~(0xffull << pos);
146 /* set bits to new value */
147 reg_value |= new_value << pos;
148
149 out_be64(&pmd_regs->tm_tpr.val, reg_value);
150 return size;
151}
152
153static ssize_t spu_show_throttle_end(struct sys_device *sysdev, char *buf)
154{
155 return show_throttle(get_pmd_regs(sysdev), buf, 0);
156}
157
158static ssize_t spu_show_throttle_begin(struct sys_device *sysdev, char *buf)
159{
160 return show_throttle(get_pmd_regs(sysdev), buf, 8);
161}
162
163static ssize_t spu_show_throttle_full_stop(struct sys_device *sysdev, char *buf)
164{
165 return show_throttle(get_pmd_regs(sysdev), buf, 16);
166}
167
168static ssize_t spu_store_throttle_end(struct sys_device *sysdev, const char *buf, size_t size)
169{
170 return store_throttle(get_pmd_regs(sysdev), buf, size, 0);
171}
172
173static ssize_t spu_store_throttle_begin(struct sys_device *sysdev, const char *buf, size_t size)
174{
175 return store_throttle(get_pmd_regs(sysdev), buf, size, 8);
176}
177
178static ssize_t spu_store_throttle_full_stop(struct sys_device *sysdev, const char *buf, size_t size)
179{
180 return store_throttle(get_pmd_regs(sysdev), buf, size, 16);
75} 181}
76 182
77static ssize_t ppe_show_temp(struct sys_device *sysdev, char *buf, int pos) 183static ssize_t ppe_show_temp(struct sys_device *sysdev, char *buf, int pos)
@@ -82,16 +188,9 @@ static ssize_t ppe_show_temp(struct sys_device *sysdev, char *buf, int pos)
82 pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id); 188 pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id);
83 value = in_be64(&pmd_regs->ts_ctsr2); 189 value = in_be64(&pmd_regs->ts_ctsr2);
84 190
85 /* access the corresponding byte */ 191 value = (value >> pos) & 0x3f;
86 value >>= pos;
87 /* clear all other bits */
88 value &= 0x3F;
89 /* temp is stored in steps of 2 degrees */
90 value *= 2;
91 /* base temp is 65 degrees */
92 value += 65;
93 192
94 return sprintf(buf, "%d\n", (int) value); 193 return sprintf(buf, "%d\n", reg_to_temp(value));
95} 194}
96 195
97 196
@@ -108,13 +207,52 @@ static ssize_t ppe_show_temp1(struct sys_device *sysdev, char *buf)
108 return ppe_show_temp(sysdev, buf, 0); 207 return ppe_show_temp(sysdev, buf, 0);
109} 208}
110 209
210static ssize_t ppe_show_throttle_end(struct sys_device *sysdev, char *buf)
211{
212 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 32);
213}
214
215static ssize_t ppe_show_throttle_begin(struct sys_device *sysdev, char *buf)
216{
217 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 40);
218}
219
220static ssize_t ppe_show_throttle_full_stop(struct sys_device *sysdev, char *buf)
221{
222 return show_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, 48);
223}
224
225static ssize_t ppe_store_throttle_end(struct sys_device *sysdev, const char *buf, size_t size)
226{
227 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 32);
228}
229
230static ssize_t ppe_store_throttle_begin(struct sys_device *sysdev, const char *buf, size_t size)
231{
232 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 40);
233}
234
235static ssize_t ppe_store_throttle_full_stop(struct sys_device *sysdev, const char *buf, size_t size)
236{
237 return store_throttle(cbe_get_cpu_pmd_regs(sysdev->id), buf, size, 48);
238}
239
240
111static struct sysdev_attribute attr_spu_temperature = { 241static struct sysdev_attribute attr_spu_temperature = {
112 .attr = {.name = "temperature", .mode = 0400 }, 242 .attr = {.name = "temperature", .mode = 0400 },
113 .show = spu_show_temp, 243 .show = spu_show_temp,
114}; 244};
115 245
246static SYSDEV_PREFIX_ATTR(spu, throttle_end, 0600);
247static SYSDEV_PREFIX_ATTR(spu, throttle_begin, 0600);
248static SYSDEV_PREFIX_ATTR(spu, throttle_full_stop, 0600);
249
250
116static struct attribute *spu_attributes[] = { 251static struct attribute *spu_attributes[] = {
117 &attr_spu_temperature.attr, 252 &attr_spu_temperature.attr,
253 &attr_spu_throttle_end.attr,
254 &attr_spu_throttle_begin.attr,
255 &attr_spu_throttle_full_stop.attr,
118 NULL, 256 NULL,
119}; 257};
120 258
@@ -133,9 +271,16 @@ static struct sysdev_attribute attr_ppe_temperature1 = {
133 .show = ppe_show_temp1, 271 .show = ppe_show_temp1,
134}; 272};
135 273
274static SYSDEV_PREFIX_ATTR(ppe, throttle_end, 0600);
275static SYSDEV_PREFIX_ATTR(ppe, throttle_begin, 0600);
276static SYSDEV_PREFIX_ATTR(ppe, throttle_full_stop, 0600);
277
136static struct attribute *ppe_attributes[] = { 278static struct attribute *ppe_attributes[] = {
137 &attr_ppe_temperature0.attr, 279 &attr_ppe_temperature0.attr,
138 &attr_ppe_temperature1.attr, 280 &attr_ppe_temperature1.attr,
281 &attr_ppe_throttle_end.attr,
282 &attr_ppe_throttle_begin.attr,
283 &attr_ppe_throttle_full_stop.attr,
139 NULL, 284 NULL,
140}; 285};
141 286
diff --git a/arch/powerpc/platforms/cell/interrupt.c b/arch/powerpc/platforms/cell/interrupt.c
index 6666d037eb44..4fc4e92775d0 100644
--- a/arch/powerpc/platforms/cell/interrupt.c
+++ b/arch/powerpc/platforms/cell/interrupt.c
@@ -261,7 +261,7 @@ static int iic_host_xlate(struct irq_host *h, struct device_node *ct,
261 return -ENODEV; 261 return -ENODEV;
262 if (intsize != 1) 262 if (intsize != 1)
263 return -ENODEV; 263 return -ENODEV;
264 val = get_property(ct, "#interrupt-cells", NULL); 264 val = of_get_property(ct, "#interrupt-cells", NULL);
265 if (val == NULL || *val != 1) 265 if (val == NULL || *val != 1)
266 return -ENODEV; 266 return -ENODEV;
267 267
@@ -327,7 +327,7 @@ static int __init setup_iic(void)
327 if (!device_is_compatible(dn, 327 if (!device_is_compatible(dn,
328 "IBM,CBEA-Internal-Interrupt-Controller")) 328 "IBM,CBEA-Internal-Interrupt-Controller"))
329 continue; 329 continue;
330 np = get_property(dn, "ibm,interrupt-server-ranges", NULL); 330 np = of_get_property(dn, "ibm,interrupt-server-ranges", NULL);
331 if (np == NULL) { 331 if (np == NULL) {
332 printk(KERN_WARNING "IIC: CPU association not found\n"); 332 printk(KERN_WARNING "IIC: CPU association not found\n");
333 of_node_put(dn); 333 of_node_put(dn);
diff --git a/arch/powerpc/platforms/cell/io-workarounds.c b/arch/powerpc/platforms/cell/io-workarounds.c
index 7c73128305ec..d68d920eb2c4 100644
--- a/arch/powerpc/platforms/cell/io-workarounds.c
+++ b/arch/powerpc/platforms/cell/io-workarounds.c
@@ -318,7 +318,7 @@ static int __init spider_pci_workaround_init(void)
318 */ 318 */
319 list_for_each_entry(phb, &hose_list, list_node) { 319 list_for_each_entry(phb, &hose_list, list_node) {
320 struct device_node *np = phb->arch_data; 320 struct device_node *np = phb->arch_data;
321 const char *model = get_property(np, "model", NULL); 321 const char *model = of_get_property(np, "model", NULL);
322 322
323 /* If no model property or name isn't exactly "pci", skip */ 323 /* If no model property or name isn't exactly "pci", skip */
324 if (model == NULL || strcmp(np->name, "pci")) 324 if (model == NULL || strcmp(np->name, "pci"))
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index 67d617b60a23..760caa76841a 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -291,9 +291,9 @@ static int cell_iommu_find_ioc(int nid, unsigned long *base)
291 const unsigned int *nidp; 291 const unsigned int *nidp;
292 const unsigned long *tmp; 292 const unsigned long *tmp;
293 293
294 nidp = get_property(np, "node-id", NULL); 294 nidp = of_get_property(np, "node-id", NULL);
295 if (nidp && *nidp == nid) { 295 if (nidp && *nidp == nid) {
296 tmp = get_property(np, "ioc-translation", NULL); 296 tmp = of_get_property(np, "ioc-translation", NULL);
297 if (tmp) { 297 if (tmp) {
298 *base = *tmp; 298 *base = *tmp;
299 of_node_put(np); 299 of_node_put(np);
@@ -430,7 +430,7 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np,
430 struct iommu_window *window; 430 struct iommu_window *window;
431 const unsigned int *ioid; 431 const unsigned int *ioid;
432 432
433 ioid = get_property(np, "ioid", NULL); 433 ioid = of_get_property(np, "ioid", NULL);
434 if (ioid == NULL) 434 if (ioid == NULL)
435 printk(KERN_WARNING "iommu: missing ioid for %s using 0\n", 435 printk(KERN_WARNING "iommu: missing ioid for %s using 0\n",
436 np->full_name); 436 np->full_name);
@@ -496,7 +496,7 @@ static void cell_dma_dev_setup(struct device *dev)
496 struct dev_archdata *archdata = &dev->archdata; 496 struct dev_archdata *archdata = &dev->archdata;
497 497
498 /* If we run without iommu, no need to do anything */ 498 /* If we run without iommu, no need to do anything */
499 if (pci_dma_ops == &dma_direct_ops) 499 if (get_pci_dma_ops() == &dma_direct_ops)
500 return; 500 return;
501 501
502 /* Current implementation uses the first window available in that 502 /* Current implementation uses the first window available in that
@@ -530,7 +530,7 @@ static int cell_of_bus_notify(struct notifier_block *nb, unsigned long action,
530 return 0; 530 return 0;
531 531
532 /* We use the PCI DMA ops */ 532 /* We use the PCI DMA ops */
533 dev->archdata.dma_ops = pci_dma_ops; 533 dev->archdata.dma_ops = get_pci_dma_ops();
534 534
535 cell_dma_dev_setup(dev); 535 cell_dma_dev_setup(dev);
536 536
@@ -549,7 +549,7 @@ static int __init cell_iommu_get_window(struct device_node *np,
549 unsigned long index; 549 unsigned long index;
550 550
551 /* Use ibm,dma-window if available, else, hard code ! */ 551 /* Use ibm,dma-window if available, else, hard code ! */
552 dma_window = get_property(np, "ibm,dma-window", NULL); 552 dma_window = of_get_property(np, "ibm,dma-window", NULL);
553 if (dma_window == NULL) { 553 if (dma_window == NULL) {
554 *base = 0; 554 *base = 0;
555 *size = 0x80000000u; 555 *size = 0x80000000u;
@@ -646,7 +646,7 @@ static int __init cell_iommu_init_disabled(void)
646 unsigned long base = 0, size; 646 unsigned long base = 0, size;
647 647
648 /* When no iommu is present, we use direct DMA ops */ 648 /* When no iommu is present, we use direct DMA ops */
649 pci_dma_ops = &dma_direct_ops; 649 set_pci_dma_ops(&dma_direct_ops);
650 650
651 /* First make sure all IOC translation is turned off */ 651 /* First make sure all IOC translation is turned off */
652 cell_disable_iommus(); 652 cell_disable_iommus();
@@ -734,7 +734,7 @@ static int __init cell_iommu_init(void)
734 } 734 }
735 735
736 /* Setup default PCI iommu ops */ 736 /* Setup default PCI iommu ops */
737 pci_dma_ops = &dma_iommu_ops; 737 set_pci_dma_ops(&dma_iommu_ops);
738 738
739 bail: 739 bail:
740 /* Register callbacks on OF platform device addition/removal 740 /* Register callbacks on OF platform device addition/removal
diff --git a/arch/powerpc/platforms/cell/ras.c b/arch/powerpc/platforms/cell/ras.c
index 0984c7071695..3961a085b432 100644
--- a/arch/powerpc/platforms/cell/ras.c
+++ b/arch/powerpc/platforms/cell/ras.c
@@ -3,11 +3,13 @@
3#include <linux/types.h> 3#include <linux/types.h>
4#include <linux/kernel.h> 4#include <linux/kernel.h>
5#include <linux/smp.h> 5#include <linux/smp.h>
6#include <linux/reboot.h>
6 7
7#include <asm/reg.h> 8#include <asm/reg.h>
8#include <asm/io.h> 9#include <asm/io.h>
9#include <asm/prom.h> 10#include <asm/prom.h>
10#include <asm/machdep.h> 11#include <asm/machdep.h>
12#include <asm/rtas.h>
11 13
12#include "ras.h" 14#include "ras.h"
13#include "cbe_regs.h" 15#include "cbe_regs.h"
@@ -82,6 +84,164 @@ static int cbe_machine_check_handler(struct pt_regs *regs)
82 return 0; 84 return 0;
83} 85}
84 86
87struct ptcal_area {
88 struct list_head list;
89 int nid;
90 int order;
91 struct page *pages;
92};
93
94static LIST_HEAD(ptcal_list);
95
96static int ptcal_start_tok, ptcal_stop_tok;
97
98static int __init cbe_ptcal_enable_on_node(int nid, int order)
99{
100 struct ptcal_area *area;
101 int ret = -ENOMEM;
102 unsigned long addr;
103
104#ifdef CONFIG_CRASH_DUMP
105 rtas_call(ptcal_stop_tok, 1, 1, NULL, nid);
106#endif
107
108 area = kmalloc(sizeof(*area), GFP_KERNEL);
109 if (!area)
110 goto out_err;
111
112 area->nid = nid;
113 area->order = order;
114 area->pages = alloc_pages_node(area->nid, GFP_KERNEL, area->order);
115
116 if (!area->pages)
117 goto out_free_area;
118
119 addr = __pa(page_address(area->pages));
120
121 ret = -EIO;
122 if (rtas_call(ptcal_start_tok, 3, 1, NULL, area->nid,
123 (unsigned int)(addr >> 32),
124 (unsigned int)(addr & 0xffffffff))) {
125 printk(KERN_ERR "%s: error enabling PTCAL on node %d!\n",
126 __FUNCTION__, nid);
127 goto out_free_pages;
128 }
129
130 list_add(&area->list, &ptcal_list);
131
132 return 0;
133
134out_free_pages:
135 __free_pages(area->pages, area->order);
136out_free_area:
137 kfree(area);
138out_err:
139 return ret;
140}
141
142static int __init cbe_ptcal_enable(void)
143{
144 const u32 *size;
145 struct device_node *np;
146 int order, found_mic = 0;
147
148 np = of_find_node_by_path("/rtas");
149 if (!np)
150 return -ENODEV;
151
152 size = of_get_property(np, "ibm,cbe-ptcal-size", NULL);
153 if (!size)
154 return -ENODEV;
155
156 pr_debug("%s: enabling PTCAL, size = 0x%x\n", __FUNCTION__, *size);
157 order = get_order(*size);
158 of_node_put(np);
159
160 /* support for malta device trees, with be@/mic@ nodes */
161 for_each_node_by_type(np, "mic-tm") {
162 cbe_ptcal_enable_on_node(of_node_to_nid(np), order);
163 found_mic = 1;
164 }
165
166 if (found_mic)
167 return 0;
168
169 /* support for older device tree - use cpu nodes */
170 for_each_node_by_type(np, "cpu") {
171 const u32 *nid = of_get_property(np, "node-id", NULL);
172 if (!nid) {
173 printk(KERN_ERR "%s: node %s is missing node-id?\n",
174 __FUNCTION__, np->full_name);
175 continue;
176 }
177 cbe_ptcal_enable_on_node(*nid, order);
178 found_mic = 1;
179 }
180
181 return found_mic ? 0 : -ENODEV;
182}
183
184static int cbe_ptcal_disable(void)
185{
186 struct ptcal_area *area, *tmp;
187 int ret = 0;
188
189 pr_debug("%s: disabling PTCAL\n", __FUNCTION__);
190
191 list_for_each_entry_safe(area, tmp, &ptcal_list, list) {
192 /* disable ptcal on this node */
193 if (rtas_call(ptcal_stop_tok, 1, 1, NULL, area->nid)) {
194 printk(KERN_ERR "%s: error disabling PTCAL "
195 "on node %d!\n", __FUNCTION__,
196 area->nid);
197 ret = -EIO;
198 continue;
199 }
200
201 /* ensure we can access the PTCAL area */
202 memset(page_address(area->pages), 0,
203 1 << (area->order + PAGE_SHIFT));
204
205 /* clean up */
206 list_del(&area->list);
207 __free_pages(area->pages, area->order);
208 kfree(area);
209 }
210
211 return ret;
212}
213
214static int cbe_ptcal_notify_reboot(struct notifier_block *nb,
215 unsigned long code, void *data)
216{
217 return cbe_ptcal_disable();
218}
219
220static struct notifier_block cbe_ptcal_reboot_notifier = {
221 .notifier_call = cbe_ptcal_notify_reboot
222};
223
224int __init cbe_ptcal_init(void)
225{
226 int ret;
227 ptcal_start_tok = rtas_token("ibm,cbe-start-ptcal");
228 ptcal_stop_tok = rtas_token("ibm,cbe-stop-ptcal");
229
230 if (ptcal_start_tok == RTAS_UNKNOWN_SERVICE
231 || ptcal_stop_tok == RTAS_UNKNOWN_SERVICE)
232 return -ENODEV;
233
234 ret = register_reboot_notifier(&cbe_ptcal_reboot_notifier);
235 if (ret) {
236 printk(KERN_ERR "Can't disable PTCAL, so not enabling\n");
237 return ret;
238 }
239
240 return cbe_ptcal_enable();
241}
242
243arch_initcall(cbe_ptcal_init);
244
85void __init cbe_ras_init(void) 245void __init cbe_ras_init(void)
86{ 246{
87 unsigned long hid0; 247 unsigned long hid0;
diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c
index 36989c2eee66..54b96183cb64 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -71,7 +71,7 @@ static void cell_show_cpuinfo(struct seq_file *m)
71 71
72 root = of_find_node_by_path("/"); 72 root = of_find_node_by_path("/");
73 if (root) 73 if (root)
74 model = get_property(root, "model", NULL); 74 model = of_get_property(root, "model", NULL);
75 seq_printf(m, "machine\t\t: CHRP %s\n", model); 75 seq_printf(m, "machine\t\t: CHRP %s\n", model);
76 of_node_put(root); 76 of_node_put(root);
77} 77}
@@ -190,15 +190,6 @@ static int __init cell_probe(void)
190 return 1; 190 return 1;
191} 191}
192 192
193/*
194 * Cell has no legacy IO; anything calling this function has to
195 * fail or bad things will happen
196 */
197static int cell_check_legacy_ioport(unsigned int baseport)
198{
199 return -ENODEV;
200}
201
202define_machine(cell) { 193define_machine(cell) {
203 .name = "Cell", 194 .name = "Cell",
204 .probe = cell_probe, 195 .probe = cell_probe,
@@ -211,7 +202,6 @@ define_machine(cell) {
211 .get_rtc_time = rtas_get_rtc_time, 202 .get_rtc_time = rtas_get_rtc_time,
212 .set_rtc_time = rtas_set_rtc_time, 203 .set_rtc_time = rtas_set_rtc_time,
213 .calibrate_decr = generic_calibrate_decr, 204 .calibrate_decr = generic_calibrate_decr,
214 .check_legacy_ioport = cell_check_legacy_ioport,
215 .progress = cell_progress, 205 .progress = cell_progress,
216 .init_IRQ = cell_init_irq, 206 .init_IRQ = cell_init_irq,
217 .pci_setup_phb = rtas_setup_phb, 207 .pci_setup_phb = rtas_setup_phb,
diff --git a/arch/powerpc/platforms/cell/spider-pic.c b/arch/powerpc/platforms/cell/spider-pic.c
index 21a9ebd4978e..fb1f15797bbb 100644
--- a/arch/powerpc/platforms/cell/spider-pic.c
+++ b/arch/powerpc/platforms/cell/spider-pic.c
@@ -254,25 +254,25 @@ static unsigned int __init spider_find_cascade_and_node(struct spider_pic *pic)
254 } 254 }
255 255
256 /* Now do the horrible hacks */ 256 /* Now do the horrible hacks */
257 tmp = get_property(pic->of_node, "#interrupt-cells", NULL); 257 tmp = of_get_property(pic->of_node, "#interrupt-cells", NULL);
258 if (tmp == NULL) 258 if (tmp == NULL)
259 return NO_IRQ; 259 return NO_IRQ;
260 intsize = *tmp; 260 intsize = *tmp;
261 imap = get_property(pic->of_node, "interrupt-map", &imaplen); 261 imap = of_get_property(pic->of_node, "interrupt-map", &imaplen);
262 if (imap == NULL || imaplen < (intsize + 1)) 262 if (imap == NULL || imaplen < (intsize + 1))
263 return NO_IRQ; 263 return NO_IRQ;
264 iic = of_find_node_by_phandle(imap[intsize]); 264 iic = of_find_node_by_phandle(imap[intsize]);
265 if (iic == NULL) 265 if (iic == NULL)
266 return NO_IRQ; 266 return NO_IRQ;
267 imap += intsize + 1; 267 imap += intsize + 1;
268 tmp = get_property(iic, "#interrupt-cells", NULL); 268 tmp = of_get_property(iic, "#interrupt-cells", NULL);
269 if (tmp == NULL) 269 if (tmp == NULL)
270 return NO_IRQ; 270 return NO_IRQ;
271 intsize = *tmp; 271 intsize = *tmp;
272 /* Assume unit is last entry of interrupt specifier */ 272 /* Assume unit is last entry of interrupt specifier */
273 unit = imap[intsize - 1]; 273 unit = imap[intsize - 1];
274 /* Ok, we have a unit, now let's try to get the node */ 274 /* Ok, we have a unit, now let's try to get the node */
275 tmp = get_property(iic, "ibm,interrupt-server-ranges", NULL); 275 tmp = of_get_property(iic, "ibm,interrupt-server-ranges", NULL);
276 if (tmp == NULL) { 276 if (tmp == NULL) {
277 of_node_put(iic); 277 of_node_put(iic);
278 return NO_IRQ; 278 return NO_IRQ;
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index eba7a2641dce..fec51525252e 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -36,12 +36,14 @@
36#include <asm/xmon.h> 36#include <asm/xmon.h>
37 37
38const struct spu_management_ops *spu_management_ops; 38const struct spu_management_ops *spu_management_ops;
39EXPORT_SYMBOL_GPL(spu_management_ops);
40
39const struct spu_priv1_ops *spu_priv1_ops; 41const struct spu_priv1_ops *spu_priv1_ops;
40 42
41static struct list_head spu_list[MAX_NUMNODES]; 43static struct list_head spu_list[MAX_NUMNODES];
42static LIST_HEAD(spu_full_list); 44static LIST_HEAD(spu_full_list);
43static DEFINE_MUTEX(spu_mutex); 45static DEFINE_MUTEX(spu_mutex);
44static spinlock_t spu_list_lock = SPIN_LOCK_UNLOCKED; 46static DEFINE_SPINLOCK(spu_list_lock);
45 47
46EXPORT_SYMBOL_GPL(spu_priv1_ops); 48EXPORT_SYMBOL_GPL(spu_priv1_ops);
47 49
@@ -290,7 +292,6 @@ spu_irq_class_1(int irq, void *data)
290 292
291 return stat ? IRQ_HANDLED : IRQ_NONE; 293 return stat ? IRQ_HANDLED : IRQ_NONE;
292} 294}
293EXPORT_SYMBOL_GPL(spu_irq_class_1_bottom);
294 295
295static irqreturn_t 296static irqreturn_t
296spu_irq_class_2(int irq, void *data) 297spu_irq_class_2(int irq, void *data)
@@ -431,10 +432,11 @@ struct spu *spu_alloc_node(int node)
431 spu = list_entry(spu_list[node].next, struct spu, list); 432 spu = list_entry(spu_list[node].next, struct spu, list);
432 list_del_init(&spu->list); 433 list_del_init(&spu->list);
433 pr_debug("Got SPU %d %d\n", spu->number, spu->node); 434 pr_debug("Got SPU %d %d\n", spu->number, spu->node);
434 spu_init_channels(spu);
435 } 435 }
436 mutex_unlock(&spu_mutex); 436 mutex_unlock(&spu_mutex);
437 437
438 if (spu)
439 spu_init_channels(spu);
438 return spu; 440 return spu;
439} 441}
440EXPORT_SYMBOL_GPL(spu_alloc_node); 442EXPORT_SYMBOL_GPL(spu_alloc_node);
@@ -461,108 +463,6 @@ void spu_free(struct spu *spu)
461} 463}
462EXPORT_SYMBOL_GPL(spu_free); 464EXPORT_SYMBOL_GPL(spu_free);
463 465
464static int spu_handle_mm_fault(struct spu *spu)
465{
466 struct mm_struct *mm = spu->mm;
467 struct vm_area_struct *vma;
468 u64 ea, dsisr, is_write;
469 int ret;
470
471 ea = spu->dar;
472 dsisr = spu->dsisr;
473#if 0
474 if (!IS_VALID_EA(ea)) {
475 return -EFAULT;
476 }
477#endif /* XXX */
478 if (mm == NULL) {
479 return -EFAULT;
480 }
481 if (mm->pgd == NULL) {
482 return -EFAULT;
483 }
484
485 down_read(&mm->mmap_sem);
486 vma = find_vma(mm, ea);
487 if (!vma)
488 goto bad_area;
489 if (vma->vm_start <= ea)
490 goto good_area;
491 if (!(vma->vm_flags & VM_GROWSDOWN))
492 goto bad_area;
493#if 0
494 if (expand_stack(vma, ea))
495 goto bad_area;
496#endif /* XXX */
497good_area:
498 is_write = dsisr & MFC_DSISR_ACCESS_PUT;
499 if (is_write) {
500 if (!(vma->vm_flags & VM_WRITE))
501 goto bad_area;
502 } else {
503 if (dsisr & MFC_DSISR_ACCESS_DENIED)
504 goto bad_area;
505 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
506 goto bad_area;
507 }
508 ret = 0;
509 switch (handle_mm_fault(mm, vma, ea, is_write)) {
510 case VM_FAULT_MINOR:
511 current->min_flt++;
512 break;
513 case VM_FAULT_MAJOR:
514 current->maj_flt++;
515 break;
516 case VM_FAULT_SIGBUS:
517 ret = -EFAULT;
518 goto bad_area;
519 case VM_FAULT_OOM:
520 ret = -ENOMEM;
521 goto bad_area;
522 default:
523 BUG();
524 }
525 up_read(&mm->mmap_sem);
526 return ret;
527
528bad_area:
529 up_read(&mm->mmap_sem);
530 return -EFAULT;
531}
532
533int spu_irq_class_1_bottom(struct spu *spu)
534{
535 u64 ea, dsisr, access, error = 0UL;
536 int ret = 0;
537
538 ea = spu->dar;
539 dsisr = spu->dsisr;
540 if (dsisr & (MFC_DSISR_PTE_NOT_FOUND | MFC_DSISR_ACCESS_DENIED)) {
541 u64 flags;
542
543 access = (_PAGE_PRESENT | _PAGE_USER);
544 access |= (dsisr & MFC_DSISR_ACCESS_PUT) ? _PAGE_RW : 0UL;
545 local_irq_save(flags);
546 if (hash_page(ea, access, 0x300) != 0)
547 error |= CLASS1_ENABLE_STORAGE_FAULT_INTR;
548 local_irq_restore(flags);
549 }
550 if (error & CLASS1_ENABLE_STORAGE_FAULT_INTR) {
551 if ((ret = spu_handle_mm_fault(spu)) != 0)
552 error |= CLASS1_ENABLE_STORAGE_FAULT_INTR;
553 else
554 error &= ~CLASS1_ENABLE_STORAGE_FAULT_INTR;
555 }
556 spu->dar = 0UL;
557 spu->dsisr = 0UL;
558 if (!error) {
559 spu_restart_dma(spu);
560 } else {
561 spu->dma_callback(spu, SPE_EVENT_SPE_DATA_STORAGE);
562 }
563 return ret;
564}
565
566struct sysdev_class spu_sysdev_class = { 466struct sysdev_class spu_sysdev_class = {
567 set_kset_name("spu") 467 set_kset_name("spu")
568}; 468};
@@ -636,12 +536,6 @@ static int spu_create_sysdev(struct spu *spu)
636 return 0; 536 return 0;
637} 537}
638 538
639static void spu_destroy_sysdev(struct spu *spu)
640{
641 sysfs_remove_device_from_node(&spu->sysdev, spu->node);
642 sysdev_unregister(&spu->sysdev);
643}
644
645static int __init create_spu(void *data) 539static int __init create_spu(void *data)
646{ 540{
647 struct spu *spu; 541 struct spu *spu;
@@ -693,58 +587,37 @@ out:
693 return ret; 587 return ret;
694} 588}
695 589
696static void destroy_spu(struct spu *spu)
697{
698 list_del_init(&spu->list);
699 list_del_init(&spu->full_list);
700
701 spu_destroy_sysdev(spu);
702 spu_free_irqs(spu);
703 spu_destroy_spu(spu);
704 kfree(spu);
705}
706
707static void cleanup_spu_base(void)
708{
709 struct spu *spu, *tmp;
710 int node;
711
712 mutex_lock(&spu_mutex);
713 for (node = 0; node < MAX_NUMNODES; node++) {
714 list_for_each_entry_safe(spu, tmp, &spu_list[node], list)
715 destroy_spu(spu);
716 }
717 mutex_unlock(&spu_mutex);
718 sysdev_class_unregister(&spu_sysdev_class);
719}
720module_exit(cleanup_spu_base);
721
722static int __init init_spu_base(void) 590static int __init init_spu_base(void)
723{ 591{
724 int i, ret; 592 int i, ret = 0;
593
594 for (i = 0; i < MAX_NUMNODES; i++)
595 INIT_LIST_HEAD(&spu_list[i]);
725 596
726 if (!spu_management_ops) 597 if (!spu_management_ops)
727 return 0; 598 goto out;
728 599
729 /* create sysdev class for spus */ 600 /* create sysdev class for spus */
730 ret = sysdev_class_register(&spu_sysdev_class); 601 ret = sysdev_class_register(&spu_sysdev_class);
731 if (ret) 602 if (ret)
732 return ret; 603 goto out;
733
734 for (i = 0; i < MAX_NUMNODES; i++)
735 INIT_LIST_HEAD(&spu_list[i]);
736 604
737 ret = spu_enumerate_spus(create_spu); 605 ret = spu_enumerate_spus(create_spu);
738 606
739 if (ret) { 607 if (ret) {
740 printk(KERN_WARNING "%s: Error initializing spus\n", 608 printk(KERN_WARNING "%s: Error initializing spus\n",
741 __FUNCTION__); 609 __FUNCTION__);
742 cleanup_spu_base(); 610 goto out_unregister_sysdev_class;
743 return ret;
744 } 611 }
745 612
746 xmon_register_spus(&spu_full_list); 613 xmon_register_spus(&spu_full_list);
747 614
615 return 0;
616
617 out_unregister_sysdev_class:
618 sysdev_class_unregister(&spu_sysdev_class);
619 out:
620
748 return ret; 621 return ret;
749} 622}
750module_init(init_spu_base); 623module_init(init_spu_base);
diff --git a/arch/powerpc/platforms/cell/spu_coredump.c b/arch/powerpc/platforms/cell/spu_coredump.c
index 6915b418ee73..4fd37ff1e210 100644
--- a/arch/powerpc/platforms/cell/spu_coredump.c
+++ b/arch/powerpc/platforms/cell/spu_coredump.c
@@ -26,19 +26,18 @@
26 26
27#include <asm/spu.h> 27#include <asm/spu.h>
28 28
29static struct spu_coredump_calls spu_coredump_calls; 29static struct spu_coredump_calls *spu_coredump_calls;
30static DEFINE_MUTEX(spu_coredump_mutex); 30static DEFINE_MUTEX(spu_coredump_mutex);
31 31
32int arch_notes_size(void) 32int arch_notes_size(void)
33{ 33{
34 long ret; 34 long ret;
35 struct module *owner = spu_coredump_calls.owner;
36 35
37 ret = -ENOSYS; 36 ret = -ENOSYS;
38 mutex_lock(&spu_coredump_mutex); 37 mutex_lock(&spu_coredump_mutex);
39 if (owner && try_module_get(owner)) { 38 if (spu_coredump_calls && try_module_get(spu_coredump_calls->owner)) {
40 ret = spu_coredump_calls.arch_notes_size(); 39 ret = spu_coredump_calls->arch_notes_size();
41 module_put(owner); 40 module_put(spu_coredump_calls->owner);
42 } 41 }
43 mutex_unlock(&spu_coredump_mutex); 42 mutex_unlock(&spu_coredump_mutex);
44 return ret; 43 return ret;
@@ -46,36 +45,35 @@ int arch_notes_size(void)
46 45
47void arch_write_notes(struct file *file) 46void arch_write_notes(struct file *file)
48{ 47{
49 struct module *owner = spu_coredump_calls.owner;
50
51 mutex_lock(&spu_coredump_mutex); 48 mutex_lock(&spu_coredump_mutex);
52 if (owner && try_module_get(owner)) { 49 if (spu_coredump_calls && try_module_get(spu_coredump_calls->owner)) {
53 spu_coredump_calls.arch_write_notes(file); 50 spu_coredump_calls->arch_write_notes(file);
54 module_put(owner); 51 module_put(spu_coredump_calls->owner);
55 } 52 }
56 mutex_unlock(&spu_coredump_mutex); 53 mutex_unlock(&spu_coredump_mutex);
57} 54}
58 55
59int register_arch_coredump_calls(struct spu_coredump_calls *calls) 56int register_arch_coredump_calls(struct spu_coredump_calls *calls)
60{ 57{
61 if (spu_coredump_calls.owner) 58 int ret = 0;
62 return -EBUSY; 59
63 60
64 mutex_lock(&spu_coredump_mutex); 61 mutex_lock(&spu_coredump_mutex);
65 spu_coredump_calls.arch_notes_size = calls->arch_notes_size; 62 if (spu_coredump_calls)
66 spu_coredump_calls.arch_write_notes = calls->arch_write_notes; 63 ret = -EBUSY;
67 spu_coredump_calls.owner = calls->owner; 64 else
65 spu_coredump_calls = calls;
68 mutex_unlock(&spu_coredump_mutex); 66 mutex_unlock(&spu_coredump_mutex);
69 return 0; 67 return ret;
70} 68}
71EXPORT_SYMBOL_GPL(register_arch_coredump_calls); 69EXPORT_SYMBOL_GPL(register_arch_coredump_calls);
72 70
73void unregister_arch_coredump_calls(struct spu_coredump_calls *calls) 71void unregister_arch_coredump_calls(struct spu_coredump_calls *calls)
74{ 72{
75 BUG_ON(spu_coredump_calls.owner != calls->owner); 73 BUG_ON(spu_coredump_calls != calls);
76 74
77 mutex_lock(&spu_coredump_mutex); 75 mutex_lock(&spu_coredump_mutex);
78 spu_coredump_calls.owner = NULL; 76 spu_coredump_calls = NULL;
79 mutex_unlock(&spu_coredump_mutex); 77 mutex_unlock(&spu_coredump_mutex);
80} 78}
81EXPORT_SYMBOL_GPL(unregister_arch_coredump_calls); 79EXPORT_SYMBOL_GPL(unregister_arch_coredump_calls);
diff --git a/arch/powerpc/platforms/cell/spu_manage.c b/arch/powerpc/platforms/cell/spu_manage.c
index e34599f53d28..1d4562ae463d 100644
--- a/arch/powerpc/platforms/cell/spu_manage.c
+++ b/arch/powerpc/platforms/cell/spu_manage.c
@@ -48,11 +48,11 @@ static u64 __init find_spu_unit_number(struct device_node *spe)
48{ 48{
49 const unsigned int *prop; 49 const unsigned int *prop;
50 int proplen; 50 int proplen;
51 prop = get_property(spe, "unit-id", &proplen); 51 prop = of_get_property(spe, "unit-id", &proplen);
52 if (proplen == 4) 52 if (proplen == 4)
53 return (u64)*prop; 53 return (u64)*prop;
54 54
55 prop = get_property(spe, "reg", &proplen); 55 prop = of_get_property(spe, "reg", &proplen);
56 if (proplen == 4) 56 if (proplen == 4)
57 return (u64)*prop; 57 return (u64)*prop;
58 58
@@ -76,12 +76,12 @@ static int __init spu_map_interrupts_old(struct spu *spu,
76 int nid; 76 int nid;
77 77
78 /* Get the interrupt source unit from the device-tree */ 78 /* Get the interrupt source unit from the device-tree */
79 tmp = get_property(np, "isrc", NULL); 79 tmp = of_get_property(np, "isrc", NULL);
80 if (!tmp) 80 if (!tmp)
81 return -ENODEV; 81 return -ENODEV;
82 isrc = tmp[0]; 82 isrc = tmp[0];
83 83
84 tmp = get_property(np->parent->parent, "node-id", NULL); 84 tmp = of_get_property(np->parent->parent, "node-id", NULL);
85 if (!tmp) { 85 if (!tmp) {
86 printk(KERN_WARNING "%s: can't find node-id\n", __FUNCTION__); 86 printk(KERN_WARNING "%s: can't find node-id\n", __FUNCTION__);
87 nid = spu->node; 87 nid = spu->node;
@@ -110,7 +110,7 @@ static void __iomem * __init spu_map_prop_old(struct spu *spu,
110 } __attribute__((packed)) *prop; 110 } __attribute__((packed)) *prop;
111 int proplen; 111 int proplen;
112 112
113 prop = get_property(n, name, &proplen); 113 prop = of_get_property(n, name, &proplen);
114 if (prop == NULL || proplen != sizeof (struct address_prop)) 114 if (prop == NULL || proplen != sizeof (struct address_prop))
115 return NULL; 115 return NULL;
116 116
@@ -124,11 +124,11 @@ static int __init spu_map_device_old(struct spu *spu)
124 int ret; 124 int ret;
125 125
126 ret = -ENODEV; 126 ret = -ENODEV;
127 spu->name = get_property(node, "name", NULL); 127 spu->name = of_get_property(node, "name", NULL);
128 if (!spu->name) 128 if (!spu->name)
129 goto out; 129 goto out;
130 130
131 prop = get_property(node, "local-store", NULL); 131 prop = of_get_property(node, "local-store", NULL);
132 if (!prop) 132 if (!prop)
133 goto out; 133 goto out;
134 spu->local_store_phys = *(unsigned long *)prop; 134 spu->local_store_phys = *(unsigned long *)prop;
@@ -139,7 +139,7 @@ static int __init spu_map_device_old(struct spu *spu)
139 if (!spu->local_store) 139 if (!spu->local_store)
140 goto out; 140 goto out;
141 141
142 prop = get_property(node, "problem", NULL); 142 prop = of_get_property(node, "problem", NULL);
143 if (!prop) 143 if (!prop)
144 goto out_unmap; 144 goto out_unmap;
145 spu->problem_phys = *(unsigned long *)prop; 145 spu->problem_phys = *(unsigned long *)prop;
@@ -226,7 +226,7 @@ static int __init spu_map_device(struct spu *spu)
226 struct device_node *np = spu->devnode; 226 struct device_node *np = spu->devnode;
227 int ret = -ENODEV; 227 int ret = -ENODEV;
228 228
229 spu->name = get_property(np, "name", NULL); 229 spu->name = of_get_property(np, "name", NULL);
230 if (!spu->name) 230 if (!spu->name)
231 goto out; 231 goto out;
232 232
diff --git a/arch/powerpc/platforms/cell/spufs/Makefile b/arch/powerpc/platforms/cell/spufs/Makefile
index 472217d19faf..2cd89c11af5a 100644
--- a/arch/powerpc/platforms/cell/spufs/Makefile
+++ b/arch/powerpc/platforms/cell/spufs/Makefile
@@ -1,4 +1,4 @@
1obj-y += switch.o 1obj-y += switch.o fault.o
2 2
3obj-$(CONFIG_SPU_FS) += spufs.o 3obj-$(CONFIG_SPU_FS) += spufs.o
4spufs-y += inode.o file.o context.o syscalls.o coredump.o 4spufs-y += inode.o file.o context.o syscalls.o coredump.o
diff --git a/arch/powerpc/platforms/cell/spufs/backing_ops.c b/arch/powerpc/platforms/cell/spufs/backing_ops.c
index 1898f0d3a8b8..3322528fa6eb 100644
--- a/arch/powerpc/platforms/cell/spufs/backing_ops.c
+++ b/arch/powerpc/platforms/cell/spufs/backing_ops.c
@@ -350,6 +350,11 @@ static int spu_backing_send_mfc_command(struct spu_context *ctx,
350 return ret; 350 return ret;
351} 351}
352 352
353static void spu_backing_restart_dma(struct spu_context *ctx)
354{
355 /* nothing to do here */
356}
357
353struct spu_context_ops spu_backing_ops = { 358struct spu_context_ops spu_backing_ops = {
354 .mbox_read = spu_backing_mbox_read, 359 .mbox_read = spu_backing_mbox_read,
355 .mbox_stat_read = spu_backing_mbox_stat_read, 360 .mbox_stat_read = spu_backing_mbox_stat_read,
@@ -376,4 +381,5 @@ struct spu_context_ops spu_backing_ops = {
376 .read_mfc_tagstatus = spu_backing_read_mfc_tagstatus, 381 .read_mfc_tagstatus = spu_backing_read_mfc_tagstatus,
377 .get_mfc_free_elements = spu_backing_get_mfc_free_elements, 382 .get_mfc_free_elements = spu_backing_get_mfc_free_elements,
378 .send_mfc_command = spu_backing_send_mfc_command, 383 .send_mfc_command = spu_backing_send_mfc_command,
384 .restart_dma = spu_backing_restart_dma,
379}; 385};
diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c
index 04ad2e364e97..a87d9ca3dba2 100644
--- a/arch/powerpc/platforms/cell/spufs/context.c
+++ b/arch/powerpc/platforms/cell/spufs/context.c
@@ -41,9 +41,10 @@ struct spu_context *alloc_spu_context(struct spu_gang *gang)
41 goto out_free; 41 goto out_free;
42 } 42 }
43 spin_lock_init(&ctx->mmio_lock); 43 spin_lock_init(&ctx->mmio_lock);
44 spin_lock_init(&ctx->mapping_lock);
44 kref_init(&ctx->kref); 45 kref_init(&ctx->kref);
45 mutex_init(&ctx->state_mutex); 46 mutex_init(&ctx->state_mutex);
46 init_MUTEX(&ctx->run_sema); 47 mutex_init(&ctx->run_mutex);
47 init_waitqueue_head(&ctx->ibox_wq); 48 init_waitqueue_head(&ctx->ibox_wq);
48 init_waitqueue_head(&ctx->wbox_wq); 49 init_waitqueue_head(&ctx->wbox_wq);
49 init_waitqueue_head(&ctx->stop_wq); 50 init_waitqueue_head(&ctx->stop_wq);
@@ -51,6 +52,7 @@ struct spu_context *alloc_spu_context(struct spu_gang *gang)
51 ctx->state = SPU_STATE_SAVED; 52 ctx->state = SPU_STATE_SAVED;
52 ctx->ops = &spu_backing_ops; 53 ctx->ops = &spu_backing_ops;
53 ctx->owner = get_task_mm(current); 54 ctx->owner = get_task_mm(current);
55 INIT_LIST_HEAD(&ctx->rq);
54 if (gang) 56 if (gang)
55 spu_gang_add_ctx(gang, ctx); 57 spu_gang_add_ctx(gang, ctx);
56 ctx->rt_priority = current->rt_priority; 58 ctx->rt_priority = current->rt_priority;
@@ -75,6 +77,7 @@ void destroy_spu_context(struct kref *kref)
75 spu_fini_csa(&ctx->csa); 77 spu_fini_csa(&ctx->csa);
76 if (ctx->gang) 78 if (ctx->gang)
77 spu_gang_remove_ctx(ctx->gang, ctx); 79 spu_gang_remove_ctx(ctx->gang, ctx);
80 BUG_ON(!list_empty(&ctx->rq));
78 kfree(ctx); 81 kfree(ctx);
79} 82}
80 83
@@ -119,46 +122,6 @@ void spu_unmap_mappings(struct spu_context *ctx)
119} 122}
120 123
121/** 124/**
122 * spu_acquire_exclusive - lock spu contex and protect against userspace access
123 * @ctx: spu contex to lock
124 *
125 * Note:
126 * Returns 0 and with the context locked on success
127 * Returns negative error and with the context _unlocked_ on failure.
128 */
129int spu_acquire_exclusive(struct spu_context *ctx)
130{
131 int ret = -EINVAL;
132
133 spu_acquire(ctx);
134 /*
135 * Context is about to be freed, so we can't acquire it anymore.
136 */
137 if (!ctx->owner)
138 goto out_unlock;
139
140 if (ctx->state == SPU_STATE_SAVED) {
141 ret = spu_activate(ctx, 0);
142 if (ret)
143 goto out_unlock;
144 } else {
145 /*
146 * We need to exclude userspace access to the context.
147 *
148 * To protect against memory access we invalidate all ptes
149 * and make sure the pagefault handlers block on the mutex.
150 */
151 spu_unmap_mappings(ctx);
152 }
153
154 return 0;
155
156 out_unlock:
157 spu_release(ctx);
158 return ret;
159}
160
161/**
162 * spu_acquire_runnable - lock spu contex and make sure it is in runnable state 125 * spu_acquire_runnable - lock spu contex and make sure it is in runnable state
163 * @ctx: spu contex to lock 126 * @ctx: spu contex to lock
164 * 127 *
diff --git a/arch/powerpc/platforms/cell/spufs/coredump.c b/arch/powerpc/platforms/cell/spufs/coredump.c
index 725e19561159..5d9ad5a0307b 100644
--- a/arch/powerpc/platforms/cell/spufs/coredump.c
+++ b/arch/powerpc/platforms/cell/spufs/coredump.c
@@ -169,12 +169,12 @@ static void spufs_arch_write_note(struct spufs_ctx_info *ctx_info, int i,
169 struct spu_context *ctx; 169 struct spu_context *ctx;
170 loff_t pos = 0; 170 loff_t pos = 0;
171 int sz, dfd, rc, total = 0; 171 int sz, dfd, rc, total = 0;
172 const int bufsz = 4096; 172 const int bufsz = PAGE_SIZE;
173 char *name; 173 char *name;
174 char fullname[80], *buf; 174 char fullname[80], *buf;
175 struct elf_note en; 175 struct elf_note en;
176 176
177 buf = kmalloc(bufsz, GFP_KERNEL); 177 buf = (void *)get_zeroed_page(GFP_KERNEL);
178 if (!buf) 178 if (!buf)
179 return; 179 return;
180 180
@@ -187,9 +187,8 @@ static void spufs_arch_write_note(struct spufs_ctx_info *ctx_info, int i,
187 sz = spufs_coredump_read[i].size; 187 sz = spufs_coredump_read[i].size;
188 188
189 ctx = ctx_info->ctx; 189 ctx = ctx_info->ctx;
190 if (!ctx) { 190 if (!ctx)
191 return; 191 goto out;
192 }
193 192
194 sprintf(fullname, "SPU/%d/%s", dfd, name); 193 sprintf(fullname, "SPU/%d/%s", dfd, name);
195 en.n_namesz = strlen(fullname) + 1; 194 en.n_namesz = strlen(fullname) + 1;
@@ -197,23 +196,25 @@ static void spufs_arch_write_note(struct spufs_ctx_info *ctx_info, int i,
197 en.n_type = NT_SPU; 196 en.n_type = NT_SPU;
198 197
199 if (!spufs_dump_write(file, &en, sizeof(en))) 198 if (!spufs_dump_write(file, &en, sizeof(en)))
200 return; 199 goto out;
201 if (!spufs_dump_write(file, fullname, en.n_namesz)) 200 if (!spufs_dump_write(file, fullname, en.n_namesz))
202 return; 201 goto out;
203 if (!spufs_dump_seek(file, roundup((unsigned long)file->f_pos, 4))) 202 if (!spufs_dump_seek(file, roundup((unsigned long)file->f_pos, 4)))
204 return; 203 goto out;
205 204
206 do { 205 do {
207 rc = do_coredump_read(i, ctx, buf, bufsz, &pos); 206 rc = do_coredump_read(i, ctx, buf, bufsz, &pos);
208 if (rc > 0) { 207 if (rc > 0) {
209 if (!spufs_dump_write(file, buf, rc)) 208 if (!spufs_dump_write(file, buf, rc))
210 return; 209 goto out;
211 total += rc; 210 total += rc;
212 } 211 }
213 } while (rc == bufsz && total < sz); 212 } while (rc == bufsz && total < sz);
214 213
215 spufs_dump_seek(file, roundup((unsigned long)file->f_pos 214 spufs_dump_seek(file, roundup((unsigned long)file->f_pos
216 - total + sz, 4)); 215 - total + sz, 4));
216out:
217 free_page((unsigned long)buf);
217} 218}
218 219
219static void spufs_arch_write_notes(struct file *file) 220static void spufs_arch_write_notes(struct file *file)
diff --git a/arch/powerpc/platforms/cell/spufs/fault.c b/arch/powerpc/platforms/cell/spufs/fault.c
new file mode 100644
index 000000000000..0f75c07e29d8
--- /dev/null
+++ b/arch/powerpc/platforms/cell/spufs/fault.c
@@ -0,0 +1,211 @@
1/*
2 * Low-level SPU handling
3 *
4 * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
5 *
6 * Author: Arnd Bergmann <arndb@de.ibm.com>
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, or (at your option)
11 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22#include <linux/sched.h>
23#include <linux/mm.h>
24#include <linux/module.h>
25
26#include <asm/spu.h>
27#include <asm/spu_csa.h>
28
29#include "spufs.h"
30
31/*
32 * This ought to be kept in sync with the powerpc specific do_page_fault
33 * function. Currently, there are a few corner cases that we haven't had
34 * to handle fortunately.
35 */
36static int spu_handle_mm_fault(struct mm_struct *mm, unsigned long ea, unsigned long dsisr)
37{
38 struct vm_area_struct *vma;
39 unsigned long is_write;
40 int ret;
41
42#if 0
43 if (!IS_VALID_EA(ea)) {
44 return -EFAULT;
45 }
46#endif /* XXX */
47 if (mm == NULL) {
48 return -EFAULT;
49 }
50 if (mm->pgd == NULL) {
51 return -EFAULT;
52 }
53
54 down_read(&mm->mmap_sem);
55 vma = find_vma(mm, ea);
56 if (!vma)
57 goto bad_area;
58 if (vma->vm_start <= ea)
59 goto good_area;
60 if (!(vma->vm_flags & VM_GROWSDOWN))
61 goto bad_area;
62 if (expand_stack(vma, ea))
63 goto bad_area;
64good_area:
65 is_write = dsisr & MFC_DSISR_ACCESS_PUT;
66 if (is_write) {
67 if (!(vma->vm_flags & VM_WRITE))
68 goto bad_area;
69 } else {
70 if (dsisr & MFC_DSISR_ACCESS_DENIED)
71 goto bad_area;
72 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
73 goto bad_area;
74 }
75 ret = 0;
76 switch (handle_mm_fault(mm, vma, ea, is_write)) {
77 case VM_FAULT_MINOR:
78 current->min_flt++;
79 break;
80 case VM_FAULT_MAJOR:
81 current->maj_flt++;
82 break;
83 case VM_FAULT_SIGBUS:
84 ret = -EFAULT;
85 goto bad_area;
86 case VM_FAULT_OOM:
87 ret = -ENOMEM;
88 goto bad_area;
89 default:
90 BUG();
91 }
92 up_read(&mm->mmap_sem);
93 return ret;
94
95bad_area:
96 up_read(&mm->mmap_sem);
97 return -EFAULT;
98}
99
100static void spufs_handle_dma_error(struct spu_context *ctx,
101 unsigned long ea, int type)
102{
103 if (ctx->flags & SPU_CREATE_EVENTS_ENABLED) {
104 ctx->event_return |= type;
105 wake_up_all(&ctx->stop_wq);
106 } else {
107 siginfo_t info;
108 memset(&info, 0, sizeof(info));
109
110 switch (type) {
111 case SPE_EVENT_INVALID_DMA:
112 info.si_signo = SIGBUS;
113 info.si_code = BUS_OBJERR;
114 break;
115 case SPE_EVENT_SPE_DATA_STORAGE:
116 info.si_signo = SIGBUS;
117 info.si_addr = (void __user *)ea;
118 info.si_code = BUS_ADRERR;
119 break;
120 case SPE_EVENT_DMA_ALIGNMENT:
121 info.si_signo = SIGBUS;
122 /* DAR isn't set for an alignment fault :( */
123 info.si_code = BUS_ADRALN;
124 break;
125 case SPE_EVENT_SPE_ERROR:
126 info.si_signo = SIGILL;
127 info.si_addr = (void __user *)(unsigned long)
128 ctx->ops->npc_read(ctx) - 4;
129 info.si_code = ILL_ILLOPC;
130 break;
131 }
132 if (info.si_signo)
133 force_sig_info(info.si_signo, &info, current);
134 }
135}
136
137void spufs_dma_callback(struct spu *spu, int type)
138{
139 spufs_handle_dma_error(spu->ctx, spu->dar, type);
140}
141EXPORT_SYMBOL_GPL(spufs_dma_callback);
142
143/*
144 * bottom half handler for page faults, we can't do this from
145 * interrupt context, since we might need to sleep.
146 * we also need to give up the mutex so we can get scheduled
147 * out while waiting for the backing store.
148 *
149 * TODO: try calling hash_page from the interrupt handler first
150 * in order to speed up the easy case.
151 */
152int spufs_handle_class1(struct spu_context *ctx)
153{
154 u64 ea, dsisr, access;
155 unsigned long flags;
156 int ret;
157
158 /*
159 * dar and dsisr get passed from the registers
160 * to the spu_context, to this function, but not
161 * back to the spu if it gets scheduled again.
162 *
163 * if we don't handle the fault for a saved context
164 * in time, we can still expect to get the same fault
165 * the immediately after the context restore.
166 */
167 if (ctx->state == SPU_STATE_RUNNABLE) {
168 ea = ctx->spu->dar;
169 dsisr = ctx->spu->dsisr;
170 ctx->spu->dar= ctx->spu->dsisr = 0;
171 } else {
172 ea = ctx->csa.priv1.mfc_dar_RW;
173 dsisr = ctx->csa.priv1.mfc_dsisr_RW;
174 ctx->csa.priv1.mfc_dar_RW = 0;
175 ctx->csa.priv1.mfc_dsisr_RW = 0;
176 }
177
178 if (!(dsisr & (MFC_DSISR_PTE_NOT_FOUND | MFC_DSISR_ACCESS_DENIED)))
179 return 0;
180
181 pr_debug("ctx %p: ea %016lx, dsisr %016lx state %d\n", ctx, ea,
182 dsisr, ctx->state);
183
184 /* we must not hold the lock when entering spu_handle_mm_fault */
185 spu_release(ctx);
186
187 access = (_PAGE_PRESENT | _PAGE_USER);
188 access |= (dsisr & MFC_DSISR_ACCESS_PUT) ? _PAGE_RW : 0UL;
189 local_irq_save(flags);
190 ret = hash_page(ea, access, 0x300);
191 local_irq_restore(flags);
192
193 /* hashing failed, so try the actual fault handler */
194 if (ret)
195 ret = spu_handle_mm_fault(current->mm, ea, dsisr);
196
197 spu_acquire(ctx);
198 /*
199 * If we handled the fault successfully and are in runnable
200 * state, restart the DMA.
201 * In case of unhandled error report the problem to user space.
202 */
203 if (!ret) {
204 if (ctx->spu)
205 ctx->ops->restart_dma(ctx);
206 } else
207 spufs_handle_dma_error(ctx, ea, SPE_EVENT_SPE_DATA_STORAGE);
208
209 return ret;
210}
211EXPORT_SYMBOL_GPL(spufs_handle_class1);
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index 505266a568d4..d010b2464a98 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -44,9 +44,25 @@ spufs_mem_open(struct inode *inode, struct file *file)
44{ 44{
45 struct spufs_inode_info *i = SPUFS_I(inode); 45 struct spufs_inode_info *i = SPUFS_I(inode);
46 struct spu_context *ctx = i->i_ctx; 46 struct spu_context *ctx = i->i_ctx;
47
48 spin_lock(&ctx->mapping_lock);
47 file->private_data = ctx; 49 file->private_data = ctx;
48 ctx->local_store = inode->i_mapping; 50 if (!i->i_openers++)
49 smp_wmb(); 51 ctx->local_store = inode->i_mapping;
52 spin_unlock(&ctx->mapping_lock);
53 return 0;
54}
55
56static int
57spufs_mem_release(struct inode *inode, struct file *file)
58{
59 struct spufs_inode_info *i = SPUFS_I(inode);
60 struct spu_context *ctx = i->i_ctx;
61
62 spin_lock(&ctx->mapping_lock);
63 if (!--i->i_openers)
64 ctx->local_store = NULL;
65 spin_unlock(&ctx->mapping_lock);
50 return 0; 66 return 0;
51} 67}
52 68
@@ -149,6 +165,7 @@ spufs_mem_mmap(struct file *file, struct vm_area_struct *vma)
149 165
150static const struct file_operations spufs_mem_fops = { 166static const struct file_operations spufs_mem_fops = {
151 .open = spufs_mem_open, 167 .open = spufs_mem_open,
168 .release = spufs_mem_release,
152 .read = spufs_mem_read, 169 .read = spufs_mem_read,
153 .write = spufs_mem_write, 170 .write = spufs_mem_write,
154 .llseek = generic_file_llseek, 171 .llseek = generic_file_llseek,
@@ -238,16 +255,33 @@ static int spufs_cntl_open(struct inode *inode, struct file *file)
238 struct spufs_inode_info *i = SPUFS_I(inode); 255 struct spufs_inode_info *i = SPUFS_I(inode);
239 struct spu_context *ctx = i->i_ctx; 256 struct spu_context *ctx = i->i_ctx;
240 257
258 spin_lock(&ctx->mapping_lock);
241 file->private_data = ctx; 259 file->private_data = ctx;
242 ctx->cntl = inode->i_mapping; 260 if (!i->i_openers++)
243 smp_wmb(); 261 ctx->cntl = inode->i_mapping;
262 spin_unlock(&ctx->mapping_lock);
244 return simple_attr_open(inode, file, spufs_cntl_get, 263 return simple_attr_open(inode, file, spufs_cntl_get,
245 spufs_cntl_set, "0x%08lx"); 264 spufs_cntl_set, "0x%08lx");
246} 265}
247 266
267static int
268spufs_cntl_release(struct inode *inode, struct file *file)
269{
270 struct spufs_inode_info *i = SPUFS_I(inode);
271 struct spu_context *ctx = i->i_ctx;
272
273 simple_attr_close(inode, file);
274
275 spin_lock(&ctx->mapping_lock);
276 if (!--i->i_openers)
277 ctx->cntl = NULL;
278 spin_unlock(&ctx->mapping_lock);
279 return 0;
280}
281
248static const struct file_operations spufs_cntl_fops = { 282static const struct file_operations spufs_cntl_fops = {
249 .open = spufs_cntl_open, 283 .open = spufs_cntl_open,
250 .release = simple_attr_close, 284 .release = spufs_cntl_release,
251 .read = simple_attr_read, 285 .read = simple_attr_read,
252 .write = simple_attr_write, 286 .write = simple_attr_write,
253 .mmap = spufs_cntl_mmap, 287 .mmap = spufs_cntl_mmap,
@@ -723,12 +757,28 @@ static int spufs_signal1_open(struct inode *inode, struct file *file)
723{ 757{
724 struct spufs_inode_info *i = SPUFS_I(inode); 758 struct spufs_inode_info *i = SPUFS_I(inode);
725 struct spu_context *ctx = i->i_ctx; 759 struct spu_context *ctx = i->i_ctx;
760
761 spin_lock(&ctx->mapping_lock);
726 file->private_data = ctx; 762 file->private_data = ctx;
727 ctx->signal1 = inode->i_mapping; 763 if (!i->i_openers++)
728 smp_wmb(); 764 ctx->signal1 = inode->i_mapping;
765 spin_unlock(&ctx->mapping_lock);
729 return nonseekable_open(inode, file); 766 return nonseekable_open(inode, file);
730} 767}
731 768
769static int
770spufs_signal1_release(struct inode *inode, struct file *file)
771{
772 struct spufs_inode_info *i = SPUFS_I(inode);
773 struct spu_context *ctx = i->i_ctx;
774
775 spin_lock(&ctx->mapping_lock);
776 if (!--i->i_openers)
777 ctx->signal1 = NULL;
778 spin_unlock(&ctx->mapping_lock);
779 return 0;
780}
781
732static ssize_t __spufs_signal1_read(struct spu_context *ctx, char __user *buf, 782static ssize_t __spufs_signal1_read(struct spu_context *ctx, char __user *buf,
733 size_t len, loff_t *pos) 783 size_t len, loff_t *pos)
734{ 784{
@@ -821,6 +871,7 @@ static int spufs_signal1_mmap(struct file *file, struct vm_area_struct *vma)
821 871
822static const struct file_operations spufs_signal1_fops = { 872static const struct file_operations spufs_signal1_fops = {
823 .open = spufs_signal1_open, 873 .open = spufs_signal1_open,
874 .release = spufs_signal1_release,
824 .read = spufs_signal1_read, 875 .read = spufs_signal1_read,
825 .write = spufs_signal1_write, 876 .write = spufs_signal1_write,
826 .mmap = spufs_signal1_mmap, 877 .mmap = spufs_signal1_mmap,
@@ -830,12 +881,28 @@ static int spufs_signal2_open(struct inode *inode, struct file *file)
830{ 881{
831 struct spufs_inode_info *i = SPUFS_I(inode); 882 struct spufs_inode_info *i = SPUFS_I(inode);
832 struct spu_context *ctx = i->i_ctx; 883 struct spu_context *ctx = i->i_ctx;
884
885 spin_lock(&ctx->mapping_lock);
833 file->private_data = ctx; 886 file->private_data = ctx;
834 ctx->signal2 = inode->i_mapping; 887 if (!i->i_openers++)
835 smp_wmb(); 888 ctx->signal2 = inode->i_mapping;
889 spin_unlock(&ctx->mapping_lock);
836 return nonseekable_open(inode, file); 890 return nonseekable_open(inode, file);
837} 891}
838 892
893static int
894spufs_signal2_release(struct inode *inode, struct file *file)
895{
896 struct spufs_inode_info *i = SPUFS_I(inode);
897 struct spu_context *ctx = i->i_ctx;
898
899 spin_lock(&ctx->mapping_lock);
900 if (!--i->i_openers)
901 ctx->signal2 = NULL;
902 spin_unlock(&ctx->mapping_lock);
903 return 0;
904}
905
839static ssize_t __spufs_signal2_read(struct spu_context *ctx, char __user *buf, 906static ssize_t __spufs_signal2_read(struct spu_context *ctx, char __user *buf,
840 size_t len, loff_t *pos) 907 size_t len, loff_t *pos)
841{ 908{
@@ -932,6 +999,7 @@ static int spufs_signal2_mmap(struct file *file, struct vm_area_struct *vma)
932 999
933static const struct file_operations spufs_signal2_fops = { 1000static const struct file_operations spufs_signal2_fops = {
934 .open = spufs_signal2_open, 1001 .open = spufs_signal2_open,
1002 .release = spufs_signal2_release,
935 .read = spufs_signal2_read, 1003 .read = spufs_signal2_read,
936 .write = spufs_signal2_write, 1004 .write = spufs_signal2_write,
937 .mmap = spufs_signal2_mmap, 1005 .mmap = spufs_signal2_mmap,
@@ -1031,13 +1099,30 @@ static int spufs_mss_open(struct inode *inode, struct file *file)
1031 struct spu_context *ctx = i->i_ctx; 1099 struct spu_context *ctx = i->i_ctx;
1032 1100
1033 file->private_data = i->i_ctx; 1101 file->private_data = i->i_ctx;
1034 ctx->mss = inode->i_mapping; 1102
1035 smp_wmb(); 1103 spin_lock(&ctx->mapping_lock);
1104 if (!i->i_openers++)
1105 ctx->mss = inode->i_mapping;
1106 spin_unlock(&ctx->mapping_lock);
1036 return nonseekable_open(inode, file); 1107 return nonseekable_open(inode, file);
1037} 1108}
1038 1109
1110static int
1111spufs_mss_release(struct inode *inode, struct file *file)
1112{
1113 struct spufs_inode_info *i = SPUFS_I(inode);
1114 struct spu_context *ctx = i->i_ctx;
1115
1116 spin_lock(&ctx->mapping_lock);
1117 if (!--i->i_openers)
1118 ctx->mss = NULL;
1119 spin_unlock(&ctx->mapping_lock);
1120 return 0;
1121}
1122
1039static const struct file_operations spufs_mss_fops = { 1123static const struct file_operations spufs_mss_fops = {
1040 .open = spufs_mss_open, 1124 .open = spufs_mss_open,
1125 .release = spufs_mss_release,
1041 .mmap = spufs_mss_mmap, 1126 .mmap = spufs_mss_mmap,
1042}; 1127};
1043 1128
@@ -1072,14 +1157,30 @@ static int spufs_psmap_open(struct inode *inode, struct file *file)
1072 struct spufs_inode_info *i = SPUFS_I(inode); 1157 struct spufs_inode_info *i = SPUFS_I(inode);
1073 struct spu_context *ctx = i->i_ctx; 1158 struct spu_context *ctx = i->i_ctx;
1074 1159
1160 spin_lock(&ctx->mapping_lock);
1075 file->private_data = i->i_ctx; 1161 file->private_data = i->i_ctx;
1076 ctx->psmap = inode->i_mapping; 1162 if (!i->i_openers++)
1077 smp_wmb(); 1163 ctx->psmap = inode->i_mapping;
1164 spin_unlock(&ctx->mapping_lock);
1078 return nonseekable_open(inode, file); 1165 return nonseekable_open(inode, file);
1079} 1166}
1080 1167
1168static int
1169spufs_psmap_release(struct inode *inode, struct file *file)
1170{
1171 struct spufs_inode_info *i = SPUFS_I(inode);
1172 struct spu_context *ctx = i->i_ctx;
1173
1174 spin_lock(&ctx->mapping_lock);
1175 if (!--i->i_openers)
1176 ctx->psmap = NULL;
1177 spin_unlock(&ctx->mapping_lock);
1178 return 0;
1179}
1180
1081static const struct file_operations spufs_psmap_fops = { 1181static const struct file_operations spufs_psmap_fops = {
1082 .open = spufs_psmap_open, 1182 .open = spufs_psmap_open,
1183 .release = spufs_psmap_release,
1083 .mmap = spufs_psmap_mmap, 1184 .mmap = spufs_psmap_mmap,
1084}; 1185};
1085 1186
@@ -1126,12 +1227,27 @@ static int spufs_mfc_open(struct inode *inode, struct file *file)
1126 if (atomic_read(&inode->i_count) != 1) 1227 if (atomic_read(&inode->i_count) != 1)
1127 return -EBUSY; 1228 return -EBUSY;
1128 1229
1230 spin_lock(&ctx->mapping_lock);
1129 file->private_data = ctx; 1231 file->private_data = ctx;
1130 ctx->mfc = inode->i_mapping; 1232 if (!i->i_openers++)
1131 smp_wmb(); 1233 ctx->mfc = inode->i_mapping;
1234 spin_unlock(&ctx->mapping_lock);
1132 return nonseekable_open(inode, file); 1235 return nonseekable_open(inode, file);
1133} 1236}
1134 1237
1238static int
1239spufs_mfc_release(struct inode *inode, struct file *file)
1240{
1241 struct spufs_inode_info *i = SPUFS_I(inode);
1242 struct spu_context *ctx = i->i_ctx;
1243
1244 spin_lock(&ctx->mapping_lock);
1245 if (!--i->i_openers)
1246 ctx->mfc = NULL;
1247 spin_unlock(&ctx->mapping_lock);
1248 return 0;
1249}
1250
1135/* interrupt-level mfc callback function. */ 1251/* interrupt-level mfc callback function. */
1136void spufs_mfc_callback(struct spu *spu) 1252void spufs_mfc_callback(struct spu *spu)
1137{ 1253{
@@ -1313,7 +1429,10 @@ static ssize_t spufs_mfc_write(struct file *file, const char __user *buffer,
1313 if (ret) 1429 if (ret)
1314 goto out; 1430 goto out;
1315 1431
1316 spu_acquire_runnable(ctx, 0); 1432 ret = spu_acquire_runnable(ctx, 0);
1433 if (ret)
1434 goto out;
1435
1317 if (file->f_flags & O_NONBLOCK) { 1436 if (file->f_flags & O_NONBLOCK) {
1318 ret = ctx->ops->send_mfc_command(ctx, &cmd); 1437 ret = ctx->ops->send_mfc_command(ctx, &cmd);
1319 } else { 1438 } else {
@@ -1399,6 +1518,7 @@ static int spufs_mfc_fasync(int fd, struct file *file, int on)
1399 1518
1400static const struct file_operations spufs_mfc_fops = { 1519static const struct file_operations spufs_mfc_fops = {
1401 .open = spufs_mfc_open, 1520 .open = spufs_mfc_open,
1521 .release = spufs_mfc_release,
1402 .read = spufs_mfc_read, 1522 .read = spufs_mfc_read,
1403 .write = spufs_mfc_write, 1523 .write = spufs_mfc_write,
1404 .poll = spufs_mfc_poll, 1524 .poll = spufs_mfc_poll,
diff --git a/arch/powerpc/platforms/cell/spufs/hw_ops.c b/arch/powerpc/platforms/cell/spufs/hw_ops.c
index ae42e03b8c86..428875c5e4ec 100644
--- a/arch/powerpc/platforms/cell/spufs/hw_ops.c
+++ b/arch/powerpc/platforms/cell/spufs/hw_ops.c
@@ -296,6 +296,14 @@ static int spu_hw_send_mfc_command(struct spu_context *ctx,
296 } 296 }
297} 297}
298 298
299static void spu_hw_restart_dma(struct spu_context *ctx)
300{
301 struct spu_priv2 __iomem *priv2 = ctx->spu->priv2;
302
303 if (!test_bit(SPU_CONTEXT_SWITCH_PENDING, &ctx->spu->flags))
304 out_be64(&priv2->mfc_control_RW, MFC_CNTL_RESTART_DMA_COMMAND);
305}
306
299struct spu_context_ops spu_hw_ops = { 307struct spu_context_ops spu_hw_ops = {
300 .mbox_read = spu_hw_mbox_read, 308 .mbox_read = spu_hw_mbox_read,
301 .mbox_stat_read = spu_hw_mbox_stat_read, 309 .mbox_stat_read = spu_hw_mbox_stat_read,
@@ -320,4 +328,5 @@ struct spu_context_ops spu_hw_ops = {
320 .read_mfc_tagstatus = spu_hw_read_mfc_tagstatus, 328 .read_mfc_tagstatus = spu_hw_read_mfc_tagstatus,
321 .get_mfc_free_elements = spu_hw_get_mfc_free_elements, 329 .get_mfc_free_elements = spu_hw_get_mfc_free_elements,
322 .send_mfc_command = spu_hw_send_mfc_command, 330 .send_mfc_command = spu_hw_send_mfc_command,
331 .restart_dma = spu_hw_restart_dma,
323}; 332};
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index 8079983ef94f..13e4f70ec8c0 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -36,6 +36,7 @@
36#include <asm/prom.h> 36#include <asm/prom.h>
37#include <asm/semaphore.h> 37#include <asm/semaphore.h>
38#include <asm/spu.h> 38#include <asm/spu.h>
39#include <asm/spu_priv1.h>
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
40 41
41#include "spufs.h" 42#include "spufs.h"
@@ -54,6 +55,7 @@ spufs_alloc_inode(struct super_block *sb)
54 55
55 ei->i_gang = NULL; 56 ei->i_gang = NULL;
56 ei->i_ctx = NULL; 57 ei->i_ctx = NULL;
58 ei->i_openers = 0;
57 59
58 return &ei->vfs_inode; 60 return &ei->vfs_inode;
59} 61}
@@ -520,13 +522,14 @@ out:
520 522
521/* File system initialization */ 523/* File system initialization */
522enum { 524enum {
523 Opt_uid, Opt_gid, Opt_err, 525 Opt_uid, Opt_gid, Opt_mode, Opt_err,
524}; 526};
525 527
526static match_table_t spufs_tokens = { 528static match_table_t spufs_tokens = {
527 { Opt_uid, "uid=%d" }, 529 { Opt_uid, "uid=%d" },
528 { Opt_gid, "gid=%d" }, 530 { Opt_gid, "gid=%d" },
529 { Opt_err, NULL }, 531 { Opt_mode, "mode=%o" },
532 { Opt_err, NULL },
530}; 533};
531 534
532static int 535static int
@@ -553,6 +556,11 @@ spufs_parse_options(char *options, struct inode *root)
553 return 0; 556 return 0;
554 root->i_gid = option; 557 root->i_gid = option;
555 break; 558 break;
559 case Opt_mode:
560 if (match_octal(&args[0], &option))
561 return 0;
562 root->i_mode = option | S_IFDIR;
563 break;
556 default: 564 default:
557 return 0; 565 return 0;
558 } 566 }
@@ -560,6 +568,11 @@ spufs_parse_options(char *options, struct inode *root)
560 return 1; 568 return 1;
561} 569}
562 570
571static void spufs_exit_isolated_loader(void)
572{
573 kfree(isolated_loader);
574}
575
563static void 576static void
564spufs_init_isolated_loader(void) 577spufs_init_isolated_loader(void)
565{ 578{
@@ -571,7 +584,7 @@ spufs_init_isolated_loader(void)
571 if (!dn) 584 if (!dn)
572 return; 585 return;
573 586
574 loader = get_property(dn, "loader", &size); 587 loader = of_get_property(dn, "loader", &size);
575 if (!loader) 588 if (!loader)
576 return; 589 return;
577 590
@@ -653,6 +666,10 @@ static int __init spufs_init(void)
653{ 666{
654 int ret; 667 int ret;
655 668
669 ret = -ENODEV;
670 if (!spu_management_ops)
671 goto out;
672
656 ret = -ENOMEM; 673 ret = -ENOMEM;
657 spufs_inode_cache = kmem_cache_create("spufs_inode_cache", 674 spufs_inode_cache = kmem_cache_create("spufs_inode_cache",
658 sizeof(struct spufs_inode_info), 0, 675 sizeof(struct spufs_inode_info), 0,
@@ -660,25 +677,29 @@ static int __init spufs_init(void)
660 677
661 if (!spufs_inode_cache) 678 if (!spufs_inode_cache)
662 goto out; 679 goto out;
663 if (spu_sched_init() != 0) { 680 ret = spu_sched_init();
664 kmem_cache_destroy(spufs_inode_cache);
665 goto out;
666 }
667 ret = register_filesystem(&spufs_type);
668 if (ret) 681 if (ret)
669 goto out_cache; 682 goto out_cache;
683 ret = register_filesystem(&spufs_type);
684 if (ret)
685 goto out_sched;
670 ret = register_spu_syscalls(&spufs_calls); 686 ret = register_spu_syscalls(&spufs_calls);
671 if (ret) 687 if (ret)
672 goto out_fs; 688 goto out_fs;
673 ret = register_arch_coredump_calls(&spufs_coredump_calls); 689 ret = register_arch_coredump_calls(&spufs_coredump_calls);
674 if (ret) 690 if (ret)
675 goto out_fs; 691 goto out_syscalls;
676 692
677 spufs_init_isolated_loader(); 693 spufs_init_isolated_loader();
678 694
679 return 0; 695 return 0;
696
697out_syscalls:
698 unregister_spu_syscalls(&spufs_calls);
680out_fs: 699out_fs:
681 unregister_filesystem(&spufs_type); 700 unregister_filesystem(&spufs_type);
701out_sched:
702 spu_sched_exit();
682out_cache: 703out_cache:
683 kmem_cache_destroy(spufs_inode_cache); 704 kmem_cache_destroy(spufs_inode_cache);
684out: 705out:
@@ -689,6 +710,7 @@ module_init(spufs_init);
689static void __exit spufs_exit(void) 710static void __exit spufs_exit(void)
690{ 711{
691 spu_sched_exit(); 712 spu_sched_exit();
713 spufs_exit_isolated_loader();
692 unregister_arch_coredump_calls(&spufs_coredump_calls); 714 unregister_arch_coredump_calls(&spufs_coredump_calls);
693 unregister_spu_syscalls(&spufs_calls); 715 unregister_spu_syscalls(&spufs_calls);
694 unregister_filesystem(&spufs_type); 716 unregister_filesystem(&spufs_type);
diff --git a/arch/powerpc/platforms/cell/spufs/run.c b/arch/powerpc/platforms/cell/spufs/run.c
index f95a611ca362..57626600b1a4 100644
--- a/arch/powerpc/platforms/cell/spufs/run.c
+++ b/arch/powerpc/platforms/cell/spufs/run.c
@@ -18,27 +18,6 @@ void spufs_stop_callback(struct spu *spu)
18 wake_up_all(&ctx->stop_wq); 18 wake_up_all(&ctx->stop_wq);
19} 19}
20 20
21void spufs_dma_callback(struct spu *spu, int type)
22{
23 struct spu_context *ctx = spu->ctx;
24
25 if (ctx->flags & SPU_CREATE_EVENTS_ENABLED) {
26 ctx->event_return |= type;
27 wake_up_all(&ctx->stop_wq);
28 } else {
29 switch (type) {
30 case SPE_EVENT_DMA_ALIGNMENT:
31 case SPE_EVENT_SPE_DATA_STORAGE:
32 case SPE_EVENT_INVALID_DMA:
33 force_sig(SIGBUS, /* info, */ current);
34 break;
35 case SPE_EVENT_SPE_ERROR:
36 force_sig(SIGILL, /* info */ current);
37 break;
38 }
39 }
40}
41
42static inline int spu_stopped(struct spu_context *ctx, u32 * stat) 21static inline int spu_stopped(struct spu_context *ctx, u32 * stat)
43{ 22{
44 struct spu *spu; 23 struct spu *spu;
@@ -63,13 +42,18 @@ static int spu_setup_isolated(struct spu_context *ctx)
63 const u32 status_loading = SPU_STATUS_RUNNING 42 const u32 status_loading = SPU_STATUS_RUNNING
64 | SPU_STATUS_ISOLATED_STATE | SPU_STATUS_ISOLATED_LOAD_STATUS; 43 | SPU_STATUS_ISOLATED_STATE | SPU_STATUS_ISOLATED_LOAD_STATUS;
65 44
45 ret = -ENODEV;
66 if (!isolated_loader) 46 if (!isolated_loader)
67 return -ENODEV;
68
69 ret = spu_acquire_exclusive(ctx);
70 if (ret)
71 goto out; 47 goto out;
72 48
49 /*
50 * We need to exclude userspace access to the context.
51 *
52 * To protect against memory access we invalidate all ptes
53 * and make sure the pagefault handlers block on the mutex.
54 */
55 spu_unmap_mappings(ctx);
56
73 mfc_cntl = &ctx->spu->priv2->mfc_control_RW; 57 mfc_cntl = &ctx->spu->priv2->mfc_control_RW;
74 58
75 /* purge the MFC DMA queue to ensure no spurious accesses before we 59 /* purge the MFC DMA queue to ensure no spurious accesses before we
@@ -82,7 +66,7 @@ static int spu_setup_isolated(struct spu_context *ctx)
82 printk(KERN_ERR "%s: timeout flushing MFC DMA queue\n", 66 printk(KERN_ERR "%s: timeout flushing MFC DMA queue\n",
83 __FUNCTION__); 67 __FUNCTION__);
84 ret = -EIO; 68 ret = -EIO;
85 goto out_unlock; 69 goto out;
86 } 70 }
87 cond_resched(); 71 cond_resched();
88 } 72 }
@@ -119,12 +103,15 @@ static int spu_setup_isolated(struct spu_context *ctx)
119 pr_debug("%s: isolated LOAD failed\n", __FUNCTION__); 103 pr_debug("%s: isolated LOAD failed\n", __FUNCTION__);
120 ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_RUNNABLE); 104 ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_RUNNABLE);
121 ret = -EACCES; 105 ret = -EACCES;
106 goto out_drop_priv;
107 }
122 108
123 } else if (!(status & SPU_STATUS_ISOLATED_STATE)) { 109 if (!(status & SPU_STATUS_ISOLATED_STATE)) {
124 /* This isn't allowed by the CBEA, but check anyway */ 110 /* This isn't allowed by the CBEA, but check anyway */
125 pr_debug("%s: SPU fell out of isolated mode?\n", __FUNCTION__); 111 pr_debug("%s: SPU fell out of isolated mode?\n", __FUNCTION__);
126 ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_STOP); 112 ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_STOP);
127 ret = -EINVAL; 113 ret = -EINVAL;
114 goto out_drop_priv;
128 } 115 }
129 116
130out_drop_priv: 117out_drop_priv:
@@ -132,30 +119,19 @@ out_drop_priv:
132 sr1 |= MFC_STATE1_PROBLEM_STATE_MASK; 119 sr1 |= MFC_STATE1_PROBLEM_STATE_MASK;
133 spu_mfc_sr1_set(ctx->spu, sr1); 120 spu_mfc_sr1_set(ctx->spu, sr1);
134 121
135out_unlock:
136 spu_release(ctx);
137out: 122out:
138 return ret; 123 return ret;
139} 124}
140 125
141static inline int spu_run_init(struct spu_context *ctx, u32 * npc) 126static int spu_run_init(struct spu_context *ctx, u32 * npc)
142{ 127{
143 int ret;
144 unsigned long runcntl = SPU_RUNCNTL_RUNNABLE;
145
146 ret = spu_acquire_runnable(ctx, 0);
147 if (ret)
148 return ret;
149
150 if (ctx->flags & SPU_CREATE_ISOLATE) { 128 if (ctx->flags & SPU_CREATE_ISOLATE) {
129 unsigned long runcntl;
130
151 if (!(ctx->ops->status_read(ctx) & SPU_STATUS_ISOLATED_STATE)) { 131 if (!(ctx->ops->status_read(ctx) & SPU_STATUS_ISOLATED_STATE)) {
152 /* Need to release ctx, because spu_setup_isolated will 132 int ret = spu_setup_isolated(ctx);
153 * acquire it exclusively. 133 if (ret)
154 */ 134 return ret;
155 spu_release(ctx);
156 ret = spu_setup_isolated(ctx);
157 if (!ret)
158 ret = spu_acquire_runnable(ctx, 0);
159 } 135 }
160 136
161 /* if userspace has set the runcntrl register (eg, to issue an 137 /* if userspace has set the runcntrl register (eg, to issue an
@@ -164,16 +140,17 @@ static inline int spu_run_init(struct spu_context *ctx, u32 * npc)
164 (SPU_RUNCNTL_RUNNABLE | SPU_RUNCNTL_ISOLATE); 140 (SPU_RUNCNTL_RUNNABLE | SPU_RUNCNTL_ISOLATE);
165 if (runcntl == 0) 141 if (runcntl == 0)
166 runcntl = SPU_RUNCNTL_RUNNABLE; 142 runcntl = SPU_RUNCNTL_RUNNABLE;
143 ctx->ops->runcntl_write(ctx, runcntl);
167 } else { 144 } else {
168 spu_start_tick(ctx); 145 spu_start_tick(ctx);
169 ctx->ops->npc_write(ctx, *npc); 146 ctx->ops->npc_write(ctx, *npc);
147 ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_RUNNABLE);
170 } 148 }
171 149
172 ctx->ops->runcntl_write(ctx, runcntl); 150 return 0;
173 return ret;
174} 151}
175 152
176static inline int spu_run_fini(struct spu_context *ctx, u32 * npc, 153static int spu_run_fini(struct spu_context *ctx, u32 * npc,
177 u32 * status) 154 u32 * status)
178{ 155{
179 int ret = 0; 156 int ret = 0;
@@ -189,19 +166,27 @@ static inline int spu_run_fini(struct spu_context *ctx, u32 * npc,
189 return ret; 166 return ret;
190} 167}
191 168
192static inline int spu_reacquire_runnable(struct spu_context *ctx, u32 *npc, 169static int spu_reacquire_runnable(struct spu_context *ctx, u32 *npc,
193 u32 *status) 170 u32 *status)
194{ 171{
195 int ret; 172 int ret;
196 173
197 if ((ret = spu_run_fini(ctx, npc, status)) != 0) 174 ret = spu_run_fini(ctx, npc, status);
175 if (ret)
198 return ret; 176 return ret;
199 if (*status & (SPU_STATUS_STOPPED_BY_STOP | 177
200 SPU_STATUS_STOPPED_BY_HALT)) { 178 if (*status & (SPU_STATUS_STOPPED_BY_STOP | SPU_STATUS_STOPPED_BY_HALT))
201 return *status; 179 return *status;
202 } 180
203 if ((ret = spu_run_init(ctx, npc)) != 0) 181 ret = spu_acquire_runnable(ctx, 0);
182 if (ret)
183 return ret;
184
185 ret = spu_run_init(ctx, npc);
186 if (ret) {
187 spu_release(ctx);
204 return ret; 188 return ret;
189 }
205 return 0; 190 return 0;
206} 191}
207 192
@@ -253,17 +238,17 @@ int spu_process_callback(struct spu_context *ctx)
253{ 238{
254 struct spu_syscall_block s; 239 struct spu_syscall_block s;
255 u32 ls_pointer, npc; 240 u32 ls_pointer, npc;
256 char *ls; 241 void __iomem *ls;
257 long spu_ret; 242 long spu_ret;
258 int ret; 243 int ret;
259 244
260 /* get syscall block from local store */ 245 /* get syscall block from local store */
261 npc = ctx->ops->npc_read(ctx); 246 npc = ctx->ops->npc_read(ctx) & ~3;
262 ls = ctx->ops->get_ls(ctx); 247 ls = (void __iomem *)ctx->ops->get_ls(ctx);
263 ls_pointer = *(u32*)(ls + npc); 248 ls_pointer = in_be32(ls + npc);
264 if (ls_pointer > (LS_SIZE - sizeof(s))) 249 if (ls_pointer > (LS_SIZE - sizeof(s)))
265 return -EFAULT; 250 return -EFAULT;
266 memcpy(&s, ls + ls_pointer, sizeof (s)); 251 memcpy_fromio(&s, ls + ls_pointer, sizeof(s));
267 252
268 /* do actual syscall without pinning the spu */ 253 /* do actual syscall without pinning the spu */
269 ret = 0; 254 ret = 0;
@@ -283,7 +268,7 @@ int spu_process_callback(struct spu_context *ctx)
283 } 268 }
284 269
285 /* write result, jump over indirect pointer */ 270 /* write result, jump over indirect pointer */
286 memcpy(ls + ls_pointer, &spu_ret, sizeof (spu_ret)); 271 memcpy_toio(ls + ls_pointer, &spu_ret, sizeof(spu_ret));
287 ctx->ops->npc_write(ctx, npc); 272 ctx->ops->npc_write(ctx, npc);
288 ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_RUNNABLE); 273 ctx->ops->runcntl_write(ctx, SPU_RUNCNTL_RUNNABLE);
289 return ret; 274 return ret;
@@ -292,11 +277,8 @@ int spu_process_callback(struct spu_context *ctx)
292static inline int spu_process_events(struct spu_context *ctx) 277static inline int spu_process_events(struct spu_context *ctx)
293{ 278{
294 struct spu *spu = ctx->spu; 279 struct spu *spu = ctx->spu;
295 u64 pte_fault = MFC_DSISR_PTE_NOT_FOUND | MFC_DSISR_ACCESS_DENIED;
296 int ret = 0; 280 int ret = 0;
297 281
298 if (spu->dsisr & pte_fault)
299 ret = spu_irq_class_1_bottom(spu);
300 if (spu->class_0_pending) 282 if (spu->class_0_pending)
301 ret = spu_irq_class_0_bottom(spu); 283 ret = spu_irq_class_0_bottom(spu);
302 if (!ret && signal_pending(current)) 284 if (!ret && signal_pending(current))
@@ -310,14 +292,21 @@ long spufs_run_spu(struct file *file, struct spu_context *ctx,
310 int ret; 292 int ret;
311 u32 status; 293 u32 status;
312 294
313 if (down_interruptible(&ctx->run_sema)) 295 if (mutex_lock_interruptible(&ctx->run_mutex))
314 return -ERESTARTSYS; 296 return -ERESTARTSYS;
315 297
316 ctx->ops->master_start(ctx); 298 ctx->ops->master_start(ctx);
317 ctx->event_return = 0; 299 ctx->event_return = 0;
318 ret = spu_run_init(ctx, npc); 300
301 ret = spu_acquire_runnable(ctx, 0);
319 if (ret) 302 if (ret)
303 return ret;
304
305 ret = spu_run_init(ctx, npc);
306 if (ret) {
307 spu_release(ctx);
320 goto out; 308 goto out;
309 }
321 310
322 do { 311 do {
323 ret = spufs_wait(ctx->stop_wq, spu_stopped(ctx, &status)); 312 ret = spufs_wait(ctx->stop_wq, spu_stopped(ctx, &status));
@@ -330,6 +319,10 @@ long spufs_run_spu(struct file *file, struct spu_context *ctx,
330 break; 319 break;
331 status &= ~SPU_STATUS_STOPPED_BY_STOP; 320 status &= ~SPU_STATUS_STOPPED_BY_STOP;
332 } 321 }
322 ret = spufs_handle_class1(ctx);
323 if (ret)
324 break;
325
333 if (unlikely(ctx->state != SPU_STATE_RUNNABLE)) { 326 if (unlikely(ctx->state != SPU_STATE_RUNNABLE)) {
334 ret = spu_reacquire_runnable(ctx, npc, &status); 327 ret = spu_reacquire_runnable(ctx, npc, &status);
335 if (ret) { 328 if (ret) {
@@ -363,6 +356,6 @@ out2:
363 356
364out: 357out:
365 *event = ctx->event_return; 358 *event = ctx->event_return;
366 up(&ctx->run_sema); 359 mutex_unlock(&ctx->run_mutex);
367 return ret; 360 return ret;
368} 361}
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index 39823cec0844..91030b8abdca 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -71,14 +71,27 @@ static inline int node_allowed(int node)
71 71
72void spu_start_tick(struct spu_context *ctx) 72void spu_start_tick(struct spu_context *ctx)
73{ 73{
74 if (ctx->policy == SCHED_RR) 74 if (ctx->policy == SCHED_RR) {
75 /*
76 * Make sure the exiting bit is cleared.
77 */
78 clear_bit(SPU_SCHED_EXITING, &ctx->sched_flags);
79 mb();
75 queue_delayed_work(spu_sched_wq, &ctx->sched_work, SPU_TIMESLICE); 80 queue_delayed_work(spu_sched_wq, &ctx->sched_work, SPU_TIMESLICE);
81 }
76} 82}
77 83
78void spu_stop_tick(struct spu_context *ctx) 84void spu_stop_tick(struct spu_context *ctx)
79{ 85{
80 if (ctx->policy == SCHED_RR) 86 if (ctx->policy == SCHED_RR) {
87 /*
88 * While the work can be rearming normally setting this flag
89 * makes sure it does not rearm itself anymore.
90 */
91 set_bit(SPU_SCHED_EXITING, &ctx->sched_flags);
92 mb();
81 cancel_delayed_work(&ctx->sched_work); 93 cancel_delayed_work(&ctx->sched_work);
94 }
82} 95}
83 96
84void spu_sched_tick(struct work_struct *work) 97void spu_sched_tick(struct work_struct *work)
@@ -86,7 +99,15 @@ void spu_sched_tick(struct work_struct *work)
86 struct spu_context *ctx = 99 struct spu_context *ctx =
87 container_of(work, struct spu_context, sched_work.work); 100 container_of(work, struct spu_context, sched_work.work);
88 struct spu *spu; 101 struct spu *spu;
89 int rearm = 1; 102 int preempted = 0;
103
104 /*
105 * If this context is being stopped avoid rescheduling from the
106 * scheduler tick because we would block on the state_mutex.
107 * The caller will yield the spu later on anyway.
108 */
109 if (test_bit(SPU_SCHED_EXITING, &ctx->sched_flags))
110 return;
90 111
91 mutex_lock(&ctx->state_mutex); 112 mutex_lock(&ctx->state_mutex);
92 spu = ctx->spu; 113 spu = ctx->spu;
@@ -94,12 +115,19 @@ void spu_sched_tick(struct work_struct *work)
94 int best = sched_find_first_bit(spu_prio->bitmap); 115 int best = sched_find_first_bit(spu_prio->bitmap);
95 if (best <= ctx->prio) { 116 if (best <= ctx->prio) {
96 spu_deactivate(ctx); 117 spu_deactivate(ctx);
97 rearm = 0; 118 preempted = 1;
98 } 119 }
99 } 120 }
100 mutex_unlock(&ctx->state_mutex); 121 mutex_unlock(&ctx->state_mutex);
101 122
102 if (rearm) 123 if (preempted) {
124 /*
125 * We need to break out of the wait loop in spu_run manually
126 * to ensure this context gets put on the runqueue again
127 * ASAP.
128 */
129 wake_up(&ctx->stop_wq);
130 } else
103 spu_start_tick(ctx); 131 spu_start_tick(ctx);
104} 132}
105 133
@@ -208,58 +236,40 @@ static void spu_unbind_context(struct spu *spu, struct spu_context *ctx)
208 * spu_add_to_rq - add a context to the runqueue 236 * spu_add_to_rq - add a context to the runqueue
209 * @ctx: context to add 237 * @ctx: context to add
210 */ 238 */
211static void spu_add_to_rq(struct spu_context *ctx) 239static void __spu_add_to_rq(struct spu_context *ctx)
212{ 240{
213 spin_lock(&spu_prio->runq_lock); 241 int prio = ctx->prio;
214 list_add_tail(&ctx->rq, &spu_prio->runq[ctx->prio]);
215 set_bit(ctx->prio, spu_prio->bitmap);
216 spin_unlock(&spu_prio->runq_lock);
217}
218 242
219/** 243 list_add_tail(&ctx->rq, &spu_prio->runq[prio]);
220 * spu_del_from_rq - remove a context from the runqueue 244 set_bit(prio, spu_prio->bitmap);
221 * @ctx: context to remove
222 */
223static void spu_del_from_rq(struct spu_context *ctx)
224{
225 spin_lock(&spu_prio->runq_lock);
226 list_del_init(&ctx->rq);
227 if (list_empty(&spu_prio->runq[ctx->prio]))
228 clear_bit(ctx->prio, spu_prio->bitmap);
229 spin_unlock(&spu_prio->runq_lock);
230} 245}
231 246
232/** 247static void __spu_del_from_rq(struct spu_context *ctx)
233 * spu_grab_context - remove one context from the runqueue
234 * @prio: priority of the context to be removed
235 *
236 * This function removes one context from the runqueue for priority @prio.
237 * If there is more than one context with the given priority the first
238 * task on the runqueue will be taken.
239 *
240 * Returns the spu_context it just removed.
241 *
242 * Must be called with spu_prio->runq_lock held.
243 */
244static struct spu_context *spu_grab_context(int prio)
245{ 248{
246 struct list_head *rq = &spu_prio->runq[prio]; 249 int prio = ctx->prio;
247 250
248 if (list_empty(rq)) 251 if (!list_empty(&ctx->rq))
249 return NULL; 252 list_del_init(&ctx->rq);
250 return list_entry(rq->next, struct spu_context, rq); 253 if (list_empty(&spu_prio->runq[prio]))
254 clear_bit(prio, spu_prio->bitmap);
251} 255}
252 256
253static void spu_prio_wait(struct spu_context *ctx) 257static void spu_prio_wait(struct spu_context *ctx)
254{ 258{
255 DEFINE_WAIT(wait); 259 DEFINE_WAIT(wait);
256 260
261 spin_lock(&spu_prio->runq_lock);
257 prepare_to_wait_exclusive(&ctx->stop_wq, &wait, TASK_INTERRUPTIBLE); 262 prepare_to_wait_exclusive(&ctx->stop_wq, &wait, TASK_INTERRUPTIBLE);
258 if (!signal_pending(current)) { 263 if (!signal_pending(current)) {
264 __spu_add_to_rq(ctx);
265 spin_unlock(&spu_prio->runq_lock);
259 mutex_unlock(&ctx->state_mutex); 266 mutex_unlock(&ctx->state_mutex);
260 schedule(); 267 schedule();
261 mutex_lock(&ctx->state_mutex); 268 mutex_lock(&ctx->state_mutex);
269 spin_lock(&spu_prio->runq_lock);
270 __spu_del_from_rq(ctx);
262 } 271 }
272 spin_unlock(&spu_prio->runq_lock);
263 __set_current_state(TASK_RUNNING); 273 __set_current_state(TASK_RUNNING);
264 remove_wait_queue(&ctx->stop_wq, &wait); 274 remove_wait_queue(&ctx->stop_wq, &wait);
265} 275}
@@ -280,9 +290,14 @@ static void spu_reschedule(struct spu *spu)
280 spin_lock(&spu_prio->runq_lock); 290 spin_lock(&spu_prio->runq_lock);
281 best = sched_find_first_bit(spu_prio->bitmap); 291 best = sched_find_first_bit(spu_prio->bitmap);
282 if (best < MAX_PRIO) { 292 if (best < MAX_PRIO) {
283 struct spu_context *ctx = spu_grab_context(best); 293 struct list_head *rq = &spu_prio->runq[best];
284 if (ctx) 294 struct spu_context *ctx;
285 wake_up(&ctx->stop_wq); 295
296 BUG_ON(list_empty(rq));
297
298 ctx = list_entry(rq->next, struct spu_context, rq);
299 __spu_del_from_rq(ctx);
300 wake_up(&ctx->stop_wq);
286 } 301 }
287 spin_unlock(&spu_prio->runq_lock); 302 spin_unlock(&spu_prio->runq_lock);
288} 303}
@@ -365,6 +380,12 @@ static struct spu *find_victim(struct spu_context *ctx)
365 } 380 }
366 spu_unbind_context(spu, victim); 381 spu_unbind_context(spu, victim);
367 mutex_unlock(&victim->state_mutex); 382 mutex_unlock(&victim->state_mutex);
383 /*
384 * We need to break out of the wait loop in spu_run
385 * manually to ensure this context gets put on the
386 * runqueue again ASAP.
387 */
388 wake_up(&victim->stop_wq);
368 return spu; 389 return spu;
369 } 390 }
370 } 391 }
@@ -377,7 +398,7 @@ static struct spu *find_victim(struct spu_context *ctx)
377 * @ctx: spu context to schedule 398 * @ctx: spu context to schedule
378 * @flags: flags (currently ignored) 399 * @flags: flags (currently ignored)
379 * 400 *
380 * Tries to find a free spu to run @ctx. If no free spu is availble 401 * Tries to find a free spu to run @ctx. If no free spu is available
381 * add the context to the runqueue so it gets woken up once an spu 402 * add the context to the runqueue so it gets woken up once an spu
382 * is available. 403 * is available.
383 */ 404 */
@@ -402,9 +423,7 @@ int spu_activate(struct spu_context *ctx, unsigned long flags)
402 return 0; 423 return 0;
403 } 424 }
404 425
405 spu_add_to_rq(ctx);
406 spu_prio_wait(ctx); 426 spu_prio_wait(ctx);
407 spu_del_from_rq(ctx);
408 } while (!signal_pending(current)); 427 } while (!signal_pending(current));
409 428
410 return -ERESTARTSYS; 429 return -ERESTARTSYS;
@@ -438,7 +457,6 @@ void spu_deactivate(struct spu_context *ctx)
438void spu_yield(struct spu_context *ctx) 457void spu_yield(struct spu_context *ctx)
439{ 458{
440 struct spu *spu; 459 struct spu *spu;
441 int need_yield = 0;
442 460
443 if (mutex_trylock(&ctx->state_mutex)) { 461 if (mutex_trylock(&ctx->state_mutex)) {
444 if ((spu = ctx->spu) != NULL) { 462 if ((spu = ctx->spu) != NULL) {
@@ -447,13 +465,10 @@ void spu_yield(struct spu_context *ctx)
447 pr_debug("%s: yielding SPU %d NODE %d\n", 465 pr_debug("%s: yielding SPU %d NODE %d\n",
448 __FUNCTION__, spu->number, spu->node); 466 __FUNCTION__, spu->number, spu->node);
449 spu_deactivate(ctx); 467 spu_deactivate(ctx);
450 need_yield = 1;
451 } 468 }
452 } 469 }
453 mutex_unlock(&ctx->state_mutex); 470 mutex_unlock(&ctx->state_mutex);
454 } 471 }
455 if (unlikely(need_yield))
456 yield();
457} 472}
458 473
459int __init spu_sched_init(void) 474int __init spu_sched_init(void)
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h
index 5c4e47d69d79..0a947fd7de57 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -41,7 +41,7 @@ struct spu_gang;
41 41
42/* ctx->sched_flags */ 42/* ctx->sched_flags */
43enum { 43enum {
44 SPU_SCHED_WAKE = 0, /* currently unused */ 44 SPU_SCHED_EXITING = 0,
45}; 45};
46 46
47struct spu_context { 47struct spu_context {
@@ -50,16 +50,17 @@ struct spu_context {
50 spinlock_t mmio_lock; /* protects mmio access */ 50 spinlock_t mmio_lock; /* protects mmio access */
51 struct address_space *local_store; /* local store mapping. */ 51 struct address_space *local_store; /* local store mapping. */
52 struct address_space *mfc; /* 'mfc' area mappings. */ 52 struct address_space *mfc; /* 'mfc' area mappings. */
53 struct address_space *cntl; /* 'control' area mappings. */ 53 struct address_space *cntl; /* 'control' area mappings. */
54 struct address_space *signal1; /* 'signal1' area mappings. */ 54 struct address_space *signal1; /* 'signal1' area mappings. */
55 struct address_space *signal2; /* 'signal2' area mappings. */ 55 struct address_space *signal2; /* 'signal2' area mappings. */
56 struct address_space *mss; /* 'mss' area mappings. */ 56 struct address_space *mss; /* 'mss' area mappings. */
57 struct address_space *psmap; /* 'psmap' area mappings. */ 57 struct address_space *psmap; /* 'psmap' area mappings. */
58 spinlock_t mapping_lock;
58 u64 object_id; /* user space pointer for oprofile */ 59 u64 object_id; /* user space pointer for oprofile */
59 60
60 enum { SPU_STATE_RUNNABLE, SPU_STATE_SAVED } state; 61 enum { SPU_STATE_RUNNABLE, SPU_STATE_SAVED } state;
61 struct mutex state_mutex; 62 struct mutex state_mutex;
62 struct semaphore run_sema; 63 struct mutex run_mutex;
63 64
64 struct mm_struct *owner; 65 struct mm_struct *owner;
65 66
@@ -140,6 +141,7 @@ struct spu_context_ops {
140 struct spu_dma_info * info); 141 struct spu_dma_info * info);
141 void (*proxydma_info_read) (struct spu_context * ctx, 142 void (*proxydma_info_read) (struct spu_context * ctx,
142 struct spu_proxydma_info * info); 143 struct spu_proxydma_info * info);
144 void (*restart_dma)(struct spu_context *ctx);
143}; 145};
144 146
145extern struct spu_context_ops spu_hw_ops; 147extern struct spu_context_ops spu_hw_ops;
@@ -149,6 +151,7 @@ struct spufs_inode_info {
149 struct spu_context *i_ctx; 151 struct spu_context *i_ctx;
150 struct spu_gang *i_gang; 152 struct spu_gang *i_gang;
151 struct inode vfs_inode; 153 struct inode vfs_inode;
154 int i_openers;
152}; 155};
153#define SPUFS_I(inode) \ 156#define SPUFS_I(inode) \
154 container_of(inode, struct spufs_inode_info, vfs_inode) 157 container_of(inode, struct spufs_inode_info, vfs_inode)
@@ -170,6 +173,9 @@ int put_spu_gang(struct spu_gang *gang);
170void spu_gang_remove_ctx(struct spu_gang *gang, struct spu_context *ctx); 173void spu_gang_remove_ctx(struct spu_gang *gang, struct spu_context *ctx);
171void spu_gang_add_ctx(struct spu_gang *gang, struct spu_context *ctx); 174void spu_gang_add_ctx(struct spu_gang *gang, struct spu_context *ctx);
172 175
176/* fault handling */
177int spufs_handle_class1(struct spu_context *ctx);
178
173/* context management */ 179/* context management */
174static inline void spu_acquire(struct spu_context *ctx) 180static inline void spu_acquire(struct spu_context *ctx)
175{ 181{
@@ -190,7 +196,6 @@ void spu_unmap_mappings(struct spu_context *ctx);
190void spu_forget(struct spu_context *ctx); 196void spu_forget(struct spu_context *ctx);
191int spu_acquire_runnable(struct spu_context *ctx, unsigned long flags); 197int spu_acquire_runnable(struct spu_context *ctx, unsigned long flags);
192void spu_acquire_saved(struct spu_context *ctx); 198void spu_acquire_saved(struct spu_context *ctx);
193int spu_acquire_exclusive(struct spu_context *ctx);
194 199
195int spu_activate(struct spu_context *ctx, unsigned long flags); 200int spu_activate(struct spu_context *ctx, unsigned long flags);
196void spu_deactivate(struct spu_context *ctx); 201void spu_deactivate(struct spu_context *ctx);
@@ -218,14 +223,13 @@ extern char *isolated_loader;
218 prepare_to_wait(&(wq), &__wait, TASK_INTERRUPTIBLE); \ 223 prepare_to_wait(&(wq), &__wait, TASK_INTERRUPTIBLE); \
219 if (condition) \ 224 if (condition) \
220 break; \ 225 break; \
221 if (!signal_pending(current)) { \ 226 if (signal_pending(current)) { \
222 spu_release(ctx); \ 227 __ret = -ERESTARTSYS; \
223 schedule(); \ 228 break; \
224 spu_acquire(ctx); \
225 continue; \
226 } \ 229 } \
227 __ret = -ERESTARTSYS; \ 230 spu_release(ctx); \
228 break; \ 231 schedule(); \
232 spu_acquire(ctx); \
229 } \ 233 } \
230 finish_wait(&(wq), &__wait); \ 234 finish_wait(&(wq), &__wait); \
231 __ret; \ 235 __ret; \
diff --git a/arch/powerpc/platforms/cell/spufs/switch.c b/arch/powerpc/platforms/cell/spufs/switch.c
index fd91c73de34e..8347c4a3f894 100644
--- a/arch/powerpc/platforms/cell/spufs/switch.c
+++ b/arch/powerpc/platforms/cell/spufs/switch.c
@@ -2084,6 +2084,10 @@ int spu_save(struct spu_state *prev, struct spu *spu)
2084 int rc; 2084 int rc;
2085 2085
2086 acquire_spu_lock(spu); /* Step 1. */ 2086 acquire_spu_lock(spu); /* Step 1. */
2087 prev->dar = spu->dar;
2088 prev->dsisr = spu->dsisr;
2089 spu->dar = 0;
2090 spu->dsisr = 0;
2087 rc = __do_spu_save(prev, spu); /* Steps 2-53. */ 2091 rc = __do_spu_save(prev, spu); /* Steps 2-53. */
2088 release_spu_lock(spu); 2092 release_spu_lock(spu);
2089 if (rc != 0 && rc != 2 && rc != 6) { 2093 if (rc != 0 && rc != 2 && rc != 6) {
@@ -2109,9 +2113,9 @@ int spu_restore(struct spu_state *new, struct spu *spu)
2109 2113
2110 acquire_spu_lock(spu); 2114 acquire_spu_lock(spu);
2111 harvest(NULL, spu); 2115 harvest(NULL, spu);
2112 spu->dar = 0;
2113 spu->dsisr = 0;
2114 spu->slb_replace = 0; 2116 spu->slb_replace = 0;
2117 new->dar = 0;
2118 new->dsisr = 0;
2115 spu->class_0_pending = 0; 2119 spu->class_0_pending = 0;
2116 rc = __do_spu_restore(new, spu); 2120 rc = __do_spu_restore(new, spu);
2117 release_spu_lock(spu); 2121 release_spu_lock(spu);
diff --git a/arch/powerpc/platforms/celleb/Kconfig b/arch/powerpc/platforms/celleb/Kconfig
new file mode 100644
index 000000000000..2db1e293433e
--- /dev/null
+++ b/arch/powerpc/platforms/celleb/Kconfig
@@ -0,0 +1,9 @@
1config PPC_CELLEB
2 bool "Toshiba's Cell Reference Set 'Celleb' Architecture"
3 depends on PPC_MULTIPLATFORM && PPC64
4 select PPC_CELL
5 select PPC_OF_PLATFORM_PCI
6 select HAS_TXX9_SERIAL
7 select PPC_UDBG_BEAT
8 select USB_OHCI_BIG_ENDIAN_MMIO
9 select USB_EHCI_BIG_ENDIAN_MMIO
diff --git a/arch/powerpc/platforms/celleb/iommu.c b/arch/powerpc/platforms/celleb/iommu.c
index f63b94c65353..755d869d8553 100644
--- a/arch/powerpc/platforms/celleb/iommu.c
+++ b/arch/powerpc/platforms/celleb/iommu.c
@@ -37,7 +37,7 @@ static int __init find_dma_window(u64 *io_space_id, u64 *ioid,
37 const unsigned long *dma_window; 37 const unsigned long *dma_window;
38 38
39 for_each_node_by_type(dn, "ioif") { 39 for_each_node_by_type(dn, "ioif") {
40 dma_window = get_property(dn, "toshiba,dma-window", NULL); 40 dma_window = of_get_property(dn, "toshiba,dma-window", NULL);
41 if (dma_window) { 41 if (dma_window) {
42 *io_space_id = (dma_window[0] >> 32) & 0xffffffffUL; 42 *io_space_id = (dma_window[0] >> 32) & 0xffffffffUL;
43 *ioid = dma_window[0] & 0x7ffUL; 43 *ioid = dma_window[0] & 0x7ffUL;
@@ -80,7 +80,7 @@ static int celleb_of_bus_notify(struct notifier_block *nb,
80 if (action != BUS_NOTIFY_ADD_DEVICE) 80 if (action != BUS_NOTIFY_ADD_DEVICE)
81 return 0; 81 return 0;
82 82
83 dev->archdata.dma_ops = pci_dma_ops; 83 dev->archdata.dma_ops = get_pci_dma_ops();
84 84
85 return 0; 85 return 0;
86} 86}
@@ -95,7 +95,7 @@ static int __init celleb_init_iommu(void)
95 return -ENODEV; 95 return -ENODEV;
96 96
97 celleb_init_direct_mapping(); 97 celleb_init_direct_mapping();
98 pci_dma_ops = &dma_direct_ops; 98 set_pci_dma_ops(&dma_direct_ops);
99 bus_register_notifier(&of_platform_bus_type, &celleb_of_bus_notifier); 99 bus_register_notifier(&of_platform_bus_type, &celleb_of_bus_notifier);
100 100
101 return 0; 101 return 0;
diff --git a/arch/powerpc/platforms/celleb/pci.c b/arch/powerpc/platforms/celleb/pci.c
index 98de836dfed3..d1adf34cd5e8 100644
--- a/arch/powerpc/platforms/celleb/pci.c
+++ b/arch/powerpc/platforms/celleb/pci.c
@@ -309,13 +309,13 @@ static int __devinit celleb_setup_fake_pci_device(struct device_node *node,
309 goto error; 309 goto error;
310 } 310 }
311 311
312 name = get_property(node, "model", &rlen); 312 name = of_get_property(node, "model", &rlen);
313 if (!name) { 313 if (!name) {
314 printk(KERN_ERR "PCI: model property not found.\n"); 314 printk(KERN_ERR "PCI: model property not found.\n");
315 goto error; 315 goto error;
316 } 316 }
317 317
318 wi4 = get_property(node, "reg", &rlen); 318 wi4 = of_get_property(node, "reg", &rlen);
319 if (wi4 == NULL) 319 if (wi4 == NULL)
320 goto error; 320 goto error;
321 321
@@ -352,10 +352,10 @@ static int __devinit celleb_setup_fake_pci_device(struct device_node *node,
352 } 352 }
353 pr_debug("PCI: res assigned 0x%016lx\n", (unsigned long)*res); 353 pr_debug("PCI: res assigned 0x%016lx\n", (unsigned long)*res);
354 354
355 wi0 = get_property(node, "device-id", NULL); 355 wi0 = of_get_property(node, "device-id", NULL);
356 wi1 = get_property(node, "vendor-id", NULL); 356 wi1 = of_get_property(node, "vendor-id", NULL);
357 wi2 = get_property(node, "class-code", NULL); 357 wi2 = of_get_property(node, "class-code", NULL);
358 wi3 = get_property(node, "revision-id", NULL); 358 wi3 = of_get_property(node, "revision-id", NULL);
359 359
360 celleb_config_write_fake(*config, PCI_DEVICE_ID, 2, wi0[0] & 0xffff); 360 celleb_config_write_fake(*config, PCI_DEVICE_ID, 2, wi0[0] & 0xffff);
361 celleb_config_write_fake(*config, PCI_VENDOR_ID, 2, wi1[0] & 0xffff); 361 celleb_config_write_fake(*config, PCI_VENDOR_ID, 2, wi1[0] & 0xffff);
@@ -376,7 +376,7 @@ static int __devinit celleb_setup_fake_pci_device(struct device_node *node,
376 376
377 celleb_setup_pci_base_addrs(hose, devno, fn, num_base_addr); 377 celleb_setup_pci_base_addrs(hose, devno, fn, num_base_addr);
378 378
379 li = get_property(node, "interrupts", &rlen); 379 li = of_get_property(node, "interrupts", &rlen);
380 val = li[0]; 380 val = li[0];
381 celleb_config_write_fake(*config, PCI_INTERRUPT_PIN, 1, 1); 381 celleb_config_write_fake(*config, PCI_INTERRUPT_PIN, 1, 1);
382 celleb_config_write_fake(*config, PCI_INTERRUPT_LINE, 1, val); 382 celleb_config_write_fake(*config, PCI_INTERRUPT_LINE, 1, val);
@@ -424,7 +424,7 @@ static int __devinit phb_set_bus_ranges(struct device_node *dev,
424 const int *bus_range; 424 const int *bus_range;
425 unsigned int len; 425 unsigned int len;
426 426
427 bus_range = get_property(dev, "bus-range", &len); 427 bus_range = of_get_property(dev, "bus-range", &len);
428 if (bus_range == NULL || len < 2 * sizeof(int)) 428 if (bus_range == NULL || len < 2 * sizeof(int))
429 return 1; 429 return 1;
430 430
@@ -451,7 +451,7 @@ int __devinit celleb_setup_phb(struct pci_controller *phb)
451 struct device_node *node; 451 struct device_node *node;
452 unsigned int rlen; 452 unsigned int rlen;
453 453
454 name = get_property(dev, "name", &rlen); 454 name = of_get_property(dev, "name", &rlen);
455 if (!name) 455 if (!name)
456 return 1; 456 return 1;
457 457
diff --git a/arch/powerpc/platforms/celleb/setup.c b/arch/powerpc/platforms/celleb/setup.c
index 5f4d0d933238..596ab2a788d4 100644
--- a/arch/powerpc/platforms/celleb/setup.c
+++ b/arch/powerpc/platforms/celleb/setup.c
@@ -67,7 +67,7 @@ static void celleb_show_cpuinfo(struct seq_file *m)
67 67
68 root = of_find_node_by_path("/"); 68 root = of_find_node_by_path("/");
69 if (root) 69 if (root)
70 model = get_property(root, "model", NULL); 70 model = of_get_property(root, "model", NULL);
71 /* using "CHRP" is to trick anaconda into installing FCx into Celleb */ 71 /* using "CHRP" is to trick anaconda into installing FCx into Celleb */
72 seq_printf(m, "machine\t\t: %s %s\n", celleb_machine_type, model); 72 seq_printf(m, "machine\t\t: %s %s\n", celleb_machine_type, model);
73 of_node_put(root); 73 of_node_put(root);
@@ -128,15 +128,6 @@ static int __init celleb_probe(void)
128 return 1; 128 return 1;
129} 129}
130 130
131/*
132 * Cell has no legacy IO; anything calling this function has to
133 * fail or bad things will happen
134 */
135static int celleb_check_legacy_ioport(unsigned int baseport)
136{
137 return -ENODEV;
138}
139
140#ifdef CONFIG_KEXEC 131#ifdef CONFIG_KEXEC
141static void celleb_kexec_cpu_down(int crash, int secondary) 132static void celleb_kexec_cpu_down(int crash, int secondary)
142{ 133{
@@ -173,7 +164,6 @@ define_machine(celleb) {
173 .get_rtc_time = beat_get_rtc_time, 164 .get_rtc_time = beat_get_rtc_time,
174 .set_rtc_time = beat_set_rtc_time, 165 .set_rtc_time = beat_set_rtc_time,
175 .calibrate_decr = generic_calibrate_decr, 166 .calibrate_decr = generic_calibrate_decr,
176 .check_legacy_ioport = celleb_check_legacy_ioport,
177 .progress = celleb_progress, 167 .progress = celleb_progress,
178 .power_save = beat_power_save, 168 .power_save = beat_power_save,
179 .nvram_size = beat_nvram_get_size, 169 .nvram_size = beat_nvram_get_size,
diff --git a/arch/powerpc/platforms/chrp/Kconfig b/arch/powerpc/platforms/chrp/Kconfig
new file mode 100644
index 000000000000..d2c690531963
--- /dev/null
+++ b/arch/powerpc/platforms/chrp/Kconfig
@@ -0,0 +1,11 @@
1config PPC_CHRP
2 bool "Common Hardware Reference Platform (CHRP) based machines"
3 depends on PPC_MULTIPLATFORM && PPC32
4 select MPIC
5 select PPC_I8259
6 select PPC_INDIRECT_PCI
7 select PPC_RTAS
8 select PPC_MPC106
9 select PPC_UDBG_16550
10 select PPC_NATIVE
11 default y
diff --git a/arch/powerpc/platforms/chrp/nvram.c b/arch/powerpc/platforms/chrp/nvram.c
index 0dd4a64757d9..8efd4244701c 100644
--- a/arch/powerpc/platforms/chrp/nvram.c
+++ b/arch/powerpc/platforms/chrp/nvram.c
@@ -74,7 +74,7 @@ void __init chrp_nvram_init(void)
74 if (nvram == NULL) 74 if (nvram == NULL)
75 return; 75 return;
76 76
77 nbytes_p = get_property(nvram, "#bytes", &proplen); 77 nbytes_p = of_get_property(nvram, "#bytes", &proplen);
78 if (nbytes_p == NULL || proplen != sizeof(unsigned int)) 78 if (nbytes_p == NULL || proplen != sizeof(unsigned int))
79 return; 79 return;
80 80
diff --git a/arch/powerpc/platforms/chrp/pci.c b/arch/powerpc/platforms/chrp/pci.c
index ddb4a116ea89..1469d6478f67 100644
--- a/arch/powerpc/platforms/chrp/pci.c
+++ b/arch/powerpc/platforms/chrp/pci.c
@@ -7,7 +7,6 @@
7#include <linux/delay.h> 7#include <linux/delay.h>
8#include <linux/string.h> 8#include <linux/string.h>
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/ide.h>
11 10
12#include <asm/io.h> 11#include <asm/io.h>
13#include <asm/pgtable.h> 12#include <asm/pgtable.h>
@@ -137,9 +136,11 @@ hydra_init(void)
137 struct device_node *np; 136 struct device_node *np;
138 struct resource r; 137 struct resource r;
139 138
140 np = find_devices("mac-io"); 139 np = of_find_node_by_name(NULL, "mac-io");
141 if (np == NULL || of_address_to_resource(np, 0, &r)) 140 if (np == NULL || of_address_to_resource(np, 0, &r)) {
141 of_node_put(np);
142 return 0; 142 return 0;
143 }
143 Hydra = ioremap(r.start, r.end-r.start); 144 Hydra = ioremap(r.start, r.end-r.start);
144 printk("Hydra Mac I/O at %llx\n", (unsigned long long)r.start); 145 printk("Hydra Mac I/O at %llx\n", (unsigned long long)r.start);
145 printk("Hydra Feature_Control was %x", 146 printk("Hydra Feature_Control was %x",
@@ -186,10 +187,9 @@ setup_python(struct pci_controller *hose, struct device_node *dev)
186/* Marvell Discovery II based Pegasos 2 */ 187/* Marvell Discovery II based Pegasos 2 */
187static void __init setup_peg2(struct pci_controller *hose, struct device_node *dev) 188static void __init setup_peg2(struct pci_controller *hose, struct device_node *dev)
188{ 189{
189 struct device_node *root = find_path_device("/"); 190 struct device_node *root = of_find_node_by_path("/");
190 struct device_node *rtas; 191 struct device_node *rtas;
191 192
192 of_node_get(root);
193 rtas = of_find_node_by_name (root, "rtas"); 193 rtas = of_find_node_by_name (root, "rtas");
194 if (rtas) { 194 if (rtas) {
195 hose->ops = &rtas_pci_ops; 195 hose->ops = &rtas_pci_ops;
@@ -199,6 +199,7 @@ static void __init setup_peg2(struct pci_controller *hose, struct device_node *d
199 " your firmware\n"); 199 " your firmware\n");
200 } 200 }
201 pci_assign_all_buses = 1; 201 pci_assign_all_buses = 1;
202 /* keep the reference to the root node */
202} 203}
203 204
204void __init 205void __init
@@ -211,14 +212,14 @@ chrp_find_bridges(void)
211 const unsigned int *dma; 212 const unsigned int *dma;
212 const char *model, *machine; 213 const char *model, *machine;
213 int is_longtrail = 0, is_mot = 0, is_pegasos = 0; 214 int is_longtrail = 0, is_mot = 0, is_pegasos = 0;
214 struct device_node *root = find_path_device("/"); 215 struct device_node *root = of_find_node_by_path("/");
215 struct resource r; 216 struct resource r;
216 /* 217 /*
217 * The PCI host bridge nodes on some machines don't have 218 * The PCI host bridge nodes on some machines don't have
218 * properties to adequately identify them, so we have to 219 * properties to adequately identify them, so we have to
219 * look at what sort of machine this is as well. 220 * look at what sort of machine this is as well.
220 */ 221 */
221 machine = get_property(root, "model", NULL); 222 machine = of_get_property(root, "model", NULL);
222 if (machine != NULL) { 223 if (machine != NULL) {
223 is_longtrail = strncmp(machine, "IBM,LongTrail", 13) == 0; 224 is_longtrail = strncmp(machine, "IBM,LongTrail", 13) == 0;
224 is_mot = strncmp(machine, "MOT", 3) == 0; 225 is_mot = strncmp(machine, "MOT", 3) == 0;
@@ -237,7 +238,7 @@ chrp_find_bridges(void)
237 dev->full_name); 238 dev->full_name);
238 continue; 239 continue;
239 } 240 }
240 bus_range = get_property(dev, "bus-range", &len); 241 bus_range = of_get_property(dev, "bus-range", &len);
241 if (bus_range == NULL || len < 2 * sizeof(int)) { 242 if (bus_range == NULL || len < 2 * sizeof(int)) {
242 printk(KERN_WARNING "Can't get bus-range for %s\n", 243 printk(KERN_WARNING "Can't get bus-range for %s\n",
243 dev->full_name); 244 dev->full_name);
@@ -263,7 +264,7 @@ chrp_find_bridges(void)
263 hose->first_busno = bus_range[0]; 264 hose->first_busno = bus_range[0];
264 hose->last_busno = bus_range[1]; 265 hose->last_busno = bus_range[1];
265 266
266 model = get_property(dev, "model", NULL); 267 model = of_get_property(dev, "model", NULL);
267 if (model == NULL) 268 if (model == NULL)
268 model = "<none>"; 269 model = "<none>";
269 if (device_is_compatible(dev, "IBM,python")) { 270 if (device_is_compatible(dev, "IBM,python")) {
@@ -285,7 +286,8 @@ chrp_find_bridges(void)
285 r.start + 0x000f8000, 286 r.start + 0x000f8000,
286 r.start + 0x000f8010); 287 r.start + 0x000f8010);
287 if (index == 0) { 288 if (index == 0) {
288 dma = get_property(dev, "system-dma-base",&len); 289 dma = of_get_property(dev, "system-dma-base",
290 &len);
289 if (dma && len >= sizeof(*dma)) { 291 if (dma && len >= sizeof(*dma)) {
290 dma = (unsigned int *) 292 dma = (unsigned int *)
291 (((unsigned long)dma) + 293 (((unsigned long)dma) +
@@ -303,12 +305,13 @@ chrp_find_bridges(void)
303 305
304 /* check the first bridge for a property that we can 306 /* check the first bridge for a property that we can
305 use to set pci_dram_offset */ 307 use to set pci_dram_offset */
306 dma = get_property(dev, "ibm,dma-ranges", &len); 308 dma = of_get_property(dev, "ibm,dma-ranges", &len);
307 if (index == 0 && dma != NULL && len >= 6 * sizeof(*dma)) { 309 if (index == 0 && dma != NULL && len >= 6 * sizeof(*dma)) {
308 pci_dram_offset = dma[2] - dma[3]; 310 pci_dram_offset = dma[2] - dma[3];
309 printk("pci_dram_offset = %lx\n", pci_dram_offset); 311 printk("pci_dram_offset = %lx\n", pci_dram_offset);
310 } 312 }
311 } 313 }
314 of_node_put(root);
312} 315}
313 316
314/* SL82C105 IDE Control/Status Register */ 317/* SL82C105 IDE Control/Status Register */
diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c
index 117c9a0055bd..1870038a8e0a 100644
--- a/arch/powerpc/platforms/chrp/setup.c
+++ b/arch/powerpc/platforms/chrp/setup.c
@@ -28,7 +28,6 @@
28#include <linux/adb.h> 28#include <linux/adb.h>
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/ide.h>
32#include <linux/console.h> 31#include <linux/console.h>
33#include <linux/seq_file.h> 32#include <linux/seq_file.h>
34#include <linux/root_dev.h> 33#include <linux/root_dev.h>
@@ -111,9 +110,9 @@ void chrp_show_cpuinfo(struct seq_file *m)
111 struct device_node *root; 110 struct device_node *root;
112 const char *model = ""; 111 const char *model = "";
113 112
114 root = find_path_device("/"); 113 root = of_find_node_by_path("/");
115 if (root) 114 if (root)
116 model = get_property(root, "model", NULL); 115 model = of_get_property(root, "model", NULL);
117 seq_printf(m, "machine\t\t: CHRP %s\n", model); 116 seq_printf(m, "machine\t\t: CHRP %s\n", model);
118 117
119 /* longtrail (goldengate) stuff */ 118 /* longtrail (goldengate) stuff */
@@ -161,6 +160,7 @@ void chrp_show_cpuinfo(struct seq_file *m)
161 gg2_cachetypes[(t>>2) & 3], 160 gg2_cachetypes[(t>>2) & 3],
162 gg2_cachemodes[t & 3]); 161 gg2_cachemodes[t & 3]);
163 } 162 }
163 of_node_put(root);
164} 164}
165 165
166/* 166/*
@@ -205,13 +205,15 @@ static void __init sio_init(void)
205{ 205{
206 struct device_node *root; 206 struct device_node *root;
207 207
208 if ((root = find_path_device("/")) && 208 if ((root = of_find_node_by_path("/")) &&
209 !strncmp(get_property(root, "model", NULL), "IBM,LongTrail", 13)) { 209 !strncmp(of_get_property(root, "model", NULL),
210 "IBM,LongTrail", 13)) {
210 /* logical device 0 (KBC/Keyboard) */ 211 /* logical device 0 (KBC/Keyboard) */
211 sio_fixup_irq("keyboard", 0, 1, 2); 212 sio_fixup_irq("keyboard", 0, 1, 2);
212 /* select logical device 1 (KBC/Mouse) */ 213 /* select logical device 1 (KBC/Mouse) */
213 sio_fixup_irq("mouse", 1, 12, 2); 214 sio_fixup_irq("mouse", 1, 12, 2);
214 } 215 }
216 of_node_put(root);
215} 217}
216 218
217 219
@@ -224,12 +226,12 @@ static void __init pegasos_set_l2cr(void)
224 return; 226 return;
225 227
226 /* Enable L2 cache if needed */ 228 /* Enable L2 cache if needed */
227 np = find_type_devices("cpu"); 229 np = of_find_node_by_type(NULL, "cpu");
228 if (np != NULL) { 230 if (np != NULL) {
229 const unsigned int *l2cr = get_property(np, "l2cr", NULL); 231 const unsigned int *l2cr = of_get_property(np, "l2cr", NULL);
230 if (l2cr == NULL) { 232 if (l2cr == NULL) {
231 printk ("Pegasos l2cr : no cpu l2cr property found\n"); 233 printk ("Pegasos l2cr : no cpu l2cr property found\n");
232 return; 234 goto out;
233 } 235 }
234 if (!((*l2cr) & 0x80000000)) { 236 if (!((*l2cr) & 0x80000000)) {
235 printk ("Pegasos l2cr : L2 cache was not active, " 237 printk ("Pegasos l2cr : L2 cache was not active, "
@@ -238,6 +240,8 @@ static void __init pegasos_set_l2cr(void)
238 _set_L2CR((*l2cr) | 0x80000000); 240 _set_L2CR((*l2cr) | 0x80000000);
239 } 241 }
240 } 242 }
243out:
244 of_node_put(np);
241} 245}
242 246
243static void briq_restart(char *cmd) 247static void briq_restart(char *cmd)
@@ -250,14 +254,14 @@ static void briq_restart(char *cmd)
250 254
251void __init chrp_setup_arch(void) 255void __init chrp_setup_arch(void)
252{ 256{
253 struct device_node *root = find_path_device ("/"); 257 struct device_node *root = of_find_node_by_path("/");
254 const char *machine = NULL; 258 const char *machine = NULL;
255 259
256 /* init to some ~sane value until calibrate_delay() runs */ 260 /* init to some ~sane value until calibrate_delay() runs */
257 loops_per_jiffy = 50000000/HZ; 261 loops_per_jiffy = 50000000/HZ;
258 262
259 if (root) 263 if (root)
260 machine = get_property(root, "model", NULL); 264 machine = of_get_property(root, "model", NULL);
261 if (machine && strncmp(machine, "Pegasos", 7) == 0) { 265 if (machine && strncmp(machine, "Pegasos", 7) == 0) {
262 _chrp_type = _CHRP_Pegasos; 266 _chrp_type = _CHRP_Pegasos;
263 } else if (machine && strncmp(machine, "IBM", 3) == 0) { 267 } else if (machine && strncmp(machine, "IBM", 3) == 0) {
@@ -273,6 +277,7 @@ void __init chrp_setup_arch(void)
273 /* Let's assume it is an IBM chrp if all else fails */ 277 /* Let's assume it is an IBM chrp if all else fails */
274 _chrp_type = _CHRP_IBM; 278 _chrp_type = _CHRP_IBM;
275 } 279 }
280 of_node_put(root);
276 printk("chrp type = %x [%s]\n", _chrp_type, chrp_names[_chrp_type]); 281 printk("chrp type = %x [%s]\n", _chrp_type, chrp_names[_chrp_type]);
277 282
278 rtas_initialize(); 283 rtas_initialize();
@@ -361,8 +366,8 @@ static void __init chrp_find_openpic(void)
361 return; 366 return;
362 root = of_find_node_by_path("/"); 367 root = of_find_node_by_path("/");
363 if (root) { 368 if (root) {
364 opprop = get_property(root, "platform-open-pic", &oplen); 369 opprop = of_get_property(root, "platform-open-pic", &oplen);
365 na = prom_n_addr_cells(root); 370 na = of_n_addr_cells(root);
366 } 371 }
367 if (opprop && oplen >= na * sizeof(unsigned int)) { 372 if (opprop && oplen >= na * sizeof(unsigned int)) {
368 opaddr = opprop[na-1]; /* assume 32-bit */ 373 opaddr = opprop[na-1]; /* assume 32-bit */
@@ -378,7 +383,7 @@ static void __init chrp_find_openpic(void)
378 383
379 printk(KERN_INFO "OpenPIC at %lx\n", opaddr); 384 printk(KERN_INFO "OpenPIC at %lx\n", opaddr);
380 385
381 iranges = get_property(np, "interrupt-ranges", &len); 386 iranges = of_get_property(np, "interrupt-ranges", &len);
382 if (iranges == NULL) 387 if (iranges == NULL)
383 len = 0; /* non-distributed mpic */ 388 len = 0; /* non-distributed mpic */
384 else 389 else
@@ -427,7 +432,7 @@ static void __init chrp_find_openpic(void)
427 of_node_put(np); 432 of_node_put(np);
428} 433}
429 434
430#if defined(CONFIG_VT) && defined(CONFIG_INPUT_ADBHID) && defined(XMON) 435#if defined(CONFIG_VT) && defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_XMON)
431static struct irqaction xmon_irqaction = { 436static struct irqaction xmon_irqaction = {
432 .handler = xmon_irq, 437 .handler = xmon_irq,
433 .mask = CPU_MASK_NONE, 438 .mask = CPU_MASK_NONE,
@@ -463,15 +468,16 @@ static void __init chrp_find_8259(void)
463 * Also, Pegasos-type platforms don't have a proper node to start 468 * Also, Pegasos-type platforms don't have a proper node to start
464 * from anyway 469 * from anyway
465 */ 470 */
466 for (np = find_devices("pci"); np != NULL; np = np->next) { 471 for_each_node_by_name(np, "pci") {
467 const unsigned int *addrp = get_property(np, 472 const unsigned int *addrp = of_get_property(np,
468 "8259-interrupt-acknowledge", NULL); 473 "8259-interrupt-acknowledge", NULL);
469 474
470 if (addrp == NULL) 475 if (addrp == NULL)
471 continue; 476 continue;
472 chrp_int_ack = addrp[prom_n_addr_cells(np)-1]; 477 chrp_int_ack = addrp[of_n_addr_cells(np)-1];
473 break; 478 break;
474 } 479 }
480 of_node_put(np);
475 if (np == NULL) 481 if (np == NULL)
476 printk(KERN_WARNING "Cannot find PCI interrupt acknowledge" 482 printk(KERN_WARNING "Cannot find PCI interrupt acknowledge"
477 " address, polling\n"); 483 " address, polling\n");
@@ -493,7 +499,7 @@ static void __init chrp_find_8259(void)
493 499
494void __init chrp_init_IRQ(void) 500void __init chrp_init_IRQ(void)
495{ 501{
496#if defined(CONFIG_VT) && defined(CONFIG_INPUT_ADBHID) && defined(XMON) 502#if defined(CONFIG_VT) && defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_XMON)
497 struct device_node *kbd; 503 struct device_node *kbd;
498#endif 504#endif
499 chrp_find_openpic(); 505 chrp_find_openpic();
@@ -510,13 +516,14 @@ void __init chrp_init_IRQ(void)
510 if (_chrp_type == _CHRP_Pegasos) 516 if (_chrp_type == _CHRP_Pegasos)
511 ppc_md.get_irq = i8259_irq; 517 ppc_md.get_irq = i8259_irq;
512 518
513#if defined(CONFIG_VT) && defined(CONFIG_INPUT_ADBHID) && defined(XMON) 519#if defined(CONFIG_VT) && defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_XMON)
514 /* see if there is a keyboard in the device tree 520 /* see if there is a keyboard in the device tree
515 with a parent of type "adb" */ 521 with a parent of type "adb" */
516 for (kbd = find_devices("keyboard"); kbd; kbd = kbd->next) 522 for_each_node_by_name(kbd, "keyboard")
517 if (kbd->parent && kbd->parent->type 523 if (kbd->parent && kbd->parent->type
518 && strcmp(kbd->parent->type, "adb") == 0) 524 && strcmp(kbd->parent->type, "adb") == 0)
519 break; 525 break;
526 of_node_put(kbd);
520 if (kbd) 527 if (kbd)
521 setup_irq(HYDRA_INT_ADB_NMI, &xmon_irqaction); 528 setup_irq(HYDRA_INT_ADB_NMI, &xmon_irqaction);
522#endif 529#endif
@@ -542,9 +549,9 @@ chrp_init2(void)
542 /* Get the event scan rate for the rtas so we know how 549 /* Get the event scan rate for the rtas so we know how
543 * often it expects a heartbeat. -- Cort 550 * often it expects a heartbeat. -- Cort
544 */ 551 */
545 device = find_devices("rtas"); 552 device = of_find_node_by_name(NULL, "rtas");
546 if (device) 553 if (device)
547 p = get_property(device, "rtas-event-scan-rate", NULL); 554 p = of_get_property(device, "rtas-event-scan-rate", NULL);
548 if (p && *p) { 555 if (p && *p) {
549 /* 556 /*
550 * Arrange to call chrp_event_scan at least *p times 557 * Arrange to call chrp_event_scan at least *p times
@@ -571,6 +578,7 @@ chrp_init2(void)
571 printk("RTAS Event Scan Rate: %u (%lu jiffies)\n", 578 printk("RTAS Event Scan Rate: %u (%lu jiffies)\n",
572 *p, interval); 579 *p, interval);
573 } 580 }
581 of_node_put(device);
574 582
575 if (ppc_md.progress) 583 if (ppc_md.progress)
576 ppc_md.progress(" Have fun! ", 0x7777); 584 ppc_md.progress(" Have fun! ", 0x7777);
diff --git a/arch/powerpc/platforms/chrp/time.c b/arch/powerpc/platforms/chrp/time.c
index 7d7889026936..96d1e4b3c493 100644
--- a/arch/powerpc/platforms/chrp/time.c
+++ b/arch/powerpc/platforms/chrp/time.c
@@ -39,12 +39,17 @@ long __init chrp_time_init(void)
39 struct resource r; 39 struct resource r;
40 int base; 40 int base;
41 41
42 rtcs = find_compatible_devices("rtc", "pnpPNP,b00"); 42 rtcs = of_find_compatible_node(NULL, "rtc", "pnpPNP,b00");
43 if (rtcs == NULL) 43 if (rtcs == NULL)
44 rtcs = find_compatible_devices("rtc", "ds1385-rtc"); 44 rtcs = of_find_compatible_node(NULL, "rtc", "ds1385-rtc");
45 if (rtcs == NULL || of_address_to_resource(rtcs, 0, &r)) 45 if (rtcs == NULL)
46 return 0;
47 if (of_address_to_resource(rtcs, 0, &r)) {
48 of_node_put(rtcs);
46 return 0; 49 return 0;
47 50 }
51 of_node_put(rtcs);
52
48 base = r.start; 53 base = r.start;
49 nvram_as1 = 0; 54 nvram_as1 = 0;
50 nvram_as0 = base; 55 nvram_as0 = base;
diff --git a/arch/powerpc/platforms/embedded6xx/Kconfig b/arch/powerpc/platforms/embedded6xx/Kconfig
index 3410bcbc9dbe..9557908ef545 100644
--- a/arch/powerpc/platforms/embedded6xx/Kconfig
+++ b/arch/powerpc/platforms/embedded6xx/Kconfig
@@ -2,78 +2,6 @@ choice
2 prompt "Machine Type" 2 prompt "Machine Type"
3 depends on EMBEDDED6xx 3 depends on EMBEDDED6xx
4 4
5config KATANA
6 bool "Artesyn-Katana"
7 help
8 Select KATANA if configuring an Artesyn KATANA 750i or 3750
9 cPCI board.
10
11config WILLOW
12 bool "Cogent-Willow"
13
14config CPCI690
15 bool "Force-CPCI690"
16 help
17 Select CPCI690 if configuring a Force CPCI690 cPCI board.
18
19config POWERPMC250
20 bool "Force-PowerPMC250"
21
22config CHESTNUT
23 bool "IBM 750FX Eval board or 750GX Eval board"
24 help
25 Select CHESTNUT if configuring an IBM 750FX Eval Board or a
26 IBM 750GX Eval board.
27
28config SPRUCE
29 bool "IBM-Spruce"
30 select PPC_INDIRECT_PCI
31
32config HDPU
33 bool "Sky-HDPU"
34 help
35 Select HDPU if configuring a Sky Computers Compute Blade.
36
37config HDPU_FEATURES
38 depends on HDPU
39 tristate "HDPU-Features"
40 help
41 Select to enable HDPU enhanced features.
42
43config EV64260
44 bool "Marvell-EV64260BP"
45 help
46 Select EV64260 if configuring a Marvell (formerly Galileo)
47 EV64260BP Evaluation platform.
48
49config LOPEC
50 bool "Motorola-LoPEC"
51 select PPC_I8259
52
53config MVME5100
54 bool "Motorola-MVME5100"
55 select PPC_INDIRECT_PCI
56
57config PPLUS
58 bool "Motorola-PowerPlus"
59 select PPC_I8259
60 select PPC_INDIRECT_PCI
61
62config PRPMC750
63 bool "Motorola-PrPMC750"
64 select PPC_INDIRECT_PCI
65
66config PRPMC800
67 bool "Motorola-PrPMC800"
68 select PPC_INDIRECT_PCI
69
70config SANDPOINT
71 bool "Motorola-Sandpoint"
72 select PPC_I8259
73 help
74 Select SANDPOINT if configuring for a Motorola Sandpoint X3
75 (any flavor).
76
77config LINKSTATION 5config LINKSTATION
78 bool "Linkstation / Kurobox(HG) from Buffalo" 6 bool "Linkstation / Kurobox(HG) from Buffalo"
79 select MPIC 7 select MPIC
@@ -97,212 +25,24 @@ config MPC7448HPC2
97 help 25 help
98 Select MPC7448HPC2 if configuring for Freescale MPC7448HPC2 (Taiga) 26 Select MPC7448HPC2 if configuring for Freescale MPC7448HPC2 (Taiga)
99 platform 27 platform
100
101config RADSTONE_PPC7D
102 bool "Radstone Technology PPC7D board"
103 select PPC_I8259
104
105config PAL4
106 bool "SBS-Palomar4"
107
108config EST8260
109 bool "EST8260"
110 ---help---
111 The EST8260 is a single-board computer manufactured by Wind River
112 Systems, Inc. (formerly Embedded Support Tools Corp.) and based on
113 the MPC8260. Wind River Systems has a website at
114 <http://www.windriver.com/>, but the EST8260 cannot be found on it
115 and has probably been discontinued or rebadged.
116
117config SBC82xx
118 bool "SBC82xx"
119 ---help---
120 SBC PowerQUICC II, single-board computer with MPC82xx CPU
121 Manufacturer: Wind River Systems, Inc.
122 Date of Release: May 2003
123 End of Life: -
124 URL: <http://www.windriver.com/>
125
126config SBS8260
127 bool "SBS8260"
128
129config RPX8260
130 bool "RPXSUPER"
131
132config TQM8260
133 bool "TQM8260"
134 ---help---
135 MPC8260 based module, little larger than credit card,
136 up to 128 MB global + 64 MB local RAM, 32 MB Flash,
137 32 kB EEPROM, 256 kB L@ Cache, 10baseT + 100baseT Ethernet,
138 2 x serial ports, ...
139 Manufacturer: TQ Components, www.tq-group.de
140 Date of Release: June 2001
141 End of Life: not yet :-)
142 URL: <http://www.denx.de/PDF/TQM82xx_SPEC_Rev005.pdf>
143
144config ADS8272
145 bool "ADS8272"
146
147config PQ2FADS
148 bool "Freescale-PQ2FADS"
149 help
150 Select PQ2FADS if you wish to configure for a Freescale
151 PQ2FADS board (-VR or -ZU).
152
153config EV64360
154 bool "Marvell-EV64360BP"
155 help
156 Select EV64360 if configuring a Marvell EV64360BP Evaluation
157 platform.
158endchoice 28endchoice
159 29
160config PQ2ADS
161 bool
162 depends on ADS8272
163 default y
164
165config TQM8xxL
166 bool
167 depends on 8xx && (TQM823L || TQM850L || FPS850L || TQM855L || TQM860L)
168 default y
169
170config 8260
171 bool "CPM2 Support" if WILLOW
172 depends on 6xx
173 default y if TQM8260 || RPX8260 || EST8260 || SBS8260 || SBC82xx || PQ2FADS
174 help
175 The MPC8260 is a typical embedded CPU made by Motorola. Selecting
176 this option means that you wish to build a kernel for a machine with
177 an 8260 class CPU.
178
179config 8272
180 bool
181 depends on 6xx
182 default y if ADS8272
183 select 8260
184 help
185 The MPC8272 CPM has a different internal dpram setup than other CPM2
186 devices
187
188config CPM2
189 bool
190 depends on 8260 || MPC8560 || MPC8555
191 default y
192 help
193 The CPM2 (Communications Processor Module) is a coprocessor on
194 embedded CPUs made by Motorola. Selecting this option means that
195 you wish to build a kernel for a machine with a CPM2 coprocessor
196 on it (826x, 827x, 8560).
197
198config PPC_GEN550
199 bool
200 depends on SANDPOINT || SPRUCE || PPLUS || \
201 PRPMC750 || PRPMC800 || LOPEC || \
202 (EV64260 && !SERIAL_MPSC) || CHESTNUT || RADSTONE_PPC7D || \
203 83xx || LINKSTATION
204 default y
205
206config FORCE
207 bool
208 depends on 6xx && POWERPMC250
209 default y
210
211config GT64260
212 bool
213 depends on EV64260 || CPCI690
214 default y
215
216config MV64360 # Really MV64360 & MV64460
217 bool
218 depends on CHESTNUT || KATANA || RADSTONE_PPC7D || HDPU || EV64360
219 default y
220
221config MV64X60
222 bool
223 depends on (GT64260 || MV64360)
224 select PPC_INDIRECT_PCI
225 default y
226
227config TSI108_BRIDGE 30config TSI108_BRIDGE
228 bool 31 bool
229 depends on MPC7448HPC2 32 depends on MPC7448HPC2
230 default y 33 default y
231 34
232menu "Set bridge options"
233 depends on MV64X60
234
235config NOT_COHERENT_CACHE
236 bool "Turn off Cache Coherency"
237 default n
238 help
239 Some 64x60 bridges lock up when trying to enforce cache coherency.
240 When this option is selected, cache coherency will be turned off.
241 Note that this can cause other problems (e.g., stale data being
242 speculatively loaded via a cached mapping). Use at your own risk.
243
244config MV64X60_BASE
245 hex "Set bridge base used by firmware"
246 default "0xf1000000"
247 help
248 A firmware can leave the base address of the bridge's registers at
249 a non-standard location. If so, set this value to reflect the
250 address of that non-standard location.
251
252config MV64X60_NEW_BASE
253 hex "Set bridge base used by kernel"
254 default "0xf1000000"
255 help
256 If the current base address of the bridge's registers is not where
257 you want it, set this value to the address that you want it moved to.
258
259endmenu
260
261config NONMONARCH_SUPPORT
262 bool "Enable Non-Monarch Support"
263 depends on PRPMC800
264
265config HARRIER
266 bool
267 depends on PRPMC800
268 default y
269
270config EPIC_SERIAL_MODE
271 bool
272 depends on 6xx && (LOPEC || SANDPOINT)
273 default y
274
275config MPC10X_BRIDGE 35config MPC10X_BRIDGE
276 bool 36 bool
277 depends on POWERPMC250 || LOPEC || SANDPOINT || LINKSTATION 37 depends on LINKSTATION
278 select PPC_INDIRECT_PCI 38 select PPC_INDIRECT_PCI
279 default y 39 default y
280 40
281config MPC10X_OPENPIC 41config MPC10X_OPENPIC
282 bool 42 bool
283 depends on POWERPMC250 || LOPEC || SANDPOINT || LINKSTATION 43 depends on LINKSTATION
284 default y 44 default y
285 45
286config MPC10X_STORE_GATHERING 46config MPC10X_STORE_GATHERING
287 bool "Enable MPC10x store gathering" 47 bool "Enable MPC10x store gathering"
288 depends on MPC10X_BRIDGE 48 depends on MPC10X_BRIDGE
289
290config SANDPOINT_ENABLE_UART1
291 bool "Enable DUART mode on Sandpoint"
292 depends on SANDPOINT
293 help
294 If this option is enabled then the MPC824x processor will run
295 in DUART mode instead of UART mode.
296
297config HARRIER_STORE_GATHERING
298 bool "Enable Harrier store gathering"
299 depends on HARRIER
300
301config MVME5100_IPMC761_PRESENT
302 bool "MVME5100 configured with an IPMC761"
303 depends on MVME5100
304 select PPC_I8259
305
306config SPRUCE_BAUD_33M
307 bool "Spruce baud clock support"
308 depends on SPRUCE
diff --git a/arch/powerpc/platforms/embedded6xx/linkstation.c b/arch/powerpc/platforms/embedded6xx/linkstation.c
index 3f6c4114f908..b412f006a9c5 100644
--- a/arch/powerpc/platforms/embedded6xx/linkstation.c
+++ b/arch/powerpc/platforms/embedded6xx/linkstation.c
@@ -58,11 +58,11 @@ static int __init add_bridge(struct device_node *dev)
58{ 58{
59 int len; 59 int len;
60 struct pci_controller *hose; 60 struct pci_controller *hose;
61 int *bus_range; 61 const int *bus_range;
62 62
63 printk("Adding PCI host bridge %s\n", dev->full_name); 63 printk("Adding PCI host bridge %s\n", dev->full_name);
64 64
65 bus_range = (int *) get_property(dev, "bus-range", &len); 65 bus_range = of_get_property(dev, "bus-range", &len);
66 if (bus_range == NULL || len < 2 * sizeof(int)) 66 if (bus_range == NULL || len < 2 * sizeof(int))
67 printk(KERN_WARNING "Can't get bus-range for %s, assume" 67 printk(KERN_WARNING "Can't get bus-range for %s, assume"
68 " bus 0\n", dev->full_name); 68 " bus 0\n", dev->full_name);
@@ -106,7 +106,7 @@ static void __init linkstation_init_IRQ(void)
106{ 106{
107 struct mpic *mpic; 107 struct mpic *mpic;
108 struct device_node *dnp; 108 struct device_node *dnp;
109 void *prop; 109 const u32 *prop;
110 int size; 110 int size;
111 phys_addr_t paddr; 111 phys_addr_t paddr;
112 112
@@ -114,7 +114,7 @@ static void __init linkstation_init_IRQ(void)
114 if (dnp == NULL) 114 if (dnp == NULL)
115 return; 115 return;
116 116
117 prop = (struct device_node *)get_property(dnp, "reg", &size); 117 prop = of_get_property(dnp, "reg", &size);
118 paddr = (phys_addr_t)of_translate_address(dnp, prop); 118 paddr = (phys_addr_t)of_translate_address(dnp, prop);
119 119
120 mpic = mpic_alloc(dnp, paddr, MPIC_PRIMARY | MPIC_WANTS_RESET, 4, 32, " EPIC "); 120 mpic = mpic_alloc(dnp, paddr, MPIC_PRIMARY | MPIC_WANTS_RESET, 4, 32, " EPIC ");
diff --git a/arch/powerpc/platforms/embedded6xx/ls_uart.c b/arch/powerpc/platforms/embedded6xx/ls_uart.c
index 0e837762cc5b..d0bee9f19e4e 100644
--- a/arch/powerpc/platforms/embedded6xx/ls_uart.c
+++ b/arch/powerpc/platforms/embedded6xx/ls_uart.c
@@ -110,8 +110,8 @@ static int __init ls_uarts_init(void)
110 if (!avr) 110 if (!avr)
111 return -EINVAL; 111 return -EINVAL;
112 112
113 avr_clock = *(u32*)get_property(avr, "clock-frequency", &len); 113 avr_clock = *(u32*)of_get_property(avr, "clock-frequency", &len);
114 phys_addr = ((u32*)get_property(avr, "reg", &len))[0]; 114 phys_addr = ((u32*)of_get_property(avr, "reg", &len))[0];
115 115
116 if (!avr_clock || !phys_addr) 116 if (!avr_clock || !phys_addr)
117 return -EINVAL; 117 return -EINVAL;
diff --git a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
index 3fcc85f60fbf..c3f64ddb0be6 100644
--- a/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
+++ b/arch/powerpc/platforms/embedded6xx/mpc7448_hpc2.c
@@ -25,7 +25,6 @@
25#include <linux/console.h> 25#include <linux/console.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/irq.h> 27#include <linux/irq.h>
28#include <linux/ide.h>
29#include <linux/seq_file.h> 28#include <linux/seq_file.h>
30#include <linux/root_dev.h> 29#include <linux/root_dev.h>
31#include <linux/serial.h> 30#include <linux/serial.h>
@@ -82,7 +81,7 @@ static void __init mpc7448_hpc2_setup_arch(void)
82 if (cpu != 0) { 81 if (cpu != 0) {
83 const unsigned int *fp; 82 const unsigned int *fp;
84 83
85 fp = get_property(cpu, "clock-frequency", NULL); 84 fp = of_get_property(cpu, "clock-frequency", NULL);
86 if (fp != 0) 85 if (fp != 0)
87 loops_per_jiffy = *fp / HZ; 86 loops_per_jiffy = *fp / HZ;
88 else 87 else
@@ -91,16 +90,6 @@ static void __init mpc7448_hpc2_setup_arch(void)
91 } 90 }
92 tsi108_csr_vir_base = get_vir_csrbase(); 91 tsi108_csr_vir_base = get_vir_csrbase();
93 92
94#ifdef CONFIG_ROOT_NFS
95 ROOT_DEV = Root_NFS;
96#else
97 ROOT_DEV = Root_HDA1;
98#endif
99
100#ifdef CONFIG_BLK_DEV_INITRD
101 ROOT_DEV = Root_RAM0;
102#endif
103
104 /* setup PCI host bridge */ 93 /* setup PCI host bridge */
105#ifdef CONFIG_PCI 94#ifdef CONFIG_PCI
106 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;) 95 for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
@@ -143,7 +132,7 @@ static void __init mpc7448_hpc2_init_IRQ(void)
143 tsi_pic = of_find_node_by_type(NULL, "open-pic"); 132 tsi_pic = of_find_node_by_type(NULL, "open-pic");
144 if (tsi_pic) { 133 if (tsi_pic) {
145 unsigned int size; 134 unsigned int size;
146 const void *prop = get_property(tsi_pic, "reg", &size); 135 const void *prop = of_get_property(tsi_pic, "reg", &size);
147 mpic_paddr = of_translate_address(tsi_pic, prop); 136 mpic_paddr = of_translate_address(tsi_pic, prop);
148 } 137 }
149 138
diff --git a/arch/powerpc/platforms/iseries/Kconfig b/arch/powerpc/platforms/iseries/Kconfig
index 54e6b3b6f261..46c3a8e7c3a8 100644
--- a/arch/powerpc/platforms/iseries/Kconfig
+++ b/arch/powerpc/platforms/iseries/Kconfig
@@ -1,3 +1,7 @@
1config PPC_ISERIES
2 bool "IBM Legacy iSeries"
3 depends on PPC_MULTIPLATFORM && PPC64
4 select PPC_INDIRECT_IO
1 5
2menu "iSeries device drivers" 6menu "iSeries device drivers"
3 depends on PPC_ISERIES 7 depends on PPC_ISERIES
diff --git a/arch/powerpc/platforms/iseries/iommu.c b/arch/powerpc/platforms/iseries/iommu.c
index d7a756d5135c..3b6a9666c2c0 100644
--- a/arch/powerpc/platforms/iseries/iommu.c
+++ b/arch/powerpc/platforms/iseries/iommu.c
@@ -171,7 +171,7 @@ void iommu_devnode_init_iSeries(struct pci_dev *pdev, struct device_node *dn)
171{ 171{
172 struct iommu_table *tbl; 172 struct iommu_table *tbl;
173 struct pci_dn *pdn = PCI_DN(dn); 173 struct pci_dn *pdn = PCI_DN(dn);
174 const u32 *lsn = get_property(dn, "linux,logical-slot-number", NULL); 174 const u32 *lsn = of_get_property(dn, "linux,logical-slot-number", NULL);
175 175
176 BUG_ON(lsn == NULL); 176 BUG_ON(lsn == NULL);
177 177
@@ -194,5 +194,5 @@ void iommu_init_early_iSeries(void)
194 ppc_md.tce_build = tce_build_iSeries; 194 ppc_md.tce_build = tce_build_iSeries;
195 ppc_md.tce_free = tce_free_iSeries; 195 ppc_md.tce_free = tce_free_iSeries;
196 196
197 pci_dma_ops = &dma_iommu_ops; 197 set_pci_dma_ops(&dma_iommu_ops);
198} 198}
diff --git a/arch/powerpc/platforms/iseries/irq.c b/arch/powerpc/platforms/iseries/irq.c
index 5225abfafd9b..63b33675848b 100644
--- a/arch/powerpc/platforms/iseries/irq.c
+++ b/arch/powerpc/platforms/iseries/irq.c
@@ -30,7 +30,6 @@
30#include <linux/param.h> 30#include <linux/param.h>
31#include <linux/string.h> 31#include <linux/string.h>
32#include <linux/bootmem.h> 32#include <linux/bootmem.h>
33#include <linux/ide.h>
34#include <linux/irq.h> 33#include <linux/irq.h>
35#include <linux/spinlock.h> 34#include <linux/spinlock.h>
36 35
@@ -337,6 +336,8 @@ unsigned int iSeries_get_irq(void)
337 return irq; 336 return irq;
338} 337}
339 338
339#ifdef CONFIG_PCI
340
340static int iseries_irq_host_map(struct irq_host *h, unsigned int virq, 341static int iseries_irq_host_map(struct irq_host *h, unsigned int virq,
341 irq_hw_number_t hw) 342 irq_hw_number_t hw)
342{ 343{
@@ -384,3 +385,4 @@ void __init iSeries_init_IRQ(void)
384 "failed with rc 0x%x\n", ret); 385 "failed with rc 0x%x\n", ret);
385} 386}
386 387
388#endif /* CONFIG_PCI */
diff --git a/arch/powerpc/platforms/iseries/pci.c b/arch/powerpc/platforms/iseries/pci.c
index 4a06d9c34986..9c974227155e 100644
--- a/arch/powerpc/platforms/iseries/pci.c
+++ b/arch/powerpc/platforms/iseries/pci.c
@@ -24,7 +24,6 @@
24#include <linux/string.h> 24#include <linux/string.h>
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/ide.h>
28#include <linux/pci.h> 27#include <linux/pci.h>
29 28
30#include <asm/io.h> 29#include <asm/io.h>
@@ -177,7 +176,7 @@ void __init iSeries_pci_final_fixup(void)
177 struct pci_dn *pdn = PCI_DN(node); 176 struct pci_dn *pdn = PCI_DN(node);
178 const u32 *agent; 177 const u32 *agent;
179 178
180 agent = get_property(node, "linux,agent-id", NULL); 179 agent = of_get_property(node, "linux,agent-id", NULL);
181 if ((pdn != NULL) && (agent != NULL)) { 180 if ((pdn != NULL) && (agent != NULL)) {
182 u8 irq = iSeries_allocate_IRQ(pdn->busno, 0, 181 u8 irq = iSeries_allocate_IRQ(pdn->busno, 0,
183 pdn->bussubno); 182 pdn->bussubno);
@@ -755,7 +754,7 @@ void __init iSeries_pcibios_init(void)
755 if ((node->type == NULL) || (strcmp(node->type, "pci") != 0)) 754 if ((node->type == NULL) || (strcmp(node->type, "pci") != 0))
756 continue; 755 continue;
757 756
758 busp = get_property(node, "bus-range", NULL); 757 busp = of_get_property(node, "bus-range", NULL);
759 if (busp == NULL) 758 if (busp == NULL)
760 continue; 759 continue;
761 bus = *busp; 760 bus = *busp;
diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c
index cce7e309340c..7f5dcee814d4 100644
--- a/arch/powerpc/platforms/iseries/setup.c
+++ b/arch/powerpc/platforms/iseries/setup.c
@@ -628,15 +628,6 @@ static void iseries_iounmap(volatile void __iomem *token)
628{ 628{
629} 629}
630 630
631/*
632 * iSeries has no legacy IO, anything calling this function has to
633 * fail or bad things will happen
634 */
635static int iseries_check_legacy_ioport(unsigned int baseport)
636{
637 return -ENODEV;
638}
639
640static int __init iseries_probe(void) 631static int __init iseries_probe(void)
641{ 632{
642 unsigned long root = of_get_flat_dt_root(); 633 unsigned long root = of_get_flat_dt_root();
@@ -667,7 +658,6 @@ define_machine(iseries) {
667 .calibrate_decr = generic_calibrate_decr, 658 .calibrate_decr = generic_calibrate_decr,
668 .progress = iSeries_progress, 659 .progress = iSeries_progress,
669 .probe = iseries_probe, 660 .probe = iseries_probe,
670 .check_legacy_ioport = iseries_check_legacy_ioport,
671 .ioremap = iseries_ioremap, 661 .ioremap = iseries_ioremap,
672 .iounmap = iseries_iounmap, 662 .iounmap = iseries_iounmap,
673 /* XXX Implement enable_pmcs for iSeries */ 663 /* XXX Implement enable_pmcs for iSeries */
diff --git a/arch/powerpc/platforms/iseries/viopath.c b/arch/powerpc/platforms/iseries/viopath.c
index e2100ece9c65..2ca2d8a9de97 100644
--- a/arch/powerpc/platforms/iseries/viopath.c
+++ b/arch/powerpc/platforms/iseries/viopath.c
@@ -155,7 +155,7 @@ static int proc_viopath_show(struct seq_file *m, void *v)
155 node = of_find_node_by_path("/"); 155 node = of_find_node_by_path("/");
156 sysid = NULL; 156 sysid = NULL;
157 if (node != NULL) 157 if (node != NULL)
158 sysid = get_property(node, "system-id", NULL); 158 sysid = of_get_property(node, "system-id", NULL);
159 159
160 if (sysid == NULL) 160 if (sysid == NULL)
161 seq_printf(m, "SRLNBR=<UNKNOWN>\n"); 161 seq_printf(m, "SRLNBR=<UNKNOWN>\n");
diff --git a/arch/powerpc/platforms/maple/Kconfig b/arch/powerpc/platforms/maple/Kconfig
new file mode 100644
index 000000000000..f7c95eb5d8ba
--- /dev/null
+++ b/arch/powerpc/platforms/maple/Kconfig
@@ -0,0 +1,17 @@
1config PPC_MAPLE
2 depends on PPC_MULTIPLATFORM && PPC64
3 bool "Maple 970FX Evaluation Board"
4 select MPIC
5 select U3_DART
6 select MPIC_U3_HT_IRQS
7 select GENERIC_TBSYNC
8 select PPC_UDBG_16550
9 select PPC_970_NAP
10 select PPC_NATIVE
11 select PPC_RTAS
12 select MMIO_NVRAM
13 select ATA_NONSTANDARD if ATA
14 default n
15 help
16 This option enables support for the Maple 970FX Evaluation Board.
17 For more information, refer to <http://www.970eval.com>
diff --git a/arch/powerpc/platforms/maple/pci.c b/arch/powerpc/platforms/maple/pci.c
index 73c59904697f..b1d3b99c3f9d 100644
--- a/arch/powerpc/platforms/maple/pci.c
+++ b/arch/powerpc/platforms/maple/pci.c
@@ -44,11 +44,11 @@ static int __init fixup_one_level_bus_range(struct device_node *node, int higher
44 int len; 44 int len;
45 45
46 /* For PCI<->PCI bridges or CardBus bridges, we go down */ 46 /* For PCI<->PCI bridges or CardBus bridges, we go down */
47 class_code = get_property(node, "class-code", NULL); 47 class_code = of_get_property(node, "class-code", NULL);
48 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI && 48 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
49 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) 49 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS))
50 continue; 50 continue;
51 bus_range = get_property(node, "bus-range", &len); 51 bus_range = of_get_property(node, "bus-range", &len);
52 if (bus_range != NULL && len > 2 * sizeof(int)) { 52 if (bus_range != NULL && len > 2 * sizeof(int)) {
53 if (bus_range[1] > higher) 53 if (bus_range[1] > higher)
54 higher = bus_range[1]; 54 higher = bus_range[1];
@@ -77,7 +77,7 @@ static void __init fixup_bus_range(struct device_node *bridge)
77 bridge->full_name); 77 bridge->full_name);
78 return; 78 return;
79 } 79 }
80 bus_range = (int *)prop->value; 80 bus_range = prop->value;
81 bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]); 81 bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]);
82} 82}
83 83
@@ -454,7 +454,7 @@ static int __init add_bridge(struct device_node *dev)
454 454
455 DBG("Adding PCI host bridge %s\n", dev->full_name); 455 DBG("Adding PCI host bridge %s\n", dev->full_name);
456 456
457 bus_range = get_property(dev, "bus-range", &len); 457 bus_range = of_get_property(dev, "bus-range", &len);
458 if (bus_range == NULL || len < 2 * sizeof(int)) { 458 if (bus_range == NULL || len < 2 * sizeof(int)) {
459 printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n", 459 printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n",
460 dev->full_name); 460 dev->full_name);
diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c
index 82d3f9e28d7c..2a30c5b2532e 100644
--- a/arch/powerpc/platforms/maple/setup.c
+++ b/arch/powerpc/platforms/maple/setup.c
@@ -32,7 +32,6 @@
32#include <linux/initrd.h> 32#include <linux/initrd.h>
33#include <linux/vt_kern.h> 33#include <linux/vt_kern.h>
34#include <linux/console.h> 34#include <linux/console.h>
35#include <linux/ide.h>
36#include <linux/pci.h> 35#include <linux/pci.h>
37#include <linux/adb.h> 36#include <linux/adb.h>
38#include <linux/cuda.h> 37#include <linux/cuda.h>
@@ -114,8 +113,8 @@ static void maple_restart(char *cmd)
114 printk(KERN_EMERG "Maple: Unable to find Service Processor\n"); 113 printk(KERN_EMERG "Maple: Unable to find Service Processor\n");
115 goto fail; 114 goto fail;
116 } 115 }
117 maple_nvram_offset = get_property(sp, "restart-addr", NULL); 116 maple_nvram_offset = of_get_property(sp, "restart-addr", NULL);
118 maple_nvram_command = get_property(sp, "restart-value", NULL); 117 maple_nvram_command = of_get_property(sp, "restart-value", NULL);
119 of_node_put(sp); 118 of_node_put(sp);
120 119
121 /* send command */ 120 /* send command */
@@ -141,8 +140,8 @@ static void maple_power_off(void)
141 printk(KERN_EMERG "Maple: Unable to find Service Processor\n"); 140 printk(KERN_EMERG "Maple: Unable to find Service Processor\n");
142 goto fail; 141 goto fail;
143 } 142 }
144 maple_nvram_offset = get_property(sp, "power-off-addr", NULL); 143 maple_nvram_offset = of_get_property(sp, "power-off-addr", NULL);
145 maple_nvram_command = get_property(sp, "power-off-value", NULL); 144 maple_nvram_command = of_get_property(sp, "power-off-value", NULL);
146 of_node_put(sp); 145 of_node_put(sp);
147 146
148 /* send command */ 147 /* send command */
@@ -249,8 +248,8 @@ static void __init maple_init_IRQ(void)
249 248
250 /* Find address list in /platform-open-pic */ 249 /* Find address list in /platform-open-pic */
251 root = of_find_node_by_path("/"); 250 root = of_find_node_by_path("/");
252 naddr = prom_n_addr_cells(root); 251 naddr = of_n_addr_cells(root);
253 opprop = get_property(root, "platform-open-pic", &opplen); 252 opprop = of_get_property(root, "platform-open-pic", &opplen);
254 if (opprop != 0) { 253 if (opprop != 0) {
255 openpic_addr = of_read_number(opprop, naddr); 254 openpic_addr = of_read_number(opprop, naddr);
256 has_isus = (opplen > naddr); 255 has_isus = (opplen > naddr);
@@ -261,11 +260,11 @@ static void __init maple_init_IRQ(void)
261 BUG_ON(openpic_addr == 0); 260 BUG_ON(openpic_addr == 0);
262 261
263 /* Check for a big endian MPIC */ 262 /* Check for a big endian MPIC */
264 if (get_property(np, "big-endian", NULL) != NULL) 263 if (of_get_property(np, "big-endian", NULL) != NULL)
265 flags |= MPIC_BIG_ENDIAN; 264 flags |= MPIC_BIG_ENDIAN;
266 265
267 /* XXX Maple specific bits */ 266 /* XXX Maple specific bits */
268 flags |= MPIC_BROKEN_U3 | MPIC_WANTS_RESET; 267 flags |= MPIC_U3_HT_IRQS | MPIC_WANTS_RESET;
269 /* All U3/U4 are big-endian, older SLOF firmware doesn't encode this */ 268 /* All U3/U4 are big-endian, older SLOF firmware doesn't encode this */
270 flags |= MPIC_BIG_ENDIAN; 269 flags |= MPIC_BIG_ENDIAN;
271 270
diff --git a/arch/powerpc/platforms/pasemi/Kconfig b/arch/powerpc/platforms/pasemi/Kconfig
index 68dc529dfd2f..eb4dbc705b06 100644
--- a/arch/powerpc/platforms/pasemi/Kconfig
+++ b/arch/powerpc/platforms/pasemi/Kconfig
@@ -1,3 +1,15 @@
1config PPC_PASEMI
2 depends on PPC_MULTIPLATFORM && PPC64
3 bool "PA Semi SoC-based platforms"
4 default n
5 select MPIC
6 select PPC_UDBG_16550
7 select GENERIC_TBSYNC
8 select PPC_NATIVE
9 help
10 This option enables support for PA Semi's PWRficient line
11 of SoC processors, including PA6T-1682M
12
1menu "PA Semi PWRficient options" 13menu "PA Semi PWRficient options"
2 depends on PPC_PASEMI 14 depends on PPC_PASEMI
3 15
@@ -7,4 +19,11 @@ config PPC_PASEMI_IOMMU
7 help 19 help
8 IOMMU support for PA6T-1682M 20 IOMMU support for PA6T-1682M
9 21
22config PPC_PASEMI_MDIO
23 depends on PHYLIB
24 tristate "MDIO support via GPIO"
25 default y
26 help
27 Driver for MDIO via GPIO on PWRficient platforms
28
10endmenu 29endmenu
diff --git a/arch/powerpc/platforms/pasemi/Makefile b/arch/powerpc/platforms/pasemi/Makefile
index e657ccae90a9..2cd2a4f26a48 100644
--- a/arch/powerpc/platforms/pasemi/Makefile
+++ b/arch/powerpc/platforms/pasemi/Makefile
@@ -1,2 +1,3 @@
1obj-y += setup.o pci.o time.o idle.o powersave.o iommu.o 1obj-y += setup.o pci.o time.o idle.o powersave.o iommu.o
2 2obj-$(CONFIG_PPC_PASEMI_MDIO) += gpio_mdio.o
3obj-$(CONFIG_PPC_PASEMI_CPUFREQ) += cpufreq.o
diff --git a/arch/powerpc/platforms/pasemi/cpufreq.c b/arch/powerpc/platforms/pasemi/cpufreq.c
new file mode 100644
index 000000000000..2a57d6023685
--- /dev/null
+++ b/arch/powerpc/platforms/pasemi/cpufreq.c
@@ -0,0 +1,308 @@
1/*
2 * Copyright (C) 2007 PA Semi, Inc
3 *
4 * Authors: Egor Martovetsky <egor@pasemi.com>
5 * Olof Johansson <olof@lixom.net>
6 *
7 * Maintained by: Olof Johansson <olof@lixom.net>
8 *
9 * Based on arch/powerpc/platforms/cell/cbe_cpufreq.c:
10 * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2, or (at your option)
15 * any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *
26 */
27
28#include <linux/cpufreq.h>
29#include <linux/timer.h>
30
31#include <asm/hw_irq.h>
32#include <asm/io.h>
33#include <asm/prom.h>
34
35#define SDCASR_REG 0x0100
36#define SDCASR_REG_STRIDE 0x1000
37#define SDCPWR_CFGA0_REG 0x0100
38#define SDCPWR_PWST0_REG 0x0000
39#define SDCPWR_GIZTIME_REG 0x0440
40
41/* SDCPWR_GIZTIME_REG fields */
42#define SDCPWR_GIZTIME_GR 0x80000000
43#define SDCPWR_GIZTIME_LONGLOCK 0x000000ff
44
45/* Offset of ASR registers from SDC base */
46#define SDCASR_OFFSET 0x120000
47
48static void __iomem *sdcpwr_mapbase;
49static void __iomem *sdcasr_mapbase;
50
51static DEFINE_MUTEX(pas_switch_mutex);
52
53/* Current astate, is used when waking up from power savings on
54 * one core, in case the other core has switched states during
55 * the idle time.
56 */
57static int current_astate;
58
59/* We support 5(A0-A4) power states excluding turbo(A5-A6) modes */
60static struct cpufreq_frequency_table pas_freqs[] = {
61 {0, 0},
62 {1, 0},
63 {2, 0},
64 {3, 0},
65 {4, 0},
66 {0, CPUFREQ_TABLE_END},
67};
68
69static struct freq_attr *pas_cpu_freqs_attr[] = {
70 &cpufreq_freq_attr_scaling_available_freqs,
71 NULL,
72};
73
74/*
75 * hardware specific functions
76 */
77
78static int get_astate_freq(int astate)
79{
80 u32 ret;
81 ret = in_le32(sdcpwr_mapbase + SDCPWR_CFGA0_REG + (astate * 0x10));
82
83 return ret & 0x3f;
84}
85
86static int get_cur_astate(int cpu)
87{
88 u32 ret;
89
90 ret = in_le32(sdcpwr_mapbase + SDCPWR_PWST0_REG);
91 ret = (ret >> (cpu * 4)) & 0x7;
92
93 return ret;
94}
95
96static int get_gizmo_latency(void)
97{
98 u32 giztime, ret;
99
100 giztime = in_le32(sdcpwr_mapbase + SDCPWR_GIZTIME_REG);
101
102 /* just provide the upper bound */
103 if (giztime & SDCPWR_GIZTIME_GR)
104 ret = (giztime & SDCPWR_GIZTIME_LONGLOCK) * 128000;
105 else
106 ret = (giztime & SDCPWR_GIZTIME_LONGLOCK) * 1000;
107
108 return ret;
109}
110
111static void set_astate(int cpu, unsigned int astate)
112{
113 u64 flags;
114
115 /* Return if called before init has run */
116 if (unlikely(!sdcasr_mapbase))
117 return;
118
119 local_irq_save(flags);
120
121 out_le32(sdcasr_mapbase + SDCASR_REG + SDCASR_REG_STRIDE*cpu, astate);
122
123 local_irq_restore(flags);
124}
125
126void restore_astate(int cpu)
127{
128 set_astate(cpu, current_astate);
129}
130
131/*
132 * cpufreq functions
133 */
134
135static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)
136{
137 const u32 *max_freqp;
138 u32 max_freq;
139 int i, cur_astate;
140 struct resource res;
141 struct device_node *cpu, *dn;
142 int err = -ENODEV;
143
144 cpu = of_get_cpu_node(policy->cpu, NULL);
145
146 if (!cpu)
147 goto out;
148
149 dn = of_find_compatible_node(NULL, "sdc", "1682m-sdc");
150 if (!dn)
151 goto out;
152 err = of_address_to_resource(dn, 0, &res);
153 of_node_put(dn);
154 if (err)
155 goto out;
156 sdcasr_mapbase = ioremap(res.start + SDCASR_OFFSET, 0x2000);
157 if (!sdcasr_mapbase) {
158 err = -EINVAL;
159 goto out;
160 }
161
162 dn = of_find_compatible_node(NULL, "gizmo", "1682m-gizmo");
163 if (!dn) {
164 err = -ENODEV;
165 goto out_unmap_sdcasr;
166 }
167 err = of_address_to_resource(dn, 0, &res);
168 of_node_put(dn);
169 if (err)
170 goto out_unmap_sdcasr;
171 sdcpwr_mapbase = ioremap(res.start, 0x1000);
172 if (!sdcpwr_mapbase) {
173 err = -EINVAL;
174 goto out_unmap_sdcasr;
175 }
176
177 pr_debug("init cpufreq on CPU %d\n", policy->cpu);
178
179 max_freqp = of_get_property(cpu, "clock-frequency", NULL);
180 if (!max_freqp) {
181 err = -EINVAL;
182 goto out_unmap_sdcpwr;
183 }
184
185 /* we need the freq in kHz */
186 max_freq = *max_freqp / 1000;
187
188 pr_debug("max clock-frequency is at %u kHz\n", max_freq);
189 pr_debug("initializing frequency table\n");
190
191 /* initialize frequency table */
192 for (i=0; pas_freqs[i].frequency!=CPUFREQ_TABLE_END; i++) {
193 pas_freqs[i].frequency = get_astate_freq(pas_freqs[i].index) * 100000;
194 pr_debug("%d: %d\n", i, pas_freqs[i].frequency);
195 }
196
197 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
198
199 policy->cpuinfo.transition_latency = get_gizmo_latency();
200
201 cur_astate = get_cur_astate(policy->cpu);
202 pr_debug("current astate is at %d\n",cur_astate);
203
204 policy->cur = pas_freqs[cur_astate].frequency;
205 policy->cpus = cpu_online_map;
206
207 cpufreq_frequency_table_get_attr(pas_freqs, policy->cpu);
208
209 /* this ensures that policy->cpuinfo_min and policy->cpuinfo_max
210 * are set correctly
211 */
212 return cpufreq_frequency_table_cpuinfo(policy, pas_freqs);
213
214out_unmap_sdcpwr:
215 iounmap(sdcpwr_mapbase);
216
217out_unmap_sdcasr:
218 iounmap(sdcasr_mapbase);
219out:
220 return err;
221}
222
223static int pas_cpufreq_cpu_exit(struct cpufreq_policy *policy)
224{
225 if (sdcasr_mapbase)
226 iounmap(sdcasr_mapbase);
227 if (sdcpwr_mapbase)
228 iounmap(sdcpwr_mapbase);
229
230 cpufreq_frequency_table_put_attr(policy->cpu);
231 return 0;
232}
233
234static int pas_cpufreq_verify(struct cpufreq_policy *policy)
235{
236 return cpufreq_frequency_table_verify(policy, pas_freqs);
237}
238
239static int pas_cpufreq_target(struct cpufreq_policy *policy,
240 unsigned int target_freq,
241 unsigned int relation)
242{
243 struct cpufreq_freqs freqs;
244 int pas_astate_new;
245 int i;
246
247 cpufreq_frequency_table_target(policy,
248 pas_freqs,
249 target_freq,
250 relation,
251 &pas_astate_new);
252
253 freqs.old = policy->cur;
254 freqs.new = pas_freqs[pas_astate_new].frequency;
255 freqs.cpu = policy->cpu;
256
257 mutex_lock(&pas_switch_mutex);
258 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
259
260 pr_debug("setting frequency for cpu %d to %d kHz, 1/%d of max frequency\n",
261 policy->cpu,
262 pas_freqs[pas_astate_new].frequency,
263 pas_freqs[pas_astate_new].index);
264
265 current_astate = pas_astate_new;
266
267 for_each_online_cpu(i)
268 set_astate(i, pas_astate_new);
269
270 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
271 mutex_unlock(&pas_switch_mutex);
272
273 return 0;
274}
275
276static struct cpufreq_driver pas_cpufreq_driver = {
277 .name = "pas-cpufreq",
278 .owner = THIS_MODULE,
279 .flags = CPUFREQ_CONST_LOOPS,
280 .init = pas_cpufreq_cpu_init,
281 .exit = pas_cpufreq_cpu_exit,
282 .verify = pas_cpufreq_verify,
283 .target = pas_cpufreq_target,
284 .attr = pas_cpu_freqs_attr,
285};
286
287/*
288 * module init and destoy
289 */
290
291static int __init pas_cpufreq_init(void)
292{
293 if (!machine_is_compatible("PA6T-1682M"))
294 return -ENODEV;
295
296 return cpufreq_register_driver(&pas_cpufreq_driver);
297}
298
299static void __exit pas_cpufreq_exit(void)
300{
301 cpufreq_unregister_driver(&pas_cpufreq_driver);
302}
303
304module_init(pas_cpufreq_init);
305module_exit(pas_cpufreq_exit);
306
307MODULE_LICENSE("GPL");
308MODULE_AUTHOR("Egor Martovetsky <egor@pasemi.com>, Olof Johansson <olof@lixom.net>");
diff --git a/arch/powerpc/platforms/pasemi/gpio_mdio.c b/arch/powerpc/platforms/pasemi/gpio_mdio.c
new file mode 100644
index 000000000000..c91a33593bb8
--- /dev/null
+++ b/arch/powerpc/platforms/pasemi/gpio_mdio.c
@@ -0,0 +1,339 @@
1/*
2 * Copyright (C) 2006-2007 PA Semi, Inc
3 *
4 * Author: Olof Johansson, PA Semi
5 *
6 * Maintained by: Olof Johansson <olof@lixom.net>
7 *
8 * Based on drivers/net/fs_enet/mii-bitbang.c.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#include <linux/io.h>
25#include <linux/module.h>
26#include <linux/types.h>
27#include <linux/sched.h>
28#include <linux/errno.h>
29#include <linux/ioport.h>
30#include <linux/interrupt.h>
31#include <linux/phy.h>
32#include <linux/platform_device.h>
33#include <asm/of_platform.h>
34
35#define DELAY 1
36
37static void __iomem *gpio_regs;
38
39struct gpio_priv {
40 int mdc_pin;
41 int mdio_pin;
42};
43
44#define MDC_PIN(bus) (((struct gpio_priv *)bus->priv)->mdc_pin)
45#define MDIO_PIN(bus) (((struct gpio_priv *)bus->priv)->mdio_pin)
46
47static inline void mdio_lo(struct mii_bus *bus)
48{
49 out_le32(gpio_regs+0x10, 1 << MDIO_PIN(bus));
50}
51
52static inline void mdio_hi(struct mii_bus *bus)
53{
54 out_le32(gpio_regs, 1 << MDIO_PIN(bus));
55}
56
57static inline void mdc_lo(struct mii_bus *bus)
58{
59 out_le32(gpio_regs+0x10, 1 << MDC_PIN(bus));
60}
61
62static inline void mdc_hi(struct mii_bus *bus)
63{
64 out_le32(gpio_regs, 1 << MDC_PIN(bus));
65}
66
67static inline void mdio_active(struct mii_bus *bus)
68{
69 out_le32(gpio_regs+0x20, (1 << MDC_PIN(bus)) | (1 << MDIO_PIN(bus)));
70}
71
72static inline void mdio_tristate(struct mii_bus *bus)
73{
74 out_le32(gpio_regs+0x30, (1 << MDIO_PIN(bus)));
75}
76
77static inline int mdio_read(struct mii_bus *bus)
78{
79 return !!(in_le32(gpio_regs+0x40) & (1 << MDIO_PIN(bus)));
80}
81
82static void clock_out(struct mii_bus *bus, int bit)
83{
84 if (bit)
85 mdio_hi(bus);
86 else
87 mdio_lo(bus);
88 udelay(DELAY);
89 mdc_hi(bus);
90 udelay(DELAY);
91 mdc_lo(bus);
92}
93
94/* Utility to send the preamble, address, and register (common to read and write). */
95static void bitbang_pre(struct mii_bus *bus, int read, u8 addr, u8 reg)
96{
97 int i;
98
99 /* CFE uses a really long preamble (40 bits). We'll do the same. */
100 mdio_active(bus);
101 for (i = 0; i < 40; i++) {
102 clock_out(bus, 1);
103 }
104
105 /* send the start bit (01) and the read opcode (10) or write (10) */
106 clock_out(bus, 0);
107 clock_out(bus, 1);
108
109 clock_out(bus, read);
110 clock_out(bus, !read);
111
112 /* send the PHY address */
113 for (i = 0; i < 5; i++) {
114 clock_out(bus, (addr & 0x10) != 0);
115 addr <<= 1;
116 }
117
118 /* send the register address */
119 for (i = 0; i < 5; i++) {
120 clock_out(bus, (reg & 0x10) != 0);
121 reg <<= 1;
122 }
123}
124
125static int gpio_mdio_read(struct mii_bus *bus, int phy_id, int location)
126{
127 u16 rdreg;
128 int ret, i;
129 u8 addr = phy_id & 0xff;
130 u8 reg = location & 0xff;
131
132 bitbang_pre(bus, 1, addr, reg);
133
134 /* tri-state our MDIO I/O pin so we can read */
135 mdio_tristate(bus);
136 udelay(DELAY);
137 mdc_hi(bus);
138 udelay(DELAY);
139 mdc_lo(bus);
140
141 /* read 16 bits of register data, MSB first */
142 rdreg = 0;
143 for (i = 0; i < 16; i++) {
144 mdc_lo(bus);
145 udelay(DELAY);
146 mdc_hi(bus);
147 udelay(DELAY);
148 mdc_lo(bus);
149 udelay(DELAY);
150 rdreg <<= 1;
151 rdreg |= mdio_read(bus);
152 }
153
154 mdc_hi(bus);
155 udelay(DELAY);
156 mdc_lo(bus);
157 udelay(DELAY);
158
159 ret = rdreg;
160
161 return ret;
162}
163
164static int gpio_mdio_write(struct mii_bus *bus, int phy_id, int location, u16 val)
165{
166 int i;
167
168 u8 addr = phy_id & 0xff;
169 u8 reg = location & 0xff;
170 u16 value = val & 0xffff;
171
172 bitbang_pre(bus, 0, addr, reg);
173
174 /* send the turnaround (10) */
175 mdc_lo(bus);
176 mdio_hi(bus);
177 udelay(DELAY);
178 mdc_hi(bus);
179 udelay(DELAY);
180 mdc_lo(bus);
181 mdio_lo(bus);
182 udelay(DELAY);
183 mdc_hi(bus);
184 udelay(DELAY);
185
186 /* write 16 bits of register data, MSB first */
187 for (i = 0; i < 16; i++) {
188 mdc_lo(bus);
189 if (value & 0x8000)
190 mdio_hi(bus);
191 else
192 mdio_lo(bus);
193 udelay(DELAY);
194 mdc_hi(bus);
195 udelay(DELAY);
196 value <<= 1;
197 }
198
199 /*
200 * Tri-state the MDIO line.
201 */
202 mdio_tristate(bus);
203 mdc_lo(bus);
204 udelay(DELAY);
205 mdc_hi(bus);
206 udelay(DELAY);
207 return 0;
208}
209
210static int gpio_mdio_reset(struct mii_bus *bus)
211{
212 /*nothing here - dunno how to reset it*/
213 return 0;
214}
215
216
217static int __devinit gpio_mdio_probe(struct of_device *ofdev,
218 const struct of_device_id *match)
219{
220 struct device *dev = &ofdev->dev;
221 struct device_node *np = ofdev->node;
222 struct device_node *gpio_np;
223 struct mii_bus *new_bus;
224 struct resource res;
225 struct gpio_priv *priv;
226 const unsigned int *prop;
227 int err = 0;
228 int i;
229
230 gpio_np = of_find_compatible_node(NULL, "gpio", "1682m-gpio");
231
232 if (!gpio_np)
233 return -ENODEV;
234
235 err = of_address_to_resource(gpio_np, 0, &res);
236 of_node_put(gpio_np);
237
238 if (err)
239 return -EINVAL;
240
241 if (!gpio_regs)
242 gpio_regs = ioremap(res.start, 0x100);
243
244 if (!gpio_regs)
245 return -EPERM;
246
247 priv = kzalloc(sizeof(struct gpio_priv), GFP_KERNEL);
248 if (priv == NULL)
249 return -ENOMEM;
250
251 new_bus = kzalloc(sizeof(struct mii_bus), GFP_KERNEL);
252
253 if (new_bus == NULL)
254 return -ENOMEM;
255
256 new_bus->name = "pasemi gpio mdio bus",
257 new_bus->read = &gpio_mdio_read,
258 new_bus->write = &gpio_mdio_write,
259 new_bus->reset = &gpio_mdio_reset,
260
261 prop = of_get_property(np, "reg", NULL);
262 new_bus->id = *prop;
263 new_bus->priv = priv;
264
265 new_bus->phy_mask = 0;
266
267 new_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
268 for(i = 0; i < PHY_MAX_ADDR; ++i)
269 new_bus->irq[i] = irq_create_mapping(NULL, 10);
270
271
272 prop = of_get_property(np, "mdc-pin", NULL);
273 priv->mdc_pin = *prop;
274
275 prop = of_get_property(np, "mdio-pin", NULL);
276 priv->mdio_pin = *prop;
277
278 new_bus->dev = dev;
279 dev_set_drvdata(dev, new_bus);
280
281 err = mdiobus_register(new_bus);
282
283 if (0 != err) {
284 printk(KERN_ERR "%s: Cannot register as MDIO bus, err %d\n",
285 new_bus->name, err);
286 goto bus_register_fail;
287 }
288
289 return 0;
290
291bus_register_fail:
292 kfree(new_bus);
293
294 return err;
295}
296
297
298static int gpio_mdio_remove(struct of_device *dev)
299{
300 struct mii_bus *bus = dev_get_drvdata(&dev->dev);
301
302 mdiobus_unregister(bus);
303
304 dev_set_drvdata(&dev->dev, NULL);
305
306 kfree(bus->priv);
307 bus->priv = NULL;
308 kfree(bus);
309
310 return 0;
311}
312
313static struct of_device_id gpio_mdio_match[] =
314{
315 {
316 .compatible = "gpio-mdio",
317 },
318 {},
319};
320
321static struct of_platform_driver gpio_mdio_driver =
322{
323 .name = "gpio-mdio-bitbang",
324 .match_table = gpio_mdio_match,
325 .probe = gpio_mdio_probe,
326 .remove = gpio_mdio_remove,
327};
328
329int gpio_mdio_init(void)
330{
331 return of_register_platform_driver(&gpio_mdio_driver);
332}
333
334void gpio_mdio_exit(void)
335{
336 of_unregister_platform_driver(&gpio_mdio_driver);
337}
338device_initcall(gpio_mdio_init);
339
diff --git a/arch/powerpc/platforms/pasemi/idle.c b/arch/powerpc/platforms/pasemi/idle.c
index 1ca3ff381591..5985ce0c5c48 100644
--- a/arch/powerpc/platforms/pasemi/idle.c
+++ b/arch/powerpc/platforms/pasemi/idle.c
@@ -61,6 +61,10 @@ static int pasemi_system_reset_exception(struct pt_regs *regs)
61 /* do system reset */ 61 /* do system reset */
62 return 0; 62 return 0;
63 } 63 }
64
65 /* Set higher astate since we come out of power savings at 0 */
66 restore_astate(hard_smp_processor_id());
67
64 /* everything handled */ 68 /* everything handled */
65 regs->msr |= MSR_RI; 69 regs->msr |= MSR_RI;
66 return 1; 70 return 1;
@@ -68,6 +72,11 @@ static int pasemi_system_reset_exception(struct pt_regs *regs)
68 72
69void __init pasemi_idle_init(void) 73void __init pasemi_idle_init(void)
70{ 74{
75#ifndef CONFIG_PPC_PASEMI_CPUFREQ
76 printk(KERN_WARNING "No cpufreq driver, powersavings modes disabled\n");
77 current_mode = 0;
78#endif
79
71 ppc_md.system_reset_exception = pasemi_system_reset_exception; 80 ppc_md.system_reset_exception = pasemi_system_reset_exception;
72 ppc_md.power_save = modes[current_mode].entry; 81 ppc_md.power_save = modes[current_mode].entry;
73 printk(KERN_INFO "Using PA6T idle loop (%s)\n", modes[current_mode].name); 82 printk(KERN_INFO "Using PA6T idle loop (%s)\n", modes[current_mode].name);
diff --git a/arch/powerpc/platforms/pasemi/iommu.c b/arch/powerpc/platforms/pasemi/iommu.c
index 71dbf1a56e13..95fa6a7d15ee 100644
--- a/arch/powerpc/platforms/pasemi/iommu.c
+++ b/arch/powerpc/platforms/pasemi/iommu.c
@@ -249,13 +249,13 @@ void iommu_init_early_pasemi(void)
249 iommu_off = 1; 249 iommu_off = 1;
250#else 250#else
251 iommu_off = of_chosen && 251 iommu_off = of_chosen &&
252 get_property(of_chosen, "linux,iommu-off", NULL); 252 of_get_property(of_chosen, "linux,iommu-off", NULL);
253#endif 253#endif
254 if (iommu_off) { 254 if (iommu_off) {
255 /* Direct I/O, IOMMU off */ 255 /* Direct I/O, IOMMU off */
256 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_null; 256 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_null;
257 ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_null; 257 ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_null;
258 pci_dma_ops = &dma_direct_ops; 258 set_pci_dma_ops(&dma_direct_ops);
259 259
260 return; 260 return;
261 } 261 }
@@ -266,7 +266,7 @@ void iommu_init_early_pasemi(void)
266 ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_pasemi; 266 ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_pasemi;
267 ppc_md.tce_build = iobmap_build; 267 ppc_md.tce_build = iobmap_build;
268 ppc_md.tce_free = iobmap_free; 268 ppc_md.tce_free = iobmap_free;
269 pci_dma_ops = &dma_iommu_ops; 269 set_pci_dma_ops(&dma_iommu_ops);
270} 270}
271 271
272void __init alloc_iobmap_l2(void) 272void __init alloc_iobmap_l2(void)
diff --git a/arch/powerpc/platforms/pasemi/pasemi.h b/arch/powerpc/platforms/pasemi/pasemi.h
index 2d3927e6edb0..be8495497611 100644
--- a/arch/powerpc/platforms/pasemi/pasemi.h
+++ b/arch/powerpc/platforms/pasemi/pasemi.h
@@ -14,6 +14,14 @@ extern void __init pasemi_idle_init(void);
14extern void idle_spin(void); 14extern void idle_spin(void);
15extern void idle_doze(void); 15extern void idle_doze(void);
16 16
17/* Restore astate to last set */
18#ifdef CONFIG_PPC_PASEMI_CPUFREQ
19extern void restore_astate(int cpu);
20#else
21static inline void restore_astate(int cpu)
22{
23}
24#endif
17 25
18 26
19#endif /* _PASEMI_PASEMI_H */ 27#endif /* _PASEMI_PASEMI_H */
diff --git a/arch/powerpc/platforms/pasemi/pci.c b/arch/powerpc/platforms/pasemi/pci.c
index 7ecb2ba24db9..056243da360b 100644
--- a/arch/powerpc/platforms/pasemi/pci.c
+++ b/arch/powerpc/platforms/pasemi/pci.c
@@ -33,7 +33,17 @@
33 33
34#define PA_PXP_CFA(bus, devfn, off) (((bus) << 20) | ((devfn) << 12) | (off)) 34#define PA_PXP_CFA(bus, devfn, off) (((bus) << 20) | ((devfn) << 12) | (off))
35 35
36#define CONFIG_OFFSET_VALID(off) ((off) < 4096) 36static inline int pa_pxp_offset_valid(u8 bus, u8 devfn, int offset)
37{
38 /* Device 0 Function 0 is special: It's config space spans function 1 as
39 * well, so allow larger offset. It's really a two-function device but the
40 * second function does not probe.
41 */
42 if (bus == 0 && devfn == 0)
43 return offset < 8192;
44 else
45 return offset < 4096;
46}
37 47
38static void volatile __iomem *pa_pxp_cfg_addr(struct pci_controller *hose, 48static void volatile __iomem *pa_pxp_cfg_addr(struct pci_controller *hose,
39 u8 bus, u8 devfn, int offset) 49 u8 bus, u8 devfn, int offset)
@@ -51,7 +61,7 @@ static int pa_pxp_read_config(struct pci_bus *bus, unsigned int devfn,
51 if (!hose) 61 if (!hose)
52 return PCIBIOS_DEVICE_NOT_FOUND; 62 return PCIBIOS_DEVICE_NOT_FOUND;
53 63
54 if (!CONFIG_OFFSET_VALID(offset)) 64 if (!pa_pxp_offset_valid(bus->number, devfn, offset))
55 return PCIBIOS_BAD_REGISTER_NUMBER; 65 return PCIBIOS_BAD_REGISTER_NUMBER;
56 66
57 addr = pa_pxp_cfg_addr(hose, bus->number, devfn, offset); 67 addr = pa_pxp_cfg_addr(hose, bus->number, devfn, offset);
@@ -85,7 +95,7 @@ static int pa_pxp_write_config(struct pci_bus *bus, unsigned int devfn,
85 if (!hose) 95 if (!hose)
86 return PCIBIOS_DEVICE_NOT_FOUND; 96 return PCIBIOS_DEVICE_NOT_FOUND;
87 97
88 if (!CONFIG_OFFSET_VALID(offset)) 98 if (!pa_pxp_offset_valid(bus->number, devfn, offset))
89 return PCIBIOS_BAD_REGISTER_NUMBER; 99 return PCIBIOS_BAD_REGISTER_NUMBER;
90 100
91 addr = pa_pxp_cfg_addr(hose, bus->number, devfn, offset); 101 addr = pa_pxp_cfg_addr(hose, bus->number, devfn, offset);
diff --git a/arch/powerpc/platforms/pasemi/setup.c b/arch/powerpc/platforms/pasemi/setup.c
index 449cf1a08291..f88f0ec4c8cb 100644
--- a/arch/powerpc/platforms/pasemi/setup.c
+++ b/arch/powerpc/platforms/pasemi/setup.c
@@ -35,6 +35,7 @@
35#include <asm/mpic.h> 35#include <asm/mpic.h>
36#include <asm/smp.h> 36#include <asm/smp.h>
37#include <asm/time.h> 37#include <asm/time.h>
38#include <asm/of_platform.h>
38 39
39#include "pasemi.h" 40#include "pasemi.h"
40 41
@@ -101,12 +102,6 @@ void __init pas_setup_arch(void)
101 pasemi_idle_init(); 102 pasemi_idle_init();
102} 103}
103 104
104/* No legacy IO on our parts */
105static int pas_check_legacy_ioport(unsigned int baseport)
106{
107 return -ENODEV;
108}
109
110static __init void pas_init_IRQ(void) 105static __init void pas_init_IRQ(void)
111{ 106{
112 struct device_node *np; 107 struct device_node *np;
@@ -136,8 +131,8 @@ static __init void pas_init_IRQ(void)
136 131
137 /* Find address list in /platform-open-pic */ 132 /* Find address list in /platform-open-pic */
138 root = of_find_node_by_path("/"); 133 root = of_find_node_by_path("/");
139 naddr = prom_n_addr_cells(root); 134 naddr = of_n_addr_cells(root);
140 opprop = get_property(root, "platform-open-pic", &opplen); 135 opprop = of_get_property(root, "platform-open-pic", &opplen);
141 if (!opprop) { 136 if (!opprop) {
142 printk(KERN_ERR "No platform-open-pic property.\n"); 137 printk(KERN_ERR "No platform-open-pic property.\n");
143 of_node_put(root); 138 of_node_put(root);
@@ -147,7 +142,7 @@ static __init void pas_init_IRQ(void)
147 printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr); 142 printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr);
148 143
149 mpic = mpic_alloc(mpic_node, openpic_addr, 144 mpic = mpic_alloc(mpic_node, openpic_addr,
150 MPIC_PRIMARY|MPIC_LARGE_VECTORS, 145 MPIC_PRIMARY|MPIC_LARGE_VECTORS|MPIC_WANTS_RESET,
151 0, 0, " PAS-OPIC "); 146 0, 0, " PAS-OPIC ");
152 BUG_ON(!mpic); 147 BUG_ON(!mpic);
153 148
@@ -209,6 +204,20 @@ static void __init pas_init_early(void)
209 iommu_init_early_pasemi(); 204 iommu_init_early_pasemi();
210} 205}
211 206
207static struct of_device_id pasemi_bus_ids[] = {
208 { .type = "sdc", },
209 {},
210};
211
212static int __init pasemi_publish_devices(void)
213{
214 /* Publish OF platform devices for southbridge IOs */
215 of_platform_bus_probe(NULL, pasemi_bus_ids, NULL);
216
217 return 0;
218}
219device_initcall(pasemi_publish_devices);
220
212 221
213/* 222/*
214 * Called very early, MMU is off, device-tree isn't unflattened 223 * Called very early, MMU is off, device-tree isn't unflattened
@@ -237,7 +246,6 @@ define_machine(pas) {
237 .restart = pas_restart, 246 .restart = pas_restart,
238 .get_boot_time = pas_get_boot_time, 247 .get_boot_time = pas_get_boot_time,
239 .calibrate_decr = generic_calibrate_decr, 248 .calibrate_decr = generic_calibrate_decr,
240 .check_legacy_ioport = pas_check_legacy_ioport,
241 .progress = pas_progress, 249 .progress = pas_progress,
242 .machine_check_exception = pas_machine_check_handler, 250 .machine_check_exception = pas_machine_check_handler,
243 .pci_irq_fixup = pas_pci_irq_fixup, 251 .pci_irq_fixup = pas_pci_irq_fixup,
diff --git a/arch/powerpc/platforms/powermac/Kconfig b/arch/powerpc/platforms/powermac/Kconfig
new file mode 100644
index 000000000000..5b7afe50039a
--- /dev/null
+++ b/arch/powerpc/platforms/powermac/Kconfig
@@ -0,0 +1,20 @@
1config PPC_PMAC
2 bool "Apple PowerMac based machines"
3 depends on PPC_MULTIPLATFORM
4 select MPIC
5 select PPC_INDIRECT_PCI if PPC32
6 select PPC_MPC106 if PPC32
7 select PPC_NATIVE
8 default y
9
10config PPC_PMAC64
11 bool
12 depends on PPC_PMAC && POWER4
13 select MPIC
14 select U3_DART
15 select MPIC_U3_HT_IRQS
16 select GENERIC_TBSYNC
17 select PPC_970_NAP
18 default y
19
20
diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c
index de7440e62cc4..d679964ae2ab 100644
--- a/arch/powerpc/platforms/powermac/backlight.c
+++ b/arch/powerpc/platforms/powermac/backlight.c
@@ -56,13 +56,16 @@ struct backlight_device *pmac_backlight;
56 56
57int pmac_has_backlight_type(const char *type) 57int pmac_has_backlight_type(const char *type)
58{ 58{
59 struct device_node* bk_node = find_devices("backlight"); 59 struct device_node* bk_node = of_find_node_by_name(NULL, "backlight");
60 60
61 if (bk_node) { 61 if (bk_node) {
62 const char *prop = get_property(bk_node, 62 const char *prop = of_get_property(bk_node,
63 "backlight-control", NULL); 63 "backlight-control", NULL);
64 if (prop && strncmp(prop, type, strlen(type)) == 0) 64 if (prop && strncmp(prop, type, strlen(type)) == 0) {
65 of_node_put(bk_node);
65 return 1; 66 return 1;
67 }
68 of_node_put(bk_node);
66 } 69 }
67 70
68 return 0; 71 return 0;
diff --git a/arch/powerpc/platforms/powermac/cpufreq_32.c b/arch/powerpc/platforms/powermac/cpufreq_32.c
index c2b6b4134f68..8943a9456bb7 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 const u32 *reg = get_property(np, "reg", NULL); 424 const u32 *reg = of_get_property(np, "reg", NULL);
425 u32 offset; 425 u32 offset;
426 426
427 if (reg == NULL) 427 if (reg == NULL)
@@ -521,13 +521,14 @@ static int pmac_cpufreq_init_MacRISC3(struct device_node *cpunode)
521 int lenp, rc; 521 int lenp, rc;
522 const u32 *freqs, *ratio; 522 const u32 *freqs, *ratio;
523 523
524 freqs = get_property(cpunode, "bus-frequencies", &lenp); 524 freqs = of_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 = get_property(cpunode, "processor-to-bus-ratio*2", NULL); 530 ratio = of_get_property(cpunode, "processor-to-bus-ratio*2",
531 NULL);
531 if (ratio == NULL) { 532 if (ratio == NULL) {
532 printk(KERN_ERR "cpufreq: processor-to-bus-ratio*2 missing\n"); 533 printk(KERN_ERR "cpufreq: processor-to-bus-ratio*2 missing\n");
533 return 1; 534 return 1;
@@ -562,7 +563,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 563 /* If we use the PMU, look for the min & max frequencies in the
563 * device-tree 564 * device-tree
564 */ 565 */
565 value = get_property(cpunode, "min-clock-frequency", NULL); 566 value = of_get_property(cpunode, "min-clock-frequency", NULL);
566 if (!value) 567 if (!value)
567 return 1; 568 return 1;
568 low_freq = (*value) / 1000; 569 low_freq = (*value) / 1000;
@@ -571,7 +572,7 @@ static int pmac_cpufreq_init_MacRISC3(struct device_node *cpunode)
571 if (low_freq < 100000) 572 if (low_freq < 100000)
572 low_freq *= 10; 573 low_freq *= 10;
573 574
574 value = get_property(cpunode, "max-clock-frequency", NULL); 575 value = of_get_property(cpunode, "max-clock-frequency", NULL);
575 if (!value) 576 if (!value)
576 return 1; 577 return 1;
577 hi_freq = (*value) / 1000; 578 hi_freq = (*value) / 1000;
@@ -585,7 +586,7 @@ static int pmac_cpufreq_init_7447A(struct device_node *cpunode)
585{ 586{
586 struct device_node *volt_gpio_np; 587 struct device_node *volt_gpio_np;
587 588
588 if (get_property(cpunode, "dynamic-power-step", NULL) == NULL) 589 if (of_get_property(cpunode, "dynamic-power-step", NULL) == NULL)
589 return 1; 590 return 1;
590 591
591 volt_gpio_np = of_find_node_by_name(NULL, "cpu-vcore-select"); 592 volt_gpio_np = of_find_node_by_name(NULL, "cpu-vcore-select");
@@ -614,11 +615,11 @@ static int pmac_cpufreq_init_750FX(struct device_node *cpunode)
614 u32 pvr; 615 u32 pvr;
615 const u32 *value; 616 const u32 *value;
616 617
617 if (get_property(cpunode, "dynamic-power-step", NULL) == NULL) 618 if (of_get_property(cpunode, "dynamic-power-step", NULL) == NULL)
618 return 1; 619 return 1;
619 620
620 hi_freq = cur_freq; 621 hi_freq = cur_freq;
621 value = get_property(cpunode, "reduced-clock-frequency", NULL); 622 value = of_get_property(cpunode, "reduced-clock-frequency", NULL);
622 if (!value) 623 if (!value)
623 return 1; 624 return 1;
624 low_freq = (*value) / 1000; 625 low_freq = (*value) / 1000;
@@ -657,19 +658,19 @@ static int __init pmac_cpufreq_setup(void)
657 return 0; 658 return 0;
658 659
659 /* Assume only one CPU */ 660 /* Assume only one CPU */
660 cpunode = find_type_devices("cpu"); 661 cpunode = of_find_node_by_type(NULL, "cpu");
661 if (!cpunode) 662 if (!cpunode)
662 goto out; 663 goto out;
663 664
664 /* Get current cpu clock freq */ 665 /* Get current cpu clock freq */
665 value = get_property(cpunode, "clock-frequency", NULL); 666 value = of_get_property(cpunode, "clock-frequency", NULL);
666 if (!value) 667 if (!value)
667 goto out; 668 goto out;
668 cur_freq = (*value) / 1000; 669 cur_freq = (*value) / 1000;
669 670
670 /* Check for 7447A based MacRISC3 */ 671 /* Check for 7447A based MacRISC3 */
671 if (machine_is_compatible("MacRISC3") && 672 if (machine_is_compatible("MacRISC3") &&
672 get_property(cpunode, "dynamic-power-step", NULL) && 673 of_get_property(cpunode, "dynamic-power-step", NULL) &&
673 PVR_VER(mfspr(SPRN_PVR)) == 0x8003) { 674 PVR_VER(mfspr(SPRN_PVR)) == 0x8003) {
674 pmac_cpufreq_init_7447A(cpunode); 675 pmac_cpufreq_init_7447A(cpunode);
675 /* Check for other MacRISC3 machines */ 676 /* Check for other MacRISC3 machines */
@@ -707,6 +708,7 @@ static int __init pmac_cpufreq_setup(void)
707 else if (PVR_VER(mfspr(SPRN_PVR)) == 0x7000) 708 else if (PVR_VER(mfspr(SPRN_PVR)) == 0x7000)
708 pmac_cpufreq_init_750FX(cpunode); 709 pmac_cpufreq_init_750FX(cpunode);
709out: 710out:
711 of_node_put(cpunode);
710 if (set_speed_proc == NULL) 712 if (set_speed_proc == NULL)
711 return -ENODEV; 713 return -ENODEV;
712 714
diff --git a/arch/powerpc/platforms/powermac/cpufreq_64.c b/arch/powerpc/platforms/powermac/cpufreq_64.c
index 9d22361a26d6..567d5523b690 100644
--- a/arch/powerpc/platforms/powermac/cpufreq_64.c
+++ b/arch/powerpc/platforms/powermac/cpufreq_64.c
@@ -410,7 +410,7 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
410 /* Get first CPU node */ 410 /* Get first CPU node */
411 for (cpunode = NULL; 411 for (cpunode = NULL;
412 (cpunode = of_get_next_child(cpus, cpunode)) != NULL;) { 412 (cpunode = of_get_next_child(cpus, cpunode)) != NULL;) {
413 const u32 *reg = get_property(cpunode, "reg", NULL); 413 const u32 *reg = of_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 = get_property(cpunode, "cpu-version", NULL); 425 valp = of_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 = get_property(cpunode, "power-mode-data",&psize); 437 g5_pmode_data = of_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;
@@ -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 = get_property(cpunode, "clock-frequency", NULL); 496 valp = of_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;
@@ -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 = get_property(cpuid, "cpuid", NULL); 566 eeprom = of_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,13 +573,13 @@ 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 const char *loc = get_property(hwclock, 576 const char *loc = of_get_property(hwclock,
577 "hwctrl-location", NULL); 577 "hwctrl-location", NULL);
578 if (loc == NULL) 578 if (loc == NULL)
579 continue; 579 continue;
580 if (strcmp(loc, "CPU CLOCK")) 580 if (strcmp(loc, "CPU CLOCK"))
581 continue; 581 continue;
582 if (!get_property(hwclock, "platform-get-frequency", NULL)) 582 if (!of_get_property(hwclock, "platform-get-frequency", NULL))
583 continue; 583 continue;
584 break; 584 break;
585 } 585 }
@@ -638,7 +638,7 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpus)
638 */ 638 */
639 639
640 /* Get max frequency from device-tree */ 640 /* Get max frequency from device-tree */
641 valp = get_property(cpunode, "clock-frequency", NULL); 641 valp = of_get_property(cpunode, "clock-frequency", NULL);
642 if (!valp) { 642 if (!valp) {
643 printk(KERN_ERR "cpufreq: Can't find CPU frequency !\n"); 643 printk(KERN_ERR "cpufreq: Can't find CPU frequency !\n");
644 rc = -ENODEV; 644 rc = -ENODEV;
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c
index 24cc50c1774a..52cfdd86c928 100644
--- a/arch/powerpc/platforms/powermac/feature.c
+++ b/arch/powerpc/platforms/powermac/feature.c
@@ -1044,6 +1044,7 @@ core99_reset_cpu(struct device_node *node, long param, long value)
1044 unsigned long flags; 1044 unsigned long flags;
1045 struct macio_chip *macio; 1045 struct macio_chip *macio;
1046 struct device_node *np; 1046 struct device_node *np;
1047 struct device_node *cpus;
1047 const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0, 1048 const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0,
1048 KL_GPIO_RESET_CPU1, 1049 KL_GPIO_RESET_CPU1,
1049 KL_GPIO_RESET_CPU2, 1050 KL_GPIO_RESET_CPU2,
@@ -1053,12 +1054,12 @@ core99_reset_cpu(struct device_node *node, long param, long value)
1053 if (macio->type != macio_keylargo) 1054 if (macio->type != macio_keylargo)
1054 return -ENODEV; 1055 return -ENODEV;
1055 1056
1056 np = find_path_device("/cpus"); 1057 cpus = of_find_node_by_path("/cpus");
1057 if (np == NULL) 1058 if (cpus == NULL)
1058 return -ENODEV; 1059 return -ENODEV;
1059 for (np = np->child; np != NULL; np = np->sibling) { 1060 for (np = cpus->child; np != NULL; np = np->sibling) {
1060 const u32 *num = get_property(np, "reg", NULL); 1061 const u32 *num = of_get_property(np, "reg", NULL);
1061 const u32 *rst = get_property(np, "soft-reset", NULL); 1062 const u32 *rst = of_get_property(np, "soft-reset", NULL);
1062 if (num == NULL || rst == NULL) 1063 if (num == NULL || rst == NULL)
1063 continue; 1064 continue;
1064 if (param == *num) { 1065 if (param == *num) {
@@ -1066,6 +1067,7 @@ core99_reset_cpu(struct device_node *node, long param, long value)
1066 break; 1067 break;
1067 } 1068 }
1068 } 1069 }
1070 of_node_put(cpus);
1069 if (np == NULL || reset_io == 0) 1071 if (np == NULL || reset_io == 0)
1070 reset_io = dflt_reset_lines[param]; 1072 reset_io = dflt_reset_lines[param];
1071 1073
@@ -1095,7 +1097,7 @@ core99_usb_enable(struct device_node *node, long param, long value)
1095 macio->type != macio_intrepid) 1097 macio->type != macio_intrepid)
1096 return -ENODEV; 1098 return -ENODEV;
1097 1099
1098 prop = get_property(node, "AAPL,clock-id", NULL); 1100 prop = of_get_property(node, "AAPL,clock-id", NULL);
1099 if (!prop) 1101 if (!prop)
1100 return -ENODEV; 1102 return -ENODEV;
1101 if (strncmp(prop, "usb0u048", 8) == 0) 1103 if (strncmp(prop, "usb0u048", 8) == 0)
@@ -1497,17 +1499,18 @@ static long g5_reset_cpu(struct device_node *node, long param, long value)
1497 unsigned long flags; 1499 unsigned long flags;
1498 struct macio_chip *macio; 1500 struct macio_chip *macio;
1499 struct device_node *np; 1501 struct device_node *np;
1502 struct device_node *cpus;
1500 1503
1501 macio = &macio_chips[0]; 1504 macio = &macio_chips[0];
1502 if (macio->type != macio_keylargo2 && macio->type != macio_shasta) 1505 if (macio->type != macio_keylargo2 && macio->type != macio_shasta)
1503 return -ENODEV; 1506 return -ENODEV;
1504 1507
1505 np = find_path_device("/cpus"); 1508 cpus = of_find_node_by_path("/cpus");
1506 if (np == NULL) 1509 if (cpus == NULL)
1507 return -ENODEV; 1510 return -ENODEV;
1508 for (np = np->child; np != NULL; np = np->sibling) { 1511 for (np = cpus->child; np != NULL; np = np->sibling) {
1509 const u32 *num = get_property(np, "reg", NULL); 1512 const u32 *num = of_get_property(np, "reg", NULL);
1510 const u32 *rst = get_property(np, "soft-reset", NULL); 1513 const u32 *rst = of_get_property(np, "soft-reset", NULL);
1511 if (num == NULL || rst == NULL) 1514 if (num == NULL || rst == NULL)
1512 continue; 1515 continue;
1513 if (param == *num) { 1516 if (param == *num) {
@@ -1515,6 +1518,7 @@ static long g5_reset_cpu(struct device_node *node, long param, long value)
1515 break; 1518 break;
1516 } 1519 }
1517 } 1520 }
1521 of_node_put(cpus);
1518 if (np == NULL || reset_io == 0) 1522 if (np == NULL || reset_io == 0)
1519 return -ENODEV; 1523 return -ENODEV;
1520 1524
@@ -2404,14 +2408,15 @@ static int __init probe_motherboard(void)
2404 struct macio_chip *macio = &macio_chips[0]; 2408 struct macio_chip *macio = &macio_chips[0];
2405 const char *model = NULL; 2409 const char *model = NULL;
2406 struct device_node *dt; 2410 struct device_node *dt;
2411 int ret = 0;
2407 2412
2408 /* Lookup known motherboard type in device-tree. First try an 2413 /* Lookup known motherboard type in device-tree. First try an
2409 * exact match on the "model" property, then try a "compatible" 2414 * exact match on the "model" property, then try a "compatible"
2410 * match is none is found. 2415 * match is none is found.
2411 */ 2416 */
2412 dt = find_devices("device-tree"); 2417 dt = of_find_node_by_name(NULL, "device-tree");
2413 if (dt != NULL) 2418 if (dt != NULL)
2414 model = get_property(dt, "model", NULL); 2419 model = of_get_property(dt, "model", NULL);
2415 for(i=0; model && i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) { 2420 for(i=0; model && i<(sizeof(pmac_mb_defs)/sizeof(struct pmac_mb_def)); i++) {
2416 if (strcmp(model, pmac_mb_defs[i].model_string) == 0) { 2421 if (strcmp(model, pmac_mb_defs[i].model_string) == 0) {
2417 pmac_mb = pmac_mb_defs[i]; 2422 pmac_mb = pmac_mb_defs[i];
@@ -2474,15 +2479,18 @@ static int __init probe_motherboard(void)
2474 break; 2479 break;
2475#endif /* CONFIG_POWER4 */ 2480#endif /* CONFIG_POWER4 */
2476 default: 2481 default:
2477 return -ENODEV; 2482 ret = -ENODEV;
2483 goto done;
2478 } 2484 }
2479found: 2485found:
2480#ifndef CONFIG_POWER4 2486#ifndef CONFIG_POWER4
2481 /* Fixup Hooper vs. Comet */ 2487 /* Fixup Hooper vs. Comet */
2482 if (pmac_mb.model_id == PMAC_TYPE_HOOPER) { 2488 if (pmac_mb.model_id == PMAC_TYPE_HOOPER) {
2483 u32 __iomem * mach_id_ptr = ioremap(0xf3000034, 4); 2489 u32 __iomem * mach_id_ptr = ioremap(0xf3000034, 4);
2484 if (!mach_id_ptr) 2490 if (!mach_id_ptr) {
2485 return -ENODEV; 2491 ret = -ENODEV;
2492 goto done;
2493 }
2486 /* Here, I used to disable the media-bay on comet. It 2494 /* Here, I used to disable the media-bay on comet. It
2487 * appears this is wrong, the floppy connector is actually 2495 * appears this is wrong, the floppy connector is actually
2488 * a kind of media-bay and works with the current driver. 2496 * a kind of media-bay and works with the current driver.
@@ -2499,18 +2507,26 @@ found:
2499 * that all Apple OF revs did it properly, I do it the paranoid way. 2507 * that all Apple OF revs did it properly, I do it the paranoid way.
2500 */ 2508 */
2501 while (uninorth_base && uninorth_rev > 3) { 2509 while (uninorth_base && uninorth_rev > 3) {
2502 struct device_node *np = find_path_device("/cpus"); 2510 struct device_node *cpus = of_find_node_by_path("/cpus");
2503 if (!np || !np->child) { 2511 struct device_node *np;
2512
2513 if (!cpus || !cpus->child) {
2504 printk(KERN_WARNING "Can't find CPU(s) in device tree !\n"); 2514 printk(KERN_WARNING "Can't find CPU(s) in device tree !\n");
2515 of_node_put(cpus);
2505 break; 2516 break;
2506 } 2517 }
2507 np = np->child; 2518 np = cpus->child;
2508 /* Nap mode not supported on SMP */ 2519 /* Nap mode not supported on SMP */
2509 if (np->sibling) 2520 if (np->sibling) {
2521 of_node_put(cpus);
2510 break; 2522 break;
2523 }
2511 /* Nap mode not supported if flush-on-lock property is present */ 2524 /* Nap mode not supported if flush-on-lock property is present */
2512 if (get_property(np, "flush-on-lock", NULL)) 2525 if (of_get_property(np, "flush-on-lock", NULL)) {
2526 of_node_put(cpus);
2513 break; 2527 break;
2528 }
2529 of_node_put(cpus);
2514 powersave_nap = 1; 2530 powersave_nap = 1;
2515 printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n"); 2531 printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n");
2516 break; 2532 break;
@@ -2532,7 +2548,9 @@ found:
2532 2548
2533 2549
2534 printk(KERN_INFO "PowerMac motherboard: %s\n", pmac_mb.model_name); 2550 printk(KERN_INFO "PowerMac motherboard: %s\n", pmac_mb.model_name);
2535 return 0; 2551done:
2552 of_node_put(dt);
2553 return ret;
2536} 2554}
2537 2555
2538/* Initialize the Core99 UniNorth host bridge and memory controller 2556/* Initialize the Core99 UniNorth host bridge and memory controller
@@ -2558,7 +2576,7 @@ static void __init probe_uninorth(void)
2558 if (uninorth_node == NULL) 2576 if (uninorth_node == NULL)
2559 return; 2577 return;
2560 2578
2561 addrp = get_property(uninorth_node, "reg", NULL); 2579 addrp = of_get_property(uninorth_node, "reg", NULL);
2562 if (addrp == NULL) 2580 if (addrp == NULL)
2563 return; 2581 return;
2564 address = of_translate_address(uninorth_node, addrp); 2582 address = of_translate_address(uninorth_node, addrp);
@@ -2642,7 +2660,7 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ
2642 return; 2660 return;
2643 } 2661 }
2644 if (type == macio_keylargo || type == macio_keylargo2) { 2662 if (type == macio_keylargo || type == macio_keylargo2) {
2645 const u32 *did = get_property(node, "device-id", NULL); 2663 const u32 *did = of_get_property(node, "device-id", NULL);
2646 if (*did == 0x00000025) 2664 if (*did == 0x00000025)
2647 type = macio_pangea; 2665 type = macio_pangea;
2648 if (*did == 0x0000003e) 2666 if (*did == 0x0000003e)
@@ -2655,7 +2673,7 @@ static void __init probe_one_macio(const char *name, const char *compat, int typ
2655 macio_chips[i].base = base; 2673 macio_chips[i].base = base;
2656 macio_chips[i].flags = MACIO_FLAG_SCCB_ON | MACIO_FLAG_SCCB_ON; 2674 macio_chips[i].flags = MACIO_FLAG_SCCB_ON | MACIO_FLAG_SCCB_ON;
2657 macio_chips[i].name = macio_names[type]; 2675 macio_chips[i].name = macio_names[type];
2658 revp = get_property(node, "revision-id", NULL); 2676 revp = of_get_property(node, "revision-id", NULL);
2659 if (revp) 2677 if (revp)
2660 macio_chips[i].rev = *revp; 2678 macio_chips[i].rev = *revp;
2661 printk(KERN_INFO "Found a %s mac-io controller, rev: %d, mapped at 0x%p\n", 2679 printk(KERN_INFO "Found a %s mac-io controller, rev: %d, mapped at 0x%p\n",
@@ -2706,8 +2724,8 @@ initial_serial_shutdown(struct device_node *np)
2706 int port_type = PMAC_SCC_ASYNC; 2724 int port_type = PMAC_SCC_ASYNC;
2707 int modem = 0; 2725 int modem = 0;
2708 2726
2709 slots = get_property(np, "slot-names", &len); 2727 slots = of_get_property(np, "slot-names", &len);
2710 conn = get_property(np, "AAPL,connector", &len); 2728 conn = of_get_property(np, "AAPL,connector", &len);
2711 if (conn && (strcmp(conn, "infrared") == 0)) 2729 if (conn && (strcmp(conn, "infrared") == 0))
2712 port_type = PMAC_SCC_IRDA; 2730 port_type = PMAC_SCC_IRDA;
2713 else if (device_is_compatible(np, "cobalt")) 2731 else if (device_is_compatible(np, "cobalt"))
@@ -2735,12 +2753,14 @@ set_initial_features(void)
2735 * differenciate them all and since that hack was there for a long 2753 * differenciate them all and since that hack was there for a long
2736 * time, I'll keep it around 2754 * time, I'll keep it around
2737 */ 2755 */
2738 if (macio_chips[0].type == macio_ohare && !find_devices("via-pmu")) { 2756 if (macio_chips[0].type == macio_ohare) {
2739 struct macio_chip *macio = &macio_chips[0]; 2757 struct macio_chip *macio = &macio_chips[0];
2740 MACIO_OUT32(OHARE_FCR, STARMAX_FEATURES); 2758 np = of_find_node_by_name(NULL, "via-pmu");
2741 } else if (macio_chips[0].type == macio_ohare) { 2759 if (np)
2742 struct macio_chip *macio = &macio_chips[0]; 2760 MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE);
2743 MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE); 2761 else
2762 MACIO_OUT32(OHARE_FCR, STARMAX_FEATURES);
2763 of_node_put(np);
2744 } else if (macio_chips[1].type == macio_ohare) { 2764 } else if (macio_chips[1].type == macio_ohare) {
2745 struct macio_chip *macio = &macio_chips[1]; 2765 struct macio_chip *macio = &macio_chips[1];
2746 MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE); 2766 MACIO_BIS(OHARE_FCR, OH_IOBUS_ENABLE);
@@ -2833,14 +2853,13 @@ set_initial_features(void)
2833 } 2853 }
2834 2854
2835 /* Switch airport off */ 2855 /* Switch airport off */
2836 np = find_devices("radio"); 2856 for_each_node_by_name(np, "radio") {
2837 while(np) {
2838 if (np && np->parent == macio_chips[0].of_node) { 2857 if (np && np->parent == macio_chips[0].of_node) {
2839 macio_chips[0].flags |= MACIO_FLAG_AIRPORT_ON; 2858 macio_chips[0].flags |= MACIO_FLAG_AIRPORT_ON;
2840 core99_airport_enable(np, 0, 0); 2859 core99_airport_enable(np, 0, 0);
2841 } 2860 }
2842 np = np->next;
2843 } 2861 }
2862 of_node_put(np);
2844 } 2863 }
2845 2864
2846 /* On all machines that support sound PM, switch sound off */ 2865 /* On all machines that support sound PM, switch sound off */
@@ -2860,16 +2879,12 @@ set_initial_features(void)
2860#endif /* CONFIG_POWER4 */ 2879#endif /* CONFIG_POWER4 */
2861 2880
2862 /* On all machines, switch modem & serial ports off */ 2881 /* On all machines, switch modem & serial ports off */
2863 np = find_devices("ch-a"); 2882 for_each_node_by_name(np, "ch-a")
2864 while(np) {
2865 initial_serial_shutdown(np); 2883 initial_serial_shutdown(np);
2866 np = np->next; 2884 of_node_put(np);
2867 } 2885 for_each_node_by_name(np, "ch-b")
2868 np = find_devices("ch-b");
2869 while(np) {
2870 initial_serial_shutdown(np); 2886 initial_serial_shutdown(np);
2871 np = np->next; 2887 of_node_put(np);
2872 }
2873} 2888}
2874 2889
2875void __init 2890void __init
diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c
index bfc4829162f1..5430e146b3e9 100644
--- a/arch/powerpc/platforms/powermac/low_i2c.c
+++ b/arch/powerpc/platforms/powermac/low_i2c.c
@@ -491,7 +491,7 @@ static struct pmac_i2c_host_kw *__init kw_i2c_host_init(struct device_node *np)
491 * 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
492 * to macio parsing if that wasn't the case 492 * to macio parsing if that wasn't the case
493 */ 493 */
494 addrp = get_property(np, "AAPL,address", NULL); 494 addrp = of_get_property(np, "AAPL,address", NULL);
495 if (addrp == NULL) { 495 if (addrp == NULL) {
496 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",
497 np->full_name); 497 np->full_name);
@@ -505,13 +505,13 @@ static struct pmac_i2c_host_kw *__init kw_i2c_host_init(struct device_node *np)
505 host->timeout_timer.function = kw_i2c_timeout; 505 host->timeout_timer.function = kw_i2c_timeout;
506 host->timeout_timer.data = (unsigned long)host; 506 host->timeout_timer.data = (unsigned long)host;
507 507
508 psteps = get_property(np, "AAPL,address-step", NULL); 508 psteps = of_get_property(np, "AAPL,address-step", NULL);
509 steps = psteps ? (*psteps) : 0x10; 509 steps = psteps ? (*psteps) : 0x10;
510 for (host->bsteps = 0; (steps & 0x01) == 0; host->bsteps++) 510 for (host->bsteps = 0; (steps & 0x01) == 0; host->bsteps++)
511 steps >>= 1; 511 steps >>= 1;
512 /* Select interface rate */ 512 /* Select interface rate */
513 host->speed = KW_I2C_MODE_25KHZ; 513 host->speed = KW_I2C_MODE_25KHZ;
514 prate = get_property(np, "AAPL,i2c-rate", NULL); 514 prate = of_get_property(np, "AAPL,i2c-rate", NULL);
515 if (prate) switch(*prate) { 515 if (prate) switch(*prate) {
516 case 100: 516 case 100:
517 host->speed = KW_I2C_MODE_100KHZ; 517 host->speed = KW_I2C_MODE_100KHZ;
@@ -619,7 +619,7 @@ static void __init kw_i2c_probe(void)
619 } else { 619 } else {
620 for (child = NULL; 620 for (child = NULL;
621 (child = of_get_next_child(np, child)) != NULL;) { 621 (child = of_get_next_child(np, child)) != NULL;) {
622 const u32 *reg = get_property(child, 622 const u32 *reg = of_get_property(child,
623 "reg", NULL); 623 "reg", NULL);
624 if (reg == NULL) 624 if (reg == NULL)
625 continue; 625 continue;
@@ -905,7 +905,7 @@ static void __init smu_i2c_probe(void)
905 if (strcmp(busnode->type, "i2c") && 905 if (strcmp(busnode->type, "i2c") &&
906 strcmp(busnode->type, "i2c-bus")) 906 strcmp(busnode->type, "i2c-bus"))
907 continue; 907 continue;
908 reg = get_property(busnode, "reg", NULL); 908 reg = of_get_property(busnode, "reg", NULL);
909 if (reg == NULL) 909 if (reg == NULL)
910 continue; 910 continue;
911 911
@@ -950,7 +950,8 @@ struct pmac_i2c_bus *pmac_i2c_find_bus(struct device_node *node)
950 if (p == bus->busnode) { 950 if (p == bus->busnode) {
951 if (prev && bus->flags & pmac_i2c_multibus) { 951 if (prev && bus->flags & pmac_i2c_multibus) {
952 const u32 *reg; 952 const u32 *reg;
953 reg = get_property(prev, "reg", NULL); 953 reg = of_get_property(prev, "reg",
954 NULL);
954 if (!reg) 955 if (!reg)
955 continue; 956 continue;
956 if (((*reg) >> 8) != bus->channel) 957 if (((*reg) >> 8) != bus->channel)
@@ -971,7 +972,7 @@ EXPORT_SYMBOL_GPL(pmac_i2c_find_bus);
971 972
972u8 pmac_i2c_get_dev_addr(struct device_node *device) 973u8 pmac_i2c_get_dev_addr(struct device_node *device)
973{ 974{
974 const u32 *reg = get_property(device, "reg", NULL); 975 const u32 *reg = of_get_property(device, "reg", NULL);
975 976
976 if (reg == NULL) 977 if (reg == NULL)
977 return 0; 978 return 0;
diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c
index 6fbac308ded6..22c4ae4c6934 100644
--- a/arch/powerpc/platforms/powermac/pci.c
+++ b/arch/powerpc/platforms/powermac/pci.c
@@ -70,11 +70,11 @@ static int __init fixup_one_level_bus_range(struct device_node *node, int higher
70 int len; 70 int len;
71 71
72 /* For PCI<->PCI bridges or CardBus bridges, we go down */ 72 /* For PCI<->PCI bridges or CardBus bridges, we go down */
73 class_code = get_property(node, "class-code", NULL); 73 class_code = of_get_property(node, "class-code", NULL);
74 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI && 74 if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
75 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) 75 (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS))
76 continue; 76 continue;
77 bus_range = get_property(node, "bus-range", &len); 77 bus_range = of_get_property(node, "bus-range", &len);
78 if (bus_range != NULL && len > 2 * sizeof(int)) { 78 if (bus_range != NULL && len > 2 * sizeof(int)) {
79 if (bus_range[1] > higher) 79 if (bus_range[1] > higher)
80 higher = bus_range[1]; 80 higher = bus_range[1];
@@ -100,7 +100,7 @@ static void __init fixup_bus_range(struct device_node *bridge)
100 if (prop == NULL || prop->length < 2 * sizeof(int)) 100 if (prop == NULL || prop->length < 2 * sizeof(int))
101 return; 101 return;
102 102
103 bus_range = (int *)prop->value; 103 bus_range = prop->value;
104 bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]); 104 bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]);
105} 105}
106 106
@@ -246,8 +246,8 @@ static int chaos_validate_dev(struct pci_bus *bus, int devfn, int offset)
246 if (np == NULL) 246 if (np == NULL)
247 return PCIBIOS_DEVICE_NOT_FOUND; 247 return PCIBIOS_DEVICE_NOT_FOUND;
248 248
249 vendor = get_property(np, "vendor-id", NULL); 249 vendor = of_get_property(np, "vendor-id", NULL);
250 device = get_property(np, "device-id", NULL); 250 device = of_get_property(np, "device-id", NULL);
251 if (vendor == NULL || device == NULL) 251 if (vendor == NULL || device == NULL)
252 return PCIBIOS_DEVICE_NOT_FOUND; 252 return PCIBIOS_DEVICE_NOT_FOUND;
253 253
@@ -622,13 +622,14 @@ static void __init init_p2pbridge(void)
622 622
623 /* XXX it would be better here to identify the specific 623 /* XXX it would be better here to identify the specific
624 PCI-PCI bridge chip we have. */ 624 PCI-PCI bridge chip we have. */
625 if ((p2pbridge = find_devices("pci-bridge")) == 0 625 p2pbridge = of_find_node_by_name(NULL, "pci-bridge");
626 if (p2pbridge == NULL
626 || p2pbridge->parent == NULL 627 || p2pbridge->parent == NULL
627 || strcmp(p2pbridge->parent->name, "pci") != 0) 628 || strcmp(p2pbridge->parent->name, "pci") != 0)
628 return; 629 goto done;
629 if (pci_device_from_OF_node(p2pbridge, &bus, &devfn) < 0) { 630 if (pci_device_from_OF_node(p2pbridge, &bus, &devfn) < 0) {
630 DBG("Can't find PCI infos for PCI<->PCI bridge\n"); 631 DBG("Can't find PCI infos for PCI<->PCI bridge\n");
631 return; 632 goto done;
632 } 633 }
633 /* Warning: At this point, we have not yet renumbered all busses. 634 /* Warning: At this point, we have not yet renumbered all busses.
634 * So we must use OF walking to find out hose 635 * So we must use OF walking to find out hose
@@ -636,16 +637,18 @@ static void __init init_p2pbridge(void)
636 hose = pci_find_hose_for_OF_device(p2pbridge); 637 hose = pci_find_hose_for_OF_device(p2pbridge);
637 if (!hose) { 638 if (!hose) {
638 DBG("Can't find hose for PCI<->PCI bridge\n"); 639 DBG("Can't find hose for PCI<->PCI bridge\n");
639 return; 640 goto done;
640 } 641 }
641 if (early_read_config_word(hose, bus, devfn, 642 if (early_read_config_word(hose, bus, devfn,
642 PCI_BRIDGE_CONTROL, &val) < 0) { 643 PCI_BRIDGE_CONTROL, &val) < 0) {
643 printk(KERN_ERR "init_p2pbridge: couldn't read bridge" 644 printk(KERN_ERR "init_p2pbridge: couldn't read bridge"
644 " control\n"); 645 " control\n");
645 return; 646 goto done;
646 } 647 }
647 val &= ~PCI_BRIDGE_CTL_MASTER_ABORT; 648 val &= ~PCI_BRIDGE_CTL_MASTER_ABORT;
648 early_write_config_word(hose, bus, devfn, PCI_BRIDGE_CONTROL, val); 649 early_write_config_word(hose, bus, devfn, PCI_BRIDGE_CONTROL, val);
650done:
651 of_node_put(p2pbridge);
649} 652}
650 653
651static void __init init_second_ohare(void) 654static void __init init_second_ohare(void)
@@ -691,17 +694,17 @@ static void __init fixup_nec_usb2(void)
691 const u32 *prop; 694 const u32 *prop;
692 u8 bus, devfn; 695 u8 bus, devfn;
693 696
694 prop = get_property(nec, "vendor-id", NULL); 697 prop = of_get_property(nec, "vendor-id", NULL);
695 if (prop == NULL) 698 if (prop == NULL)
696 continue; 699 continue;
697 if (0x1033 != *prop) 700 if (0x1033 != *prop)
698 continue; 701 continue;
699 prop = get_property(nec, "device-id", NULL); 702 prop = of_get_property(nec, "device-id", NULL);
700 if (prop == NULL) 703 if (prop == NULL)
701 continue; 704 continue;
702 if (0x0035 != *prop) 705 if (0x0035 != *prop)
703 continue; 706 continue;
704 prop = get_property(nec, "reg", NULL); 707 prop = of_get_property(nec, "reg", NULL);
705 if (prop == NULL) 708 if (prop == NULL)
706 continue; 709 continue;
707 devfn = (prop[0] >> 8) & 0xff; 710 devfn = (prop[0] >> 8) & 0xff;
@@ -909,7 +912,7 @@ static int __init add_bridge(struct device_node *dev)
909 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0); 912 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
910 913
911 /* Get bus range if any */ 914 /* Get bus range if any */
912 bus_range = get_property(dev, "bus-range", &len); 915 bus_range = of_get_property(dev, "bus-range", &len);
913 if (bus_range == NULL || len < 2 * sizeof(int)) { 916 if (bus_range == NULL || len < 2 * sizeof(int)) {
914 printk(KERN_WARNING "Can't get bus-range for %s, assume" 917 printk(KERN_WARNING "Can't get bus-range for %s, assume"
915 " bus 0\n", dev->full_name); 918 " bus 0\n", dev->full_name);
@@ -1199,8 +1202,7 @@ void __init pmac_pcibios_after_init(void)
1199 } 1202 }
1200#endif /* CONFIG_BLK_DEV_IDE */ 1203#endif /* CONFIG_BLK_DEV_IDE */
1201 1204
1202 nd = find_devices("firewire"); 1205 for_each_node_by_name(nd, "firewire") {
1203 while (nd) {
1204 if (nd->parent && (device_is_compatible(nd, "pci106b,18") || 1206 if (nd->parent && (device_is_compatible(nd, "pci106b,18") ||
1205 device_is_compatible(nd, "pci106b,30") || 1207 device_is_compatible(nd, "pci106b,30") ||
1206 device_is_compatible(nd, "pci11c1,5811")) 1208 device_is_compatible(nd, "pci11c1,5811"))
@@ -1208,15 +1210,14 @@ void __init pmac_pcibios_after_init(void)
1208 pmac_call_feature(PMAC_FTR_1394_ENABLE, nd, 0, 0); 1210 pmac_call_feature(PMAC_FTR_1394_ENABLE, nd, 0, 0);
1209 pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, nd, 0, 0); 1211 pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, nd, 0, 0);
1210 } 1212 }
1211 nd = nd->next;
1212 } 1213 }
1213 nd = find_devices("ethernet"); 1214 of_node_put(nd);
1214 while (nd) { 1215 for_each_node_by_name(nd, "ethernet") {
1215 if (nd->parent && device_is_compatible(nd, "gmac") 1216 if (nd->parent && device_is_compatible(nd, "gmac")
1216 && device_is_compatible(nd->parent, "uni-north")) 1217 && device_is_compatible(nd->parent, "uni-north"))
1217 pmac_call_feature(PMAC_FTR_GMAC_ENABLE, nd, 0, 0); 1218 pmac_call_feature(PMAC_FTR_GMAC_ENABLE, nd, 0, 0);
1218 nd = nd->next;
1219 } 1219 }
1220 of_node_put(nd);
1220} 1221}
1221 1222
1222#ifdef CONFIG_PPC32 1223#ifdef CONFIG_PPC32
diff --git a/arch/powerpc/platforms/powermac/pfunc_base.c b/arch/powerpc/platforms/powermac/pfunc_base.c
index 5c6c15c5f9a3..45d54b9ad9e0 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 const u32 *reg = get_property(gp, "reg", NULL); 117 const u32 *reg = of_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 7651f278615a..85434231ae14 100644
--- a/arch/powerpc/platforms/powermac/pfunc_core.c
+++ b/arch/powerpc/platforms/powermac/pfunc_core.c
@@ -692,8 +692,7 @@ static int pmf_add_functions(struct pmf_device *dev, void *driverdata)
692 name = pp->name + plen; 692 name = pp->name + plen;
693 if (strlen(name) && pp->length >= 12) 693 if (strlen(name) && pp->length >= 12)
694 count += pmf_add_function_prop(dev, driverdata, name, 694 count += pmf_add_function_prop(dev, driverdata, name,
695 (u32 *)pp->value, 695 pp->value, pp->length);
696 pp->length);
697 } 696 }
698 return count; 697 return count;
699} 698}
@@ -821,7 +820,7 @@ struct pmf_function *__pmf_find_function(struct device_node *target,
821 * one, then we fallback to a direct call attempt 820 * one, then we fallback to a direct call attempt
822 */ 821 */
823 snprintf(fname, 63, "platform-%s", name); 822 snprintf(fname, 63, "platform-%s", name);
824 prop = get_property(target, fname, NULL); 823 prop = of_get_property(target, fname, NULL);
825 if (prop == NULL) 824 if (prop == NULL)
826 goto find_it; 825 goto find_it;
827 ph = *prop; 826 ph = *prop;
diff --git a/arch/powerpc/platforms/powermac/pic.c b/arch/powerpc/platforms/powermac/pic.c
index 5e5c0e4add91..ae5097ac0378 100644
--- a/arch/powerpc/platforms/powermac/pic.c
+++ b/arch/powerpc/platforms/powermac/pic.c
@@ -482,14 +482,14 @@ static struct mpic * __init pmac_setup_one_mpic(struct device_node *np,
482 pmac_call_feature(PMAC_FTR_ENABLE_MPIC, np, 0, 0); 482 pmac_call_feature(PMAC_FTR_ENABLE_MPIC, np, 0, 0);
483 483
484 flags |= MPIC_WANTS_RESET; 484 flags |= MPIC_WANTS_RESET;
485 if (get_property(np, "big-endian", NULL)) 485 if (of_get_property(np, "big-endian", NULL))
486 flags |= MPIC_BIG_ENDIAN; 486 flags |= MPIC_BIG_ENDIAN;
487 487
488 /* Primary Big Endian means HT interrupts. This is quite dodgy 488 /* Primary Big Endian means HT interrupts. This is quite dodgy
489 * but works until I find a better way 489 * but works until I find a better way
490 */ 490 */
491 if (master && (flags & MPIC_BIG_ENDIAN)) 491 if (master && (flags & MPIC_BIG_ENDIAN))
492 flags |= MPIC_BROKEN_U3; 492 flags |= MPIC_U3_HT_IRQS;
493 493
494 mpic = mpic_alloc(np, r.start, flags, 0, 0, name); 494 mpic = mpic_alloc(np, r.start, flags, 0, 0, name);
495 if (mpic == NULL) 495 if (mpic == NULL)
@@ -510,7 +510,7 @@ static int __init pmac_pic_probe_mpic(void)
510 for (np = NULL; (np = of_find_node_by_type(np, "open-pic")) 510 for (np = NULL; (np = of_find_node_by_type(np, "open-pic"))
511 != NULL;) { 511 != NULL;) {
512 if (master == NULL && 512 if (master == NULL &&
513 get_property(np, "interrupts", NULL) == NULL) 513 of_get_property(np, "interrupts", NULL) == NULL)
514 master = of_node_get(np); 514 master = of_node_get(np);
515 else if (slave == NULL) 515 else if (slave == NULL)
516 slave = of_node_get(np); 516 slave = of_node_get(np);
@@ -575,7 +575,7 @@ void __init pmac_pic_init(void)
575#ifdef CONFIG_PPC32 575#ifdef CONFIG_PPC32
576 if (!pmac_newworld) 576 if (!pmac_newworld)
577 flags |= OF_IMAP_OLDWORLD_MAC; 577 flags |= OF_IMAP_OLDWORLD_MAC;
578 if (get_property(of_chosen, "linux,bootx", NULL) != NULL) 578 if (of_get_property(of_chosen, "linux,bootx", NULL) != NULL)
579 flags |= OF_IMAP_NO_PHANDLE; 579 flags |= OF_IMAP_NO_PHANDLE;
580#endif /* CONFIG_PPC_32 */ 580#endif /* CONFIG_PPC_32 */
581 581
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index 651fa424ea06..b820cabac697 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -42,7 +42,6 @@
42#include <linux/initrd.h> 42#include <linux/initrd.h>
43#include <linux/vt_kern.h> 43#include <linux/vt_kern.h>
44#include <linux/console.h> 44#include <linux/console.h>
45#include <linux/ide.h>
46#include <linux/pci.h> 45#include <linux/pci.h>
47#include <linux/adb.h> 46#include <linux/adb.h>
48#include <linux/cuda.h> 47#include <linux/cuda.h>
@@ -135,12 +134,12 @@ static void pmac_show_cpuinfo(struct seq_file *m)
135 seq_printf(m, "machine\t\t: "); 134 seq_printf(m, "machine\t\t: ");
136 np = of_find_node_by_path("/"); 135 np = of_find_node_by_path("/");
137 if (np != NULL) { 136 if (np != NULL) {
138 pp = get_property(np, "model", NULL); 137 pp = of_get_property(np, "model", NULL);
139 if (pp != NULL) 138 if (pp != NULL)
140 seq_printf(m, "%s\n", pp); 139 seq_printf(m, "%s\n", pp);
141 else 140 else
142 seq_printf(m, "PowerMac\n"); 141 seq_printf(m, "PowerMac\n");
143 pp = get_property(np, "compatible", &plen); 142 pp = of_get_property(np, "compatible", &plen);
144 if (pp != NULL) { 143 if (pp != NULL) {
145 seq_printf(m, "motherboard\t:"); 144 seq_printf(m, "motherboard\t:");
146 while (plen > 0) { 145 while (plen > 0) {
@@ -164,11 +163,13 @@ static void pmac_show_cpuinfo(struct seq_file *m)
164 if (np == NULL) 163 if (np == NULL)
165 np = of_find_node_by_type(NULL, "cache"); 164 np = of_find_node_by_type(NULL, "cache");
166 if (np != NULL) { 165 if (np != NULL) {
167 const unsigned int *ic = get_property(np, "i-cache-size", NULL); 166 const unsigned int *ic =
168 const unsigned int *dc = get_property(np, "d-cache-size", NULL); 167 of_get_property(np, "i-cache-size", NULL);
168 const unsigned int *dc =
169 of_get_property(np, "d-cache-size", NULL);
169 seq_printf(m, "L2 cache\t:"); 170 seq_printf(m, "L2 cache\t:");
170 has_l2cache = 1; 171 has_l2cache = 1;
171 if (get_property(np, "cache-unified", NULL) != 0 && dc) { 172 if (of_get_property(np, "cache-unified", NULL) != 0 && dc) {
172 seq_printf(m, " %dK unified", *dc / 1024); 173 seq_printf(m, " %dK unified", *dc / 1024);
173 } else { 174 } else {
174 if (ic) 175 if (ic)
@@ -177,7 +178,7 @@ static void pmac_show_cpuinfo(struct seq_file *m)
177 seq_printf(m, "%s %dK data", 178 seq_printf(m, "%s %dK data",
178 (ic? " +": ""), *dc / 1024); 179 (ic? " +": ""), *dc / 1024);
179 } 180 }
180 pp = get_property(np, "ram-type", NULL); 181 pp = of_get_property(np, "ram-type", NULL);
181 if (pp) 182 if (pp)
182 seq_printf(m, " %s", pp); 183 seq_printf(m, " %s", pp);
183 seq_printf(m, "\n"); 184 seq_printf(m, "\n");
@@ -192,8 +193,11 @@ static void pmac_show_cpuinfo(struct seq_file *m)
192#ifndef CONFIG_ADB_CUDA 193#ifndef CONFIG_ADB_CUDA
193int find_via_cuda(void) 194int find_via_cuda(void)
194{ 195{
195 if (!find_devices("via-cuda")) 196 struct device_node *dn = of_find_node_by_name(NULL, "via-cuda");
197
198 if (!dn)
196 return 0; 199 return 0;
200 of_node_put(dn);
197 printk("WARNING ! Your machine is CUDA-based but your kernel\n"); 201 printk("WARNING ! Your machine is CUDA-based but your kernel\n");
198 printk(" wasn't compiled with CONFIG_ADB_CUDA option !\n"); 202 printk(" wasn't compiled with CONFIG_ADB_CUDA option !\n");
199 return 0; 203 return 0;
@@ -203,8 +207,11 @@ int find_via_cuda(void)
203#ifndef CONFIG_ADB_PMU 207#ifndef CONFIG_ADB_PMU
204int find_via_pmu(void) 208int find_via_pmu(void)
205{ 209{
206 if (!find_devices("via-pmu")) 210 struct device_node *dn = of_find_node_by_name(NULL, "via-pmu");
211
212 if (!dn)
207 return 0; 213 return 0;
214 of_node_put(dn);
208 printk("WARNING ! Your machine is PMU-based but your kernel\n"); 215 printk("WARNING ! Your machine is PMU-based but your kernel\n");
209 printk(" wasn't compiled with CONFIG_ADB_PMU option !\n"); 216 printk(" wasn't compiled with CONFIG_ADB_PMU option !\n");
210 return 0; 217 return 0;
@@ -224,6 +231,8 @@ static volatile u32 *sysctrl_regs;
224 231
225static void __init ohare_init(void) 232static void __init ohare_init(void)
226{ 233{
234 struct device_node *dn;
235
227 /* this area has the CPU identification register 236 /* this area has the CPU identification register
228 and some registers used by smp boards */ 237 and some registers used by smp boards */
229 sysctrl_regs = (volatile u32 *) ioremap(0xf8000000, 0x1000); 238 sysctrl_regs = (volatile u32 *) ioremap(0xf8000000, 0x1000);
@@ -233,7 +242,9 @@ static void __init ohare_init(void)
233 * We assume that we have a PSX memory controller iff 242 * We assume that we have a PSX memory controller iff
234 * we have an ohare I/O controller. 243 * we have an ohare I/O controller.
235 */ 244 */
236 if (find_devices("ohare") != NULL) { 245 dn = of_find_node_by_name(NULL, "ohare");
246 if (dn) {
247 of_node_put(dn);
237 if (((sysctrl_regs[2] >> 24) & 0xf) >= 3) { 248 if (((sysctrl_regs[2] >> 24) & 0xf) >= 3) {
238 if (sysctrl_regs[4] & 0x10) 249 if (sysctrl_regs[4] & 0x10)
239 sysctrl_regs[4] |= 0x04000020; 250 sysctrl_regs[4] |= 0x04000020;
@@ -249,18 +260,19 @@ static void __init l2cr_init(void)
249{ 260{
250 /* Checks "l2cr-value" property in the registry */ 261 /* Checks "l2cr-value" property in the registry */
251 if (cpu_has_feature(CPU_FTR_L2CR)) { 262 if (cpu_has_feature(CPU_FTR_L2CR)) {
252 struct device_node *np = find_devices("cpus"); 263 struct device_node *np = of_find_node_by_name(NULL, "cpus");
253 if (np == 0) 264 if (np == 0)
254 np = find_type_devices("cpu"); 265 np = of_find_node_by_type(NULL, "cpu");
255 if (np != 0) { 266 if (np != 0) {
256 const unsigned int *l2cr = 267 const unsigned int *l2cr =
257 get_property(np, "l2cr-value", NULL); 268 of_get_property(np, "l2cr-value", NULL);
258 if (l2cr != 0) { 269 if (l2cr != 0) {
259 ppc_override_l2cr = 1; 270 ppc_override_l2cr = 1;
260 ppc_override_l2cr_value = *l2cr; 271 ppc_override_l2cr_value = *l2cr;
261 _set_L2CR(0); 272 _set_L2CR(0);
262 _set_L2CR(ppc_override_l2cr_value); 273 _set_L2CR(ppc_override_l2cr_value);
263 } 274 }
275 of_node_put(np);
264 } 276 }
265 } 277 }
266 278
@@ -286,7 +298,7 @@ static void __init pmac_setup_arch(void)
286 loops_per_jiffy = 50000000 / HZ; 298 loops_per_jiffy = 50000000 / HZ;
287 cpu = of_find_node_by_type(NULL, "cpu"); 299 cpu = of_find_node_by_type(NULL, "cpu");
288 if (cpu != NULL) { 300 if (cpu != NULL) {
289 fp = get_property(cpu, "clock-frequency", NULL); 301 fp = of_get_property(cpu, "clock-frequency", NULL);
290 if (fp != NULL) { 302 if (fp != NULL) {
291 if (pvr >= 0x30 && pvr < 0x80) 303 if (pvr >= 0x30 && pvr < 0x80)
292 /* PPC970 etc. */ 304 /* PPC970 etc. */
@@ -303,7 +315,7 @@ static void __init pmac_setup_arch(void)
303 315
304 /* See if newworld or oldworld */ 316 /* See if newworld or oldworld */
305 for (ic = NULL; (ic = of_find_all_nodes(ic)) != NULL; ) 317 for (ic = NULL; (ic = of_find_all_nodes(ic)) != NULL; )
306 if (get_property(ic, "interrupt-controller", NULL)) 318 if (of_get_property(ic, "interrupt-controller", NULL))
307 break; 319 break;
308 if (ic) { 320 if (ic) {
309 pmac_newworld = 1; 321 pmac_newworld = 1;
@@ -341,8 +353,15 @@ static void __init pmac_setup_arch(void)
341 353
342#ifdef CONFIG_SMP 354#ifdef CONFIG_SMP
343 /* Check for Core99 */ 355 /* Check for Core99 */
344 if (find_devices("uni-n") || find_devices("u3") || find_devices("u4")) 356 ic = of_find_node_by_name(NULL, "uni-n");
357 if (!ic)
358 ic = of_find_node_by_name(NULL, "u3");
359 if (!ic)
360 ic = of_find_node_by_name(NULL, "u4");
361 if (ic) {
362 of_node_put(ic);
345 smp_ops = &core99_smp_ops; 363 smp_ops = &core99_smp_ops;
364 }
346#ifdef CONFIG_PPC32 365#ifdef CONFIG_PPC32
347 else 366 else
348 smp_ops = &psurge_smp_ops; 367 smp_ops = &psurge_smp_ops;
@@ -616,15 +635,6 @@ static void __init pmac_init_early(void)
616#endif 635#endif
617} 636}
618 637
619/*
620 * pmac has no legacy IO, anything calling this function has to
621 * fail or bad things will happen
622 */
623static int pmac_check_legacy_ioport(unsigned int baseport)
624{
625 return -ENODEV;
626}
627
628static int __init pmac_declare_of_platform_devices(void) 638static int __init pmac_declare_of_platform_devices(void)
629{ 639{
630 struct device_node *np; 640 struct device_node *np;
@@ -736,7 +746,6 @@ define_machine(powermac) {
736 .get_rtc_time = pmac_get_rtc_time, 746 .get_rtc_time = pmac_get_rtc_time,
737 .calibrate_decr = pmac_calibrate_decr, 747 .calibrate_decr = pmac_calibrate_decr,
738 .feature_call = pmac_do_feature_call, 748 .feature_call = pmac_do_feature_call,
739 .check_legacy_ioport = pmac_check_legacy_ioport,
740 .progress = udbg_progress, 749 .progress = udbg_progress,
741#ifdef CONFIG_PPC64 750#ifdef CONFIG_PPC64
742 .pci_probe_mode = pmac_pci_probe_mode, 751 .pci_probe_mode = pmac_pci_probe_mode,
diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
index d73fb73802bb..6f32c4eca6e5 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -264,6 +264,7 @@ static void __init psurge_quad_init(void)
264static int __init smp_psurge_probe(void) 264static int __init smp_psurge_probe(void)
265{ 265{
266 int i, ncpus; 266 int i, ncpus;
267 struct device_node *dn;
267 268
268 /* We don't do SMP on the PPC601 -- paulus */ 269 /* We don't do SMP on the PPC601 -- paulus */
269 if (PVR_VER(mfspr(SPRN_PVR)) == 1) 270 if (PVR_VER(mfspr(SPRN_PVR)) == 1)
@@ -279,8 +280,10 @@ static int __init smp_psurge_probe(void)
279 * in the hammerhead memory controller in the case of the 280 * in the hammerhead memory controller in the case of the
280 * dual-cpu powersurge board. -- paulus. 281 * dual-cpu powersurge board. -- paulus.
281 */ 282 */
282 if (find_devices("hammerhead") == NULL) 283 dn = of_find_node_by_name(NULL, "hammerhead");
284 if (dn == NULL)
283 return 1; 285 return 1;
286 of_node_put(dn);
284 287
285 hhead_base = ioremap(HAMMERHEAD_BASE, 0x800); 288 hhead_base = ioremap(HAMMERHEAD_BASE, 0x800);
286 quad_base = ioremap(PSURGE_QUAD_REG_ADDR, 1024); 289 quad_base = ioremap(PSURGE_QUAD_REG_ADDR, 1024);
@@ -567,7 +570,7 @@ static void __init smp_core99_setup_i2c_hwsync(int ncpus)
567 pmac_tb_clock_chip_host = pmac_i2c_find_bus(cc); 570 pmac_tb_clock_chip_host = pmac_i2c_find_bus(cc);
568 if (pmac_tb_clock_chip_host == NULL) 571 if (pmac_tb_clock_chip_host == NULL)
569 continue; 572 continue;
570 reg = get_property(cc, "reg", NULL); 573 reg = of_get_property(cc, "reg", NULL);
571 if (reg == NULL) 574 if (reg == NULL)
572 continue; 575 continue;
573 switch (*reg) { 576 switch (*reg) {
@@ -695,7 +698,7 @@ static void __init smp_core99_setup(int ncpus)
695 struct device_node *cpus = 698 struct device_node *cpus =
696 of_find_node_by_path("/cpus"); 699 of_find_node_by_path("/cpus");
697 if (cpus && 700 if (cpus &&
698 get_property(cpus, "platform-cpu-timebase", NULL)) { 701 of_get_property(cpus, "platform-cpu-timebase", NULL)) {
699 pmac_tb_freeze = smp_core99_pfunc_tb_freeze; 702 pmac_tb_freeze = smp_core99_pfunc_tb_freeze;
700 printk(KERN_INFO "Processor timebase sync using" 703 printk(KERN_INFO "Processor timebase sync using"
701 " platform function\n"); 704 " platform function\n");
@@ -712,7 +715,7 @@ static void __init smp_core99_setup(int ncpus)
712 core99_tb_gpio = KL_GPIO_TB_ENABLE; /* default value */ 715 core99_tb_gpio = KL_GPIO_TB_ENABLE; /* default value */
713 cpu = of_find_node_by_type(NULL, "cpu"); 716 cpu = of_find_node_by_type(NULL, "cpu");
714 if (cpu != NULL) { 717 if (cpu != NULL) {
715 tbprop = get_property(cpu, "timebase-enable", NULL); 718 tbprop = of_get_property(cpu, "timebase-enable", NULL);
716 if (tbprop) 719 if (tbprop)
717 core99_tb_gpio = *tbprop; 720 core99_tb_gpio = *tbprop;
718 of_node_put(cpu); 721 of_node_put(cpu);
diff --git a/arch/powerpc/platforms/powermac/time.c b/arch/powerpc/platforms/powermac/time.c
index a4173906e945..bf9da56942e8 100644
--- a/arch/powerpc/platforms/powermac/time.c
+++ b/arch/powerpc/platforms/powermac/time.c
@@ -297,49 +297,11 @@ int __init via_calibrate_decr(void)
297} 297}
298#endif 298#endif
299 299
300#ifdef CONFIG_PM
301/*
302 * Reset the time after a sleep.
303 */
304static int
305time_sleep_notify(struct pmu_sleep_notifier *self, int when)
306{
307 static unsigned long time_diff;
308 unsigned long flags;
309 unsigned long seq;
310 struct timespec tv;
311
312 switch (when) {
313 case PBOOK_SLEEP_NOW:
314 do {
315 seq = read_seqbegin_irqsave(&xtime_lock, flags);
316 time_diff = xtime.tv_sec - pmac_get_boot_time();
317 } while (read_seqretry_irqrestore(&xtime_lock, seq, flags));
318 break;
319 case PBOOK_WAKE:
320 tv.tv_sec = pmac_get_boot_time() + time_diff;
321 tv.tv_nsec = 0;
322 do_settimeofday(&tv);
323 break;
324 }
325 return PBOOK_SLEEP_OK;
326}
327
328static struct pmu_sleep_notifier time_sleep_notifier = {
329 time_sleep_notify, SLEEP_LEVEL_MISC,
330};
331#endif /* CONFIG_PM */
332
333/* 300/*
334 * Query the OF and get the decr frequency. 301 * Query the OF and get the decr frequency.
335 */ 302 */
336void __init pmac_calibrate_decr(void) 303void __init pmac_calibrate_decr(void)
337{ 304{
338#if defined(CONFIG_PM) && defined(CONFIG_ADB_PMU)
339 /* XXX why here? */
340 pmu_register_sleep_notifier(&time_sleep_notifier);
341#endif
342
343 generic_calibrate_decr(); 305 generic_calibrate_decr();
344 306
345#ifdef CONFIG_PPC32 307#ifdef CONFIG_PPC32
diff --git a/arch/powerpc/platforms/powermac/udbg_scc.c b/arch/powerpc/platforms/powermac/udbg_scc.c
index 379db05b0082..47de4d3fc167 100644
--- a/arch/powerpc/platforms/powermac/udbg_scc.c
+++ b/arch/powerpc/platforms/powermac/udbg_scc.c
@@ -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 = get_property(of_chosen, "linux,stdout-path", NULL); 84 path = of_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 = get_property(escc, "reg", NULL); 99 reg = of_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 = get_property(macio, "assigned-addresses", NULL); 105 reg = of_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/prep/Kconfig b/arch/powerpc/platforms/prep/Kconfig
index 673ac47a1626..29d411279b0c 100644
--- a/arch/powerpc/platforms/prep/Kconfig
+++ b/arch/powerpc/platforms/prep/Kconfig
@@ -1,3 +1,12 @@
1config PPC_PREP
2 bool "PowerPC Reference Platform (PReP) based machines"
3 depends on PPC_MULTIPLATFORM && PPC32 && BROKEN
4 select MPIC
5 select PPC_I8259
6 select PPC_INDIRECT_PCI
7 select PPC_UDBG_16550
8 select PPC_NATIVE
9 default n
1 10
2config PREP_RESIDUAL 11config PREP_RESIDUAL
3 bool "Support for PReP Residual Data" 12 bool "Support for PReP Residual Data"
diff --git a/arch/powerpc/platforms/ps3/Kconfig b/arch/powerpc/platforms/ps3/Kconfig
index 1a481a60a883..40f0008af4d1 100644
--- a/arch/powerpc/platforms/ps3/Kconfig
+++ b/arch/powerpc/platforms/ps3/Kconfig
@@ -1,3 +1,19 @@
1config PPC_PS3
2 bool "Sony PS3 (incomplete)"
3 depends on PPC_MULTIPLATFORM && PPC64
4 select PPC_CELL
5 select USB_ARCH_HAS_OHCI
6 select USB_OHCI_LITTLE_ENDIAN
7 select USB_OHCI_BIG_ENDIAN_MMIO
8 select USB_ARCH_HAS_EHCI
9 select USB_EHCI_BIG_ENDIAN_MMIO
10 help
11 This option enables support for the Sony PS3 game console
12 and other platforms using the PS3 hypervisor.
13 Support for this platform is not yet complete, so
14 enabling this will not result in a bootable kernel on a
15 PS3 system.
16
1menu "PS3 Platform Options" 17menu "PS3 Platform Options"
2 depends on PPC_PS3 18 depends on PPC_PS3
3 19
diff --git a/arch/powerpc/platforms/ps3/htab.c b/arch/powerpc/platforms/ps3/htab.c
index e12e59fea13a..ea60c451cf87 100644
--- a/arch/powerpc/platforms/ps3/htab.c
+++ b/arch/powerpc/platforms/ps3/htab.c
@@ -39,7 +39,7 @@ static unsigned long htab_addr;
39static unsigned char *bolttab; 39static unsigned char *bolttab;
40static unsigned char *inusetab; 40static unsigned char *inusetab;
41 41
42static spinlock_t ps3_bolttab_lock = SPIN_LOCK_UNLOCKED; 42static DEFINE_SPINLOCK(ps3_bolttab_lock);
43 43
44#define debug_dump_hpte(_a, _b, _c, _d, _e, _f, _g) \ 44#define debug_dump_hpte(_a, _b, _c, _d, _e, _f, _g) \
45 _debug_dump_hpte(_a, _b, _c, _d, _e, _f, _g, __func__, __LINE__) 45 _debug_dump_hpte(_a, _b, _c, _d, _e, _f, _g, __func__, __LINE__)
diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig
index a57032cf6f1b..16e4e401b820 100644
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -1,3 +1,13 @@
1config PPC_PSERIES
2 depends on PPC_MULTIPLATFORM && PPC64
3 bool "IBM pSeries & new (POWER5-based) iSeries"
4 select MPIC
5 select PPC_I8259
6 select PPC_RTAS
7 select RTAS_ERROR_LOGGING
8 select PPC_UDBG_16550
9 select PPC_NATIVE
10 default y
1 11
2config PPC_SPLPAR 12config PPC_SPLPAR
3 depends on PPC_PSERIES 13 depends on PPC_PSERIES
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile
index 2dfd05095a25..90235d598751 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -2,14 +2,15 @@ ifeq ($(CONFIG_PPC64),y)
2EXTRA_CFLAGS += -mno-minimal-toc 2EXTRA_CFLAGS += -mno-minimal-toc
3endif 3endif
4 4
5obj-y := pci.o lpar.o hvCall.o nvram.o reconfig.o \ 5obj-y := lpar.o hvCall.o nvram.o reconfig.o \
6 setup.o iommu.o ras.o rtasd.o pci_dlpar.o \ 6 setup.o iommu.o ras.o rtasd.o \
7 firmware.o power.o 7 firmware.o power.o
8obj-$(CONFIG_SMP) += smp.o 8obj-$(CONFIG_SMP) += smp.o
9obj-$(CONFIG_XICS) += xics.o 9obj-$(CONFIG_XICS) += xics.o
10obj-$(CONFIG_SCANLOG) += scanlog.o 10obj-$(CONFIG_SCANLOG) += scanlog.o
11obj-$(CONFIG_EEH) += eeh.o eeh_cache.o eeh_driver.o eeh_event.o 11obj-$(CONFIG_EEH) += eeh.o eeh_cache.o eeh_driver.o eeh_event.o
12obj-$(CONFIG_KEXEC) += kexec.o 12obj-$(CONFIG_KEXEC) += kexec.o
13obj-$(CONFIG_PCI) += pci.o pci_dlpar.o
13 14
14obj-$(CONFIG_HOTPLUG_CPU) += hotplug-cpu.o 15obj-$(CONFIG_HOTPLUG_CPU) += hotplug-cpu.o
15 16
diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c
index 6cedbc002e0f..48fbd442e9df 100644
--- a/arch/powerpc/platforms/pseries/eeh.c
+++ b/arch/powerpc/platforms/pseries/eeh.c
@@ -74,7 +74,10 @@
74 * is broken and panic. This sets the threshold for how many read 74 * is broken and panic. This sets the threshold for how many read
75 * attempts we allow before panicking. 75 * attempts we allow before panicking.
76 */ 76 */
77#define EEH_MAX_FAILS 100000 77#define EEH_MAX_FAILS 2100000
78
79/* Time to wait for a PCI slot to retport status, in milliseconds */
80#define PCI_BUS_RESET_WAIT_MSEC (60*1000)
78 81
79/* RTAS tokens */ 82/* RTAS tokens */
80static int ibm_set_eeh_option; 83static int ibm_set_eeh_option;
@@ -83,6 +86,7 @@ static int ibm_read_slot_reset_state;
83static int ibm_read_slot_reset_state2; 86static int ibm_read_slot_reset_state2;
84static int ibm_slot_error_detail; 87static int ibm_slot_error_detail;
85static int ibm_get_config_addr_info; 88static int ibm_get_config_addr_info;
89static int ibm_get_config_addr_info2;
86static int ibm_configure_bridge; 90static int ibm_configure_bridge;
87 91
88int eeh_subsystem_enabled; 92int eeh_subsystem_enabled;
@@ -168,6 +172,55 @@ static int read_slot_reset_state(struct pci_dn *pdn, int rets[])
168} 172}
169 173
170/** 174/**
175 * eeh_wait_for_slot_status - returns error status of slot
176 * @pdn pci device node
177 * @max_wait_msecs maximum number to millisecs to wait
178 *
179 * Return negative value if a permanent error, else return
180 * Partition Endpoint (PE) status value.
181 *
182 * If @max_wait_msecs is positive, then this routine will
183 * sleep until a valid status can be obtained, or until
184 * the max allowed wait time is exceeded, in which case
185 * a -2 is returned.
186 */
187int
188eeh_wait_for_slot_status(struct pci_dn *pdn, int max_wait_msecs)
189{
190 int rc;
191 int rets[3];
192 int mwait;
193
194 while (1) {
195 rc = read_slot_reset_state(pdn, rets);
196 if (rc) return rc;
197 if (rets[1] == 0) return -1; /* EEH is not supported */
198
199 if (rets[0] != 5) return rets[0]; /* return actual status */
200
201 if (rets[2] == 0) return -1; /* permanently unavailable */
202
203 if (max_wait_msecs <= 0) return -1;
204
205 mwait = rets[2];
206 if (mwait <= 0) {
207 printk (KERN_WARNING
208 "EEH: Firmware returned bad wait value=%d\n", mwait);
209 mwait = 1000;
210 } else if (mwait > 300*1000) {
211 printk (KERN_WARNING
212 "EEH: Firmware is taking too long, time=%d\n", mwait);
213 mwait = 300*1000;
214 }
215 max_wait_msecs -= mwait;
216 msleep (mwait);
217 }
218
219 printk(KERN_WARNING "EEH: Timed out waiting for slot status\n");
220 return -2;
221}
222
223/**
171 * eeh_token_to_phys - convert EEH address token to phys address 224 * eeh_token_to_phys - convert EEH address token to phys address
172 * @token i/o token, should be address in the form 0xA.... 225 * @token i/o token, should be address in the form 0xA....
173 */ 226 */
@@ -229,7 +282,7 @@ void eeh_mark_slot (struct device_node *dn, int mode_flag)
229 dn = find_device_pe (dn); 282 dn = find_device_pe (dn);
230 283
231 /* Back up one, since config addrs might be shared */ 284 /* Back up one, since config addrs might be shared */
232 if (PCI_DN(dn) && PCI_DN(dn)->eeh_pe_config_addr) 285 if (!pcibios_find_pci_bus(dn) && PCI_DN(dn->parent))
233 dn = dn->parent; 286 dn = dn->parent;
234 287
235 PCI_DN(dn)->eeh_mode |= mode_flag; 288 PCI_DN(dn)->eeh_mode |= mode_flag;
@@ -263,7 +316,7 @@ void eeh_clear_slot (struct device_node *dn, int mode_flag)
263 dn = find_device_pe (dn); 316 dn = find_device_pe (dn);
264 317
265 /* Back up one, since config addrs might be shared */ 318 /* Back up one, since config addrs might be shared */
266 if (PCI_DN(dn) && PCI_DN(dn)->eeh_pe_config_addr) 319 if (!pcibios_find_pci_bus(dn) && PCI_DN(dn->parent))
267 dn = dn->parent; 320 dn = dn->parent;
268 321
269 PCI_DN(dn)->eeh_mode &= ~mode_flag; 322 PCI_DN(dn)->eeh_mode &= ~mode_flag;
@@ -293,7 +346,6 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
293 int rets[3]; 346 int rets[3];
294 unsigned long flags; 347 unsigned long flags;
295 struct pci_dn *pdn; 348 struct pci_dn *pdn;
296 enum pci_channel_state state;
297 int rc = 0; 349 int rc = 0;
298 350
299 total_mmio_ffs++; 351 total_mmio_ffs++;
@@ -367,25 +419,25 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
367 goto dn_unlock; 419 goto dn_unlock;
368 } 420 }
369 421
370 /* If EEH is not supported on this device, punt. */ 422 /* Note that config-io to empty slots may fail;
371 if (rets[1] != 1) { 423 * they are empty when they don't have children. */
372 printk(KERN_WARNING "EEH: event on unsupported device, rc=%d dn=%s\n", 424 if ((rets[0] == 5) && (dn->child == NULL)) {
373 ret, dn->full_name);
374 false_positives++; 425 false_positives++;
375 rc = 0; 426 rc = 0;
376 goto dn_unlock; 427 goto dn_unlock;
377 } 428 }
378 429
379 /* If not the kind of error we know about, punt. */ 430 /* If EEH is not supported on this device, punt. */
380 if (rets[0] != 2 && rets[0] != 4 && rets[0] != 5) { 431 if (rets[1] != 1) {
432 printk(KERN_WARNING "EEH: event on unsupported device, rc=%d dn=%s\n",
433 ret, dn->full_name);
381 false_positives++; 434 false_positives++;
382 rc = 0; 435 rc = 0;
383 goto dn_unlock; 436 goto dn_unlock;
384 } 437 }
385 438
386 /* Note that config-io to empty slots may fail; 439 /* If not the kind of error we know about, punt. */
387 * we recognize empty because they don't have children. */ 440 if (rets[0] != 1 && rets[0] != 2 && rets[0] != 4 && rets[0] != 5) {
388 if ((rets[0] == 5) && (dn->child == NULL)) {
389 false_positives++; 441 false_positives++;
390 rc = 0; 442 rc = 0;
391 goto dn_unlock; 443 goto dn_unlock;
@@ -399,17 +451,12 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
399 eeh_mark_slot (dn, EEH_MODE_ISOLATED); 451 eeh_mark_slot (dn, EEH_MODE_ISOLATED);
400 spin_unlock_irqrestore(&confirm_error_lock, flags); 452 spin_unlock_irqrestore(&confirm_error_lock, flags);
401 453
402 state = pci_channel_io_normal; 454 eeh_send_failure_event (dn, dev);
403 if ((rets[0] == 2) || (rets[0] == 4))
404 state = pci_channel_io_frozen;
405 if (rets[0] == 5)
406 state = pci_channel_io_perm_failure;
407 eeh_send_failure_event (dn, dev, state, rets[2]);
408 455
409 /* Most EEH events are due to device driver bugs. Having 456 /* Most EEH events are due to device driver bugs. Having
410 * a stack trace will help the device-driver authors figure 457 * a stack trace will help the device-driver authors figure
411 * out what happened. So print that out. */ 458 * out what happened. So print that out. */
412 if (rets[0] != 5) dump_stack(); 459 dump_stack();
413 return 1; 460 return 1;
414 461
415dn_unlock: 462dn_unlock:
@@ -458,38 +505,6 @@ EXPORT_SYMBOL(eeh_check_failure);
458/* The code below deals with error recovery */ 505/* The code below deals with error recovery */
459 506
460/** 507/**
461 * eeh_slot_availability - returns error status of slot
462 * @pdn pci device node
463 *
464 * Return negative value if a permanent error, else return
465 * a number of milliseconds to wait until the PCI slot is
466 * ready to be used.
467 */
468static int
469eeh_slot_availability(struct pci_dn *pdn)
470{
471 int rc;
472 int rets[3];
473
474 rc = read_slot_reset_state(pdn, rets);
475
476 if (rc) return rc;
477
478 if (rets[1] == 0) return -1; /* EEH is not supported */
479 if (rets[0] == 0) return 0; /* Oll Korrect */
480 if (rets[0] == 5) {
481 if (rets[2] == 0) return -1; /* permanently unavailable */
482 return rets[2]; /* number of millisecs to wait */
483 }
484 if (rets[0] == 1)
485 return 250;
486
487 printk (KERN_ERR "EEH: Slot unavailable: rc=%d, rets=%d %d %d\n",
488 rc, rets[0], rets[1], rets[2]);
489 return -2;
490}
491
492/**
493 * rtas_pci_enable - enable MMIO or DMA transfers for this slot 508 * rtas_pci_enable - enable MMIO or DMA transfers for this slot
494 * @pdn pci device node 509 * @pdn pci device node
495 */ 510 */
@@ -512,9 +527,13 @@ rtas_pci_enable(struct pci_dn *pdn, int function)
512 function); 527 function);
513 528
514 if (rc) 529 if (rc)
515 printk(KERN_WARNING "EEH: Cannot enable function %d, err=%d dn=%s\n", 530 printk(KERN_WARNING "EEH: Unexpected state change %d, err=%d dn=%s\n",
516 function, rc, pdn->node->full_name); 531 function, rc, pdn->node->full_name);
517 532
533 rc = eeh_wait_for_slot_status (pdn, PCI_BUS_RESET_WAIT_MSEC);
534 if ((rc == 4) && (function == EEH_THAW_MMIO))
535 return 0;
536
518 return rc; 537 return rc;
519} 538}
520 539
@@ -595,36 +614,24 @@ int rtas_set_slot_reset(struct pci_dn *pdn)
595{ 614{
596 int i, rc; 615 int i, rc;
597 616
598 __rtas_set_slot_reset(pdn); 617 /* Take three shots at resetting the bus */
618 for (i=0; i<3; i++) {
619 __rtas_set_slot_reset(pdn);
599 620
600 /* Now double check with the firmware to make sure the device is 621 rc = eeh_wait_for_slot_status(pdn, PCI_BUS_RESET_WAIT_MSEC);
601 * ready to be used; if not, wait for recovery. */
602 for (i=0; i<10; i++) {
603 rc = eeh_slot_availability (pdn);
604 if (rc == 0) 622 if (rc == 0)
605 return 0; 623 return 0;
606 624
607 if (rc == -2) {
608 printk (KERN_ERR "EEH: failed (%d) to reset slot %s\n",
609 i, pdn->node->full_name);
610 __rtas_set_slot_reset(pdn);
611 continue;
612 }
613
614 if (rc < 0) { 625 if (rc < 0) {
615 printk (KERN_ERR "EEH: unrecoverable slot failure %s\n", 626 printk (KERN_ERR "EEH: unrecoverable slot failure %s\n",
616 pdn->node->full_name); 627 pdn->node->full_name);
617 return -1; 628 return -1;
618 } 629 }
619 630 printk (KERN_ERR "EEH: bus reset %d failed on slot %s\n",
620 msleep (rc+100); 631 i+1, pdn->node->full_name);
621 } 632 }
622 633
623 rc = eeh_slot_availability (pdn); 634 return -1;
624 if (rc)
625 printk (KERN_ERR "EEH: timeout resetting slot %s\n", pdn->node->full_name);
626
627 return rc;
628} 635}
629 636
630/* ------------------------------------------------------- */ 637/* ------------------------------------------------------- */
@@ -744,16 +751,48 @@ struct eeh_early_enable_info {
744 unsigned int buid_lo; 751 unsigned int buid_lo;
745}; 752};
746 753
754static int get_pe_addr (int config_addr,
755 struct eeh_early_enable_info *info)
756{
757 unsigned int rets[3];
758 int ret;
759
760 /* Use latest config-addr token on power6 */
761 if (ibm_get_config_addr_info2 != RTAS_UNKNOWN_SERVICE) {
762 /* Make sure we have a PE in hand */
763 ret = rtas_call (ibm_get_config_addr_info2, 4, 2, rets,
764 config_addr, info->buid_hi, info->buid_lo, 1);
765 if (ret || (rets[0]==0))
766 return 0;
767
768 ret = rtas_call (ibm_get_config_addr_info2, 4, 2, rets,
769 config_addr, info->buid_hi, info->buid_lo, 0);
770 if (ret)
771 return 0;
772 return rets[0];
773 }
774
775 /* Use older config-addr token on power5 */
776 if (ibm_get_config_addr_info != RTAS_UNKNOWN_SERVICE) {
777 ret = rtas_call (ibm_get_config_addr_info, 4, 2, rets,
778 config_addr, info->buid_hi, info->buid_lo, 0);
779 if (ret)
780 return 0;
781 return rets[0];
782 }
783 return 0;
784}
785
747/* Enable eeh for the given device node. */ 786/* Enable eeh for the given device node. */
748static void *early_enable_eeh(struct device_node *dn, void *data) 787static void *early_enable_eeh(struct device_node *dn, void *data)
749{ 788{
750 unsigned int rets[3]; 789 unsigned int rets[3];
751 struct eeh_early_enable_info *info = data; 790 struct eeh_early_enable_info *info = data;
752 int ret; 791 int ret;
753 const char *status = get_property(dn, "status", NULL); 792 const char *status = of_get_property(dn, "status", NULL);
754 const u32 *class_code = get_property(dn, "class-code", NULL); 793 const u32 *class_code = of_get_property(dn, "class-code", NULL);
755 const u32 *vendor_id = get_property(dn, "vendor-id", NULL); 794 const u32 *vendor_id = of_get_property(dn, "vendor-id", NULL);
756 const u32 *device_id = get_property(dn, "device-id", NULL); 795 const u32 *device_id = of_get_property(dn, "device-id", NULL);
757 const u32 *regs; 796 const u32 *regs;
758 int enable; 797 int enable;
759 struct pci_dn *pdn = PCI_DN(dn); 798 struct pci_dn *pdn = PCI_DN(dn);
@@ -796,7 +835,7 @@ static void *early_enable_eeh(struct device_node *dn, void *data)
796 835
797 /* Ok... see if this device supports EEH. Some do, some don't, 836 /* Ok... see if this device supports EEH. Some do, some don't,
798 * and the only way to find out is to check each and every one. */ 837 * and the only way to find out is to check each and every one. */
799 regs = get_property(dn, "reg", NULL); 838 regs = of_get_property(dn, "reg", NULL);
800 if (regs) { 839 if (regs) {
801 /* First register entry is addr (00BBSS00) */ 840 /* First register entry is addr (00BBSS00) */
802 /* Try to enable eeh */ 841 /* Try to enable eeh */
@@ -810,15 +849,7 @@ static void *early_enable_eeh(struct device_node *dn, void *data)
810 849
811 /* If the newer, better, ibm,get-config-addr-info is supported, 850 /* If the newer, better, ibm,get-config-addr-info is supported,
812 * then use that instead. */ 851 * then use that instead. */
813 pdn->eeh_pe_config_addr = 0; 852 pdn->eeh_pe_config_addr = get_pe_addr(pdn->eeh_config_addr, info);
814 if (ibm_get_config_addr_info != RTAS_UNKNOWN_SERVICE) {
815 ret = rtas_call (ibm_get_config_addr_info, 4, 2, rets,
816 pdn->eeh_config_addr,
817 info->buid_hi, info->buid_lo,
818 0);
819 if (ret == 0)
820 pdn->eeh_pe_config_addr = rets[0];
821 }
822 853
823 /* Some older systems (Power4) allow the 854 /* Some older systems (Power4) allow the
824 * ibm,set-eeh-option call to succeed even on nodes 855 * ibm,set-eeh-option call to succeed even on nodes
@@ -889,6 +920,7 @@ void __init eeh_init(void)
889 ibm_read_slot_reset_state = rtas_token("ibm,read-slot-reset-state"); 920 ibm_read_slot_reset_state = rtas_token("ibm,read-slot-reset-state");
890 ibm_slot_error_detail = rtas_token("ibm,slot-error-detail"); 921 ibm_slot_error_detail = rtas_token("ibm,slot-error-detail");
891 ibm_get_config_addr_info = rtas_token("ibm,get-config-addr-info"); 922 ibm_get_config_addr_info = rtas_token("ibm,get-config-addr-info");
923 ibm_get_config_addr_info2 = rtas_token("ibm,get-config-addr-info2");
892 ibm_configure_bridge = rtas_token ("ibm,configure-bridge"); 924 ibm_configure_bridge = rtas_token ("ibm,configure-bridge");
893 925
894 if (ibm_set_eeh_option == RTAS_UNKNOWN_SERVICE) 926 if (ibm_set_eeh_option == RTAS_UNKNOWN_SERVICE)
diff --git a/arch/powerpc/platforms/pseries/eeh_driver.c b/arch/powerpc/platforms/pseries/eeh_driver.c
index a4c0bf84ef2e..3170e003f76a 100644
--- a/arch/powerpc/platforms/pseries/eeh_driver.c
+++ b/arch/powerpc/platforms/pseries/eeh_driver.c
@@ -158,7 +158,8 @@ static void eeh_report_reset(struct pci_dev *dev, void *userdata)
158 return; 158 return;
159 159
160 rc = driver->err_handler->slot_reset(dev); 160 rc = driver->err_handler->slot_reset(dev);
161 if (*res == PCI_ERS_RESULT_NONE) *res = rc; 161 if ((*res == PCI_ERS_RESULT_NONE) ||
162 (*res == PCI_ERS_RESULT_RECOVERED)) *res = rc;
162 if (*res == PCI_ERS_RESULT_DISCONNECT && 163 if (*res == PCI_ERS_RESULT_DISCONNECT &&
163 rc == PCI_ERS_RESULT_NEED_RESET) *res = rc; 164 rc == PCI_ERS_RESULT_NEED_RESET) *res = rc;
164} 165}
@@ -248,6 +249,7 @@ static void eeh_report_failure(struct pci_dev *dev, void *userdata)
248 249
249static int eeh_reset_device (struct pci_dn *pe_dn, struct pci_bus *bus) 250static int eeh_reset_device (struct pci_dn *pe_dn, struct pci_bus *bus)
250{ 251{
252 struct device_node *dn;
251 int cnt, rc; 253 int cnt, rc;
252 254
253 /* pcibios will clear the counter; save the value */ 255 /* pcibios will clear the counter; save the value */
@@ -263,23 +265,20 @@ static int eeh_reset_device (struct pci_dn *pe_dn, struct pci_bus *bus)
263 if (rc) 265 if (rc)
264 return rc; 266 return rc;
265 267
266 /* New-style config addrs might be shared across multiple devices, 268 /* Walk over all functions on this device. */
267 * Walk over all functions on this device */ 269 dn = pe_dn->node;
268 if (pe_dn->eeh_pe_config_addr) { 270 if (!pcibios_find_pci_bus(dn) && PCI_DN(dn->parent))
269 struct device_node *pe = pe_dn->node; 271 dn = dn->parent->child;
270 pe = pe->parent->child; 272
271 while (pe) { 273 while (dn) {
272 struct pci_dn *ppe = PCI_DN(pe); 274 struct pci_dn *ppe = PCI_DN(dn);
273 if (pe_dn->eeh_pe_config_addr == ppe->eeh_pe_config_addr) { 275 /* On Power4, always true because eeh_pe_config_addr=0 */
274 rtas_configure_bridge(ppe); 276 if (pe_dn->eeh_pe_config_addr == ppe->eeh_pe_config_addr) {
275 eeh_restore_bars(ppe); 277 rtas_configure_bridge(ppe);
276 } 278 eeh_restore_bars(ppe);
277 pe = pe->sibling;
278 } 279 }
279 } else { 280 dn = dn->sibling;
280 rtas_configure_bridge(pe_dn); 281 }
281 eeh_restore_bars(pe_dn);
282 }
283 282
284 /* Give the system 5 seconds to finish running the user-space 283 /* Give the system 5 seconds to finish running the user-space
285 * hotplug shutdown scripts, e.g. ifdown for ethernet. Yes, 284 * hotplug shutdown scripts, e.g. ifdown for ethernet. Yes,
@@ -299,7 +298,7 @@ static int eeh_reset_device (struct pci_dn *pe_dn, struct pci_bus *bus)
299/* The longest amount of time to wait for a pci device 298/* The longest amount of time to wait for a pci device
300 * to come back on line, in seconds. 299 * to come back on line, in seconds.
301 */ 300 */
302#define MAX_WAIT_FOR_RECOVERY 15 301#define MAX_WAIT_FOR_RECOVERY 150
303 302
304struct pci_dn * handle_eeh_events (struct eeh_event *event) 303struct pci_dn * handle_eeh_events (struct eeh_event *event)
305{ 304{
@@ -315,14 +314,14 @@ struct pci_dn * handle_eeh_events (struct eeh_event *event)
315 314
316 if (!frozen_dn) { 315 if (!frozen_dn) {
317 316
318 location = get_property(event->dn, "ibm,loc-code", NULL); 317 location = of_get_property(event->dn, "ibm,loc-code", NULL);
319 location = location ? location : "unknown"; 318 location = location ? location : "unknown";
320 printk(KERN_ERR "EEH: Error: Cannot find partition endpoint " 319 printk(KERN_ERR "EEH: Error: Cannot find partition endpoint "
321 "for location=%s pci addr=%s\n", 320 "for location=%s pci addr=%s\n",
322 location, pci_name(event->dev)); 321 location, pci_name(event->dev));
323 return NULL; 322 return NULL;
324 } 323 }
325 location = get_property(frozen_dn, "ibm,loc-code", NULL); 324 location = of_get_property(frozen_dn, "ibm,loc-code", NULL);
326 location = location ? location : "unknown"; 325 location = location ? location : "unknown";
327 326
328 /* There are two different styles for coming up with the PE. 327 /* There are two different styles for coming up with the PE.
@@ -341,13 +340,6 @@ struct pci_dn * handle_eeh_events (struct eeh_event *event)
341 return NULL; 340 return NULL;
342 } 341 }
343 342
344#if 0
345 /* We may get "permanent failure" messages on empty slots.
346 * These are false alarms. Empty slots have no child dn. */
347 if ((event->state == pci_channel_io_perm_failure) && (frozen_device == NULL))
348 return;
349#endif
350
351 frozen_pdn = PCI_DN(frozen_dn); 343 frozen_pdn = PCI_DN(frozen_dn);
352 frozen_pdn->eeh_freeze_count++; 344 frozen_pdn->eeh_freeze_count++;
353 345
@@ -362,13 +354,12 @@ struct pci_dn * handle_eeh_events (struct eeh_event *event)
362 if (frozen_pdn->eeh_freeze_count > EEH_MAX_ALLOWED_FREEZES) 354 if (frozen_pdn->eeh_freeze_count > EEH_MAX_ALLOWED_FREEZES)
363 goto excess_failures; 355 goto excess_failures;
364 356
365 /* If the reset state is a '5' and the time to reset is 0 (infinity) 357 /* Get the current PCI slot state. */
366 * or is more then 15 seconds, then mark this as a permanent failure. 358 rc = eeh_wait_for_slot_status (frozen_pdn, MAX_WAIT_FOR_RECOVERY*1000);
367 */ 359 if (rc < 0) {
368 if ((event->state == pci_channel_io_perm_failure) && 360 printk(KERN_WARNING "EEH: Permanent failure\n");
369 ((event->time_unavail <= 0) ||
370 (event->time_unavail > MAX_WAIT_FOR_RECOVERY*1000)))
371 goto hard_fail; 361 goto hard_fail;
362 }
372 363
373 eeh_slot_error_detail(frozen_pdn, 1 /* Temporary Error */); 364 eeh_slot_error_detail(frozen_pdn, 1 /* Temporary Error */);
374 printk(KERN_WARNING 365 printk(KERN_WARNING
@@ -390,14 +381,18 @@ struct pci_dn * handle_eeh_events (struct eeh_event *event)
390 */ 381 */
391 if (result == PCI_ERS_RESULT_NONE) { 382 if (result == PCI_ERS_RESULT_NONE) {
392 rc = eeh_reset_device(frozen_pdn, frozen_bus); 383 rc = eeh_reset_device(frozen_pdn, frozen_bus);
393 if (rc) 384 if (rc) {
385 printk(KERN_WARNING "EEH: Unable to reset, rc=%d\n", rc);
394 goto hard_fail; 386 goto hard_fail;
387 }
395 } 388 }
396 389
397 /* If all devices reported they can proceed, then re-enable MMIO */ 390 /* If all devices reported they can proceed, then re-enable MMIO */
398 if (result == PCI_ERS_RESULT_CAN_RECOVER) { 391 if (result == PCI_ERS_RESULT_CAN_RECOVER) {
399 rc = rtas_pci_enable(frozen_pdn, EEH_THAW_MMIO); 392 rc = rtas_pci_enable(frozen_pdn, EEH_THAW_MMIO);
400 393
394 if (rc < 0)
395 goto hard_fail;
401 if (rc) { 396 if (rc) {
402 result = PCI_ERS_RESULT_NEED_RESET; 397 result = PCI_ERS_RESULT_NEED_RESET;
403 } else { 398 } else {
@@ -410,6 +405,8 @@ struct pci_dn * handle_eeh_events (struct eeh_event *event)
410 if (result == PCI_ERS_RESULT_CAN_RECOVER) { 405 if (result == PCI_ERS_RESULT_CAN_RECOVER) {
411 rc = rtas_pci_enable(frozen_pdn, EEH_THAW_DMA); 406 rc = rtas_pci_enable(frozen_pdn, EEH_THAW_DMA);
412 407
408 if (rc < 0)
409 goto hard_fail;
413 if (rc) 410 if (rc)
414 result = PCI_ERS_RESULT_NEED_RESET; 411 result = PCI_ERS_RESULT_NEED_RESET;
415 else 412 else
@@ -417,21 +414,28 @@ struct pci_dn * handle_eeh_events (struct eeh_event *event)
417 } 414 }
418 415
419 /* If any device has a hard failure, then shut off everything. */ 416 /* If any device has a hard failure, then shut off everything. */
420 if (result == PCI_ERS_RESULT_DISCONNECT) 417 if (result == PCI_ERS_RESULT_DISCONNECT) {
418 printk(KERN_WARNING "EEH: Device driver gave up\n");
421 goto hard_fail; 419 goto hard_fail;
420 }
422 421
423 /* If any device called out for a reset, then reset the slot */ 422 /* If any device called out for a reset, then reset the slot */
424 if (result == PCI_ERS_RESULT_NEED_RESET) { 423 if (result == PCI_ERS_RESULT_NEED_RESET) {
425 rc = eeh_reset_device(frozen_pdn, NULL); 424 rc = eeh_reset_device(frozen_pdn, NULL);
426 if (rc) 425 if (rc) {
426 printk(KERN_WARNING "EEH: Cannot reset, rc=%d\n", rc);
427 goto hard_fail; 427 goto hard_fail;
428 }
428 result = PCI_ERS_RESULT_NONE; 429 result = PCI_ERS_RESULT_NONE;
429 pci_walk_bus(frozen_bus, eeh_report_reset, &result); 430 pci_walk_bus(frozen_bus, eeh_report_reset, &result);
430 } 431 }
431 432
432 /* All devices should claim they have recovered by now. */ 433 /* All devices should claim they have recovered by now. */
433 if (result != PCI_ERS_RESULT_RECOVERED) 434 if ((result != PCI_ERS_RESULT_RECOVERED) &&
435 (result != PCI_ERS_RESULT_NONE)) {
436 printk(KERN_WARNING "EEH: Not recovered\n");
434 goto hard_fail; 437 goto hard_fail;
438 }
435 439
436 /* Tell all device drivers that they can resume operations */ 440 /* Tell all device drivers that they can resume operations */
437 pci_walk_bus(frozen_bus, eeh_report_resume, NULL); 441 pci_walk_bus(frozen_bus, eeh_report_resume, NULL);
diff --git a/arch/powerpc/platforms/pseries/eeh_event.c b/arch/powerpc/platforms/pseries/eeh_event.c
index 49037edf7d39..ddb80f5d850b 100644
--- a/arch/powerpc/platforms/pseries/eeh_event.c
+++ b/arch/powerpc/platforms/pseries/eeh_event.c
@@ -118,9 +118,7 @@ static void eeh_thread_launcher(struct work_struct *dummy)
118 * (from a workqueue). 118 * (from a workqueue).
119 */ 119 */
120int eeh_send_failure_event (struct device_node *dn, 120int eeh_send_failure_event (struct device_node *dn,
121 struct pci_dev *dev, 121 struct pci_dev *dev)
122 enum pci_channel_state state,
123 int time_unavail)
124{ 122{
125 unsigned long flags; 123 unsigned long flags;
126 struct eeh_event *event; 124 struct eeh_event *event;
@@ -128,7 +126,7 @@ int eeh_send_failure_event (struct device_node *dn,
128 126
129 if (!mem_init_done) { 127 if (!mem_init_done) {
130 printk(KERN_ERR "EEH: event during early boot not handled\n"); 128 printk(KERN_ERR "EEH: event during early boot not handled\n");
131 location = get_property(dn, "ibm,loc-code", NULL); 129 location = of_get_property(dn, "ibm,loc-code", NULL);
132 printk(KERN_ERR "EEH: device node = %s\n", dn->full_name); 130 printk(KERN_ERR "EEH: device node = %s\n", dn->full_name);
133 printk(KERN_ERR "EEH: PCI location = %s\n", location); 131 printk(KERN_ERR "EEH: PCI location = %s\n", location);
134 return 1; 132 return 1;
@@ -144,8 +142,6 @@ int eeh_send_failure_event (struct device_node *dn,
144 142
145 event->dn = dn; 143 event->dn = dn;
146 event->dev = dev; 144 event->dev = dev;
147 event->state = state;
148 event->time_unavail = time_unavail;
149 145
150 /* We may or may not be called in an interrupt context */ 146 /* We may or may not be called in an interrupt context */
151 spin_lock_irqsave(&eeh_eventlist_lock, flags); 147 spin_lock_irqsave(&eeh_eventlist_lock, flags);
diff --git a/arch/powerpc/platforms/pseries/firmware.c b/arch/powerpc/platforms/pseries/firmware.c
index 90522e3c9d46..29bf83bfb1f0 100644
--- a/arch/powerpc/platforms/pseries/firmware.c
+++ b/arch/powerpc/platforms/pseries/firmware.c
@@ -80,7 +80,7 @@ void __init fw_feature_init(void)
80 goto out; 80 goto out;
81 } 81 }
82 82
83 hypertas = get_property(dn, "ibm,hypertas-functions", &len); 83 hypertas = of_get_property(dn, "ibm,hypertas-functions", &len);
84 if (hypertas == NULL) 84 if (hypertas == NULL)
85 goto out; 85 goto out;
86 86
diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
index f460b9cbfd46..9711eb0d5496 100644
--- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
+++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
@@ -143,7 +143,7 @@ static int pseries_add_processor(struct device_node *np)
143 int err = -ENOSPC, len, nthreads, i; 143 int err = -ENOSPC, len, nthreads, i;
144 const u32 *intserv; 144 const u32 *intserv;
145 145
146 intserv = get_property(np, "ibm,ppc-interrupt-server#s", &len); 146 intserv = of_get_property(np, "ibm,ppc-interrupt-server#s", &len);
147 if (!intserv) 147 if (!intserv)
148 return 0; 148 return 0;
149 149
@@ -203,7 +203,7 @@ static void pseries_remove_processor(struct device_node *np)
203 int len, nthreads, i; 203 int len, nthreads, i;
204 const u32 *intserv; 204 const u32 *intserv;
205 205
206 intserv = get_property(np, "ibm,ppc-interrupt-server#s", &len); 206 intserv = of_get_property(np, "ibm,ppc-interrupt-server#s", &len);
207 if (!intserv) 207 if (!intserv)
208 return; 208 return;
209 209
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index e6653a868b91..66665c82415c 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -242,6 +242,7 @@ static unsigned long tce_get_pSeriesLP(struct iommu_table *tbl, long tcenum)
242 return tce_ret; 242 return tce_ret;
243} 243}
244 244
245#ifdef CONFIG_PCI
245static void iommu_table_setparms(struct pci_controller *phb, 246static void iommu_table_setparms(struct pci_controller *phb,
246 struct device_node *dn, 247 struct device_node *dn,
247 struct iommu_table *tbl) 248 struct iommu_table *tbl)
@@ -252,8 +253,8 @@ static void iommu_table_setparms(struct pci_controller *phb,
252 253
253 node = (struct device_node *)phb->arch_data; 254 node = (struct device_node *)phb->arch_data;
254 255
255 basep = get_property(node, "linux,tce-base", NULL); 256 basep = of_get_property(node, "linux,tce-base", NULL);
256 sizep = get_property(node, "linux,tce-size", NULL); 257 sizep = of_get_property(node, "linux,tce-size", NULL);
257 if (basep == NULL || sizep == NULL) { 258 if (basep == NULL || sizep == NULL) {
258 printk(KERN_ERR "PCI_DMA: iommu_table_setparms: %s has " 259 printk(KERN_ERR "PCI_DMA: iommu_table_setparms: %s has "
259 "missing tce entries !\n", dn->full_name); 260 "missing tce entries !\n", dn->full_name);
@@ -403,7 +404,7 @@ static void pci_dma_bus_setup_pSeriesLP(struct pci_bus *bus)
403 404
404 /* Find nearest ibm,dma-window, walking up the device tree */ 405 /* Find nearest ibm,dma-window, walking up the device tree */
405 for (pdn = dn; pdn != NULL; pdn = pdn->parent) { 406 for (pdn = dn; pdn != NULL; pdn = pdn->parent) {
406 dma_window = get_property(pdn, "ibm,dma-window", NULL); 407 dma_window = of_get_property(pdn, "ibm,dma-window", NULL);
407 if (dma_window != NULL) 408 if (dma_window != NULL)
408 break; 409 break;
409 } 410 }
@@ -478,29 +479,6 @@ static void pci_dma_dev_setup_pSeries(struct pci_dev *dev)
478 pci_name(dev)); 479 pci_name(dev));
479} 480}
480 481
481static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long action, void *node)
482{
483 int err = NOTIFY_OK;
484 struct device_node *np = node;
485 struct pci_dn *pci = PCI_DN(np);
486
487 switch (action) {
488 case PSERIES_RECONFIG_REMOVE:
489 if (pci && pci->iommu_table &&
490 get_property(np, "ibm,dma-window", NULL))
491 iommu_free_table(np);
492 break;
493 default:
494 err = NOTIFY_DONE;
495 break;
496 }
497 return err;
498}
499
500static struct notifier_block iommu_reconfig_nb = {
501 .notifier_call = iommu_reconfig_notifier,
502};
503
504static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev) 482static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
505{ 483{
506 struct device_node *pdn, *dn; 484 struct device_node *pdn, *dn;
@@ -521,7 +499,7 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
521 499
522 for (pdn = dn; pdn && PCI_DN(pdn) && !PCI_DN(pdn)->iommu_table; 500 for (pdn = dn; pdn && PCI_DN(pdn) && !PCI_DN(pdn)->iommu_table;
523 pdn = pdn->parent) { 501 pdn = pdn->parent) {
524 dma_window = get_property(pdn, "ibm,dma-window", NULL); 502 dma_window = of_get_property(pdn, "ibm,dma-window", NULL);
525 if (dma_window) 503 if (dma_window)
526 break; 504 break;
527 } 505 }
@@ -554,15 +532,44 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev)
554 532
555 dev->dev.archdata.dma_data = pci->iommu_table; 533 dev->dev.archdata.dma_data = pci->iommu_table;
556} 534}
535#else /* CONFIG_PCI */
536#define pci_dma_bus_setup_pSeries NULL
537#define pci_dma_dev_setup_pSeries NULL
538#define pci_dma_bus_setup_pSeriesLP NULL
539#define pci_dma_dev_setup_pSeriesLP NULL
540#endif /* !CONFIG_PCI */
541
542static int iommu_reconfig_notifier(struct notifier_block *nb, unsigned long action, void *node)
543{
544 int err = NOTIFY_OK;
545 struct device_node *np = node;
546 struct pci_dn *pci = PCI_DN(np);
547
548 switch (action) {
549 case PSERIES_RECONFIG_REMOVE:
550 if (pci && pci->iommu_table &&
551 of_get_property(np, "ibm,dma-window", NULL))
552 iommu_free_table(np);
553 break;
554 default:
555 err = NOTIFY_DONE;
556 break;
557 }
558 return err;
559}
560
561static struct notifier_block iommu_reconfig_nb = {
562 .notifier_call = iommu_reconfig_notifier,
563};
557 564
558/* These are called very early. */ 565/* These are called very early. */
559void iommu_init_early_pSeries(void) 566void iommu_init_early_pSeries(void)
560{ 567{
561 if (of_chosen && get_property(of_chosen, "linux,iommu-off", NULL)) { 568 if (of_chosen && of_get_property(of_chosen, "linux,iommu-off", NULL)) {
562 /* Direct I/O, IOMMU off */ 569 /* Direct I/O, IOMMU off */
563 ppc_md.pci_dma_dev_setup = NULL; 570 ppc_md.pci_dma_dev_setup = NULL;
564 ppc_md.pci_dma_bus_setup = NULL; 571 ppc_md.pci_dma_bus_setup = NULL;
565 pci_dma_ops = &dma_direct_ops; 572 set_pci_dma_ops(&dma_direct_ops);
566 return; 573 return;
567 } 574 }
568 575
@@ -588,6 +595,6 @@ void iommu_init_early_pSeries(void)
588 595
589 pSeries_reconfig_notifier_register(&iommu_reconfig_nb); 596 pSeries_reconfig_notifier_register(&iommu_reconfig_nb);
590 597
591 pci_dma_ops = &dma_iommu_ops; 598 set_pci_dma_ops(&dma_iommu_ops);
592} 599}
593 600
diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c
index 843ee9643211..3a70e8ad7bc8 100644
--- a/arch/powerpc/platforms/pseries/lpar.c
+++ b/arch/powerpc/platforms/pseries/lpar.c
@@ -209,13 +209,13 @@ void __init find_udbg_vterm(void)
209 /* find the boot console from /chosen/stdout */ 209 /* find the boot console from /chosen/stdout */
210 if (!of_chosen) 210 if (!of_chosen)
211 return; 211 return;
212 name = get_property(of_chosen, "linux,stdout-path", NULL); 212 name = of_get_property(of_chosen, "linux,stdout-path", NULL);
213 if (name == NULL) 213 if (name == NULL)
214 return; 214 return;
215 stdout_node = of_find_node_by_path(name); 215 stdout_node = of_find_node_by_path(name);
216 if (!stdout_node) 216 if (!stdout_node)
217 return; 217 return;
218 name = get_property(stdout_node, "name", NULL); 218 name = of_get_property(stdout_node, "name", NULL);
219 if (!name) { 219 if (!name) {
220 printk(KERN_WARNING "stdout node missing 'name' property!\n"); 220 printk(KERN_WARNING "stdout node missing 'name' property!\n");
221 goto out; 221 goto out;
@@ -226,7 +226,7 @@ void __init find_udbg_vterm(void)
226 /* Check if it's a virtual terminal */ 226 /* Check if it's a virtual terminal */
227 if (strncmp(name, "vty", 3) != 0) 227 if (strncmp(name, "vty", 3) != 0)
228 goto out; 228 goto out;
229 termno = get_property(stdout_node, "reg", NULL); 229 termno = of_get_property(stdout_node, "reg", NULL);
230 if (termno == NULL) 230 if (termno == NULL)
231 goto out; 231 goto out;
232 vtermno = termno[0]; 232 vtermno = termno[0];
diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c
index 64163cecdf93..f68903e15bd5 100644
--- a/arch/powerpc/platforms/pseries/nvram.c
+++ b/arch/powerpc/platforms/pseries/nvram.c
@@ -130,7 +130,7 @@ int __init pSeries_nvram_init(void)
130 if (nvram == NULL) 130 if (nvram == NULL)
131 return -ENODEV; 131 return -ENODEV;
132 132
133 nbytes_p = get_property(nvram, "#bytes", &proplen); 133 nbytes_p = of_get_property(nvram, "#bytes", &proplen);
134 if (nbytes_p == NULL || proplen != sizeof(unsigned int)) 134 if (nbytes_p == NULL || proplen != sizeof(unsigned int))
135 return -EIO; 135 return -EIO;
136 136
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index fa59124ce3fe..2c6ded29f73d 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -25,6 +25,7 @@
25#include <linux/pci.h> 25#include <linux/pci.h>
26#include <linux/string.h> 26#include <linux/string.h>
27 27
28#include <asm/eeh.h>
28#include <asm/pci-bridge.h> 29#include <asm/pci-bridge.h>
29#include <asm/prom.h> 30#include <asm/prom.h>
30#include <asm/ppc-pci.h> 31#include <asm/ppc-pci.h>
@@ -39,7 +40,7 @@ void pcibios_name_device(struct pci_dev *dev)
39 */ 40 */
40 dn = pci_device_to_OF_node(dev); 41 dn = pci_device_to_OF_node(dev);
41 if (dn) { 42 if (dn) {
42 char *loc_code = get_property(dn, "ibm,loc-code", 0); 43 const char *loc_code = of_get_property(dn, "ibm,loc-code", 0);
43 if (loc_code) { 44 if (loc_code) {
44 int loc_len = strlen(loc_code); 45 int loc_len = strlen(loc_code);
45 if (loc_len < sizeof(dev->dev.name)) { 46 if (loc_len < sizeof(dev->dev.name)) {
diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c
index ac56b868913a..fdc1a369f767 100644
--- a/arch/powerpc/platforms/pseries/pci_dlpar.c
+++ b/arch/powerpc/platforms/pseries/pci_dlpar.c
@@ -29,6 +29,7 @@
29#include <asm/pci-bridge.h> 29#include <asm/pci-bridge.h>
30#include <asm/ppc-pci.h> 30#include <asm/ppc-pci.h>
31#include <asm/firmware.h> 31#include <asm/firmware.h>
32#include <asm/eeh.h>
32 33
33static struct pci_bus * 34static struct pci_bus *
34find_bus_among_children(struct pci_bus *bus, 35find_bus_among_children(struct pci_bus *bus,
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index edc038873113..53aa04101ced 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -85,7 +85,7 @@ static void request_ras_irqs(struct device_node *np,
85 * map those interrupts using the default interrupt host and default 85 * map those interrupts using the default interrupt host and default
86 * trigger 86 * trigger
87 */ 87 */
88 opicprop = get_property(np, "open-pic-interrupt", &opicplen); 88 opicprop = of_get_property(np, "open-pic-interrupt", &opicplen);
89 if (opicprop) { 89 if (opicprop) {
90 opicplen /= sizeof(u32); 90 opicplen /= sizeof(u32);
91 for (i = 0; i < opicplen; i++) { 91 for (i = 0; i < opicplen; i++) {
diff --git a/arch/powerpc/platforms/pseries/rtasd.c b/arch/powerpc/platforms/pseries/rtasd.c
index 77d0937d5c07..9797b10b2935 100644
--- a/arch/powerpc/platforms/pseries/rtasd.c
+++ b/arch/powerpc/platforms/pseries/rtasd.c
@@ -363,7 +363,7 @@ static int get_eventscan_parms(void)
363 363
364 node = of_find_node_by_path("/rtas"); 364 node = of_find_node_by_path("/rtas");
365 365
366 ip = get_property(node, "rtas-event-scan-rate", NULL); 366 ip = of_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 34aff47b1f55..33eec2822c66 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -65,6 +65,7 @@
65#include <asm/udbg.h> 65#include <asm/udbg.h>
66#include <asm/smp.h> 66#include <asm/smp.h>
67#include <asm/firmware.h> 67#include <asm/firmware.h>
68#include <asm/eeh.h>
68 69
69#include "plpar_wrappers.h" 70#include "plpar_wrappers.h"
70#include "pseries.h" 71#include "pseries.h"
@@ -92,7 +93,7 @@ static void pSeries_show_cpuinfo(struct seq_file *m)
92 93
93 root = of_find_node_by_path("/"); 94 root = of_find_node_by_path("/");
94 if (root) 95 if (root)
95 model = get_property(root, "model", NULL); 96 model = of_get_property(root, "model", NULL);
96 seq_printf(m, "machine\t\t: CHRP %s\n", model); 97 seq_printf(m, "machine\t\t: CHRP %s\n", model);
97 of_node_put(root); 98 of_node_put(root);
98} 99}
@@ -138,8 +139,8 @@ static void __init pseries_mpic_init_IRQ(void)
138 struct mpic *mpic; 139 struct mpic *mpic;
139 140
140 np = of_find_node_by_path("/"); 141 np = of_find_node_by_path("/");
141 naddr = prom_n_addr_cells(np); 142 naddr = of_n_addr_cells(np);
142 opprop = get_property(np, "platform-open-pic", &opplen); 143 opprop = of_get_property(np, "platform-open-pic", &opplen);
143 if (opprop != 0) { 144 if (opprop != 0) {
144 openpic_addr = of_read_number(opprop, naddr); 145 openpic_addr = of_read_number(opprop, naddr);
145 printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr); 146 printk(KERN_DEBUG "OpenPIC addr: %lx\n", openpic_addr);
@@ -188,11 +189,11 @@ static void __init pseries_mpic_init_IRQ(void)
188 break; 189 break;
189 if (strcmp(np->name, "pci") != 0) 190 if (strcmp(np->name, "pci") != 0)
190 continue; 191 continue;
191 addrp = get_property(np, "8259-interrupt-acknowledge", 192 addrp = of_get_property(np, "8259-interrupt-acknowledge",
192 NULL); 193 NULL);
193 if (addrp == NULL) 194 if (addrp == NULL)
194 continue; 195 continue;
195 naddr = prom_n_addr_cells(np); 196 naddr = of_n_addr_cells(np);
196 intack = addrp[naddr-1]; 197 intack = addrp[naddr-1];
197 if (naddr > 1) 198 if (naddr > 1)
198 intack |= ((unsigned long)addrp[naddr-2]) << 32; 199 intack |= ((unsigned long)addrp[naddr-2]) << 32;
@@ -225,7 +226,7 @@ static void __init pseries_discover_pic(void)
225 226
226 for (np = NULL; (np = of_find_node_by_name(np, 227 for (np = NULL; (np = of_find_node_by_name(np,
227 "interrupt-controller"));) { 228 "interrupt-controller"));) {
228 typep = get_property(np, "compatible", NULL); 229 typep = of_get_property(np, "compatible", NULL);
229 if (strstr(typep, "open-pic")) { 230 if (strstr(typep, "open-pic")) {
230 pSeries_mpic_node = of_node_get(np); 231 pSeries_mpic_node = of_node_get(np);
231 ppc_md.init_IRQ = pseries_mpic_init_IRQ; 232 ppc_md.init_IRQ = pseries_mpic_init_IRQ;
@@ -334,32 +335,6 @@ static void __init pSeries_init_early(void)
334 DBG(" <- pSeries_init_early()\n"); 335 DBG(" <- pSeries_init_early()\n");
335} 336}
336 337
337
338static int pSeries_check_legacy_ioport(unsigned int baseport)
339{
340 struct device_node *np;
341
342#define I8042_DATA_REG 0x60
343#define FDC_BASE 0x3f0
344
345
346 switch(baseport) {
347 case I8042_DATA_REG:
348 np = of_find_node_by_type(NULL, "8042");
349 if (np == NULL)
350 return -ENODEV;
351 of_node_put(np);
352 break;
353 case FDC_BASE:
354 np = of_find_node_by_type(NULL, "fdc");
355 if (np == NULL)
356 return -ENODEV;
357 of_node_put(np);
358 break;
359 }
360 return 0;
361}
362
363/* 338/*
364 * Called very early, MMU is off, device-tree isn't unflattened 339 * Called very early, MMU is off, device-tree isn't unflattened
365 */ 340 */
@@ -514,6 +489,10 @@ void pSeries_power_off(void)
514 for (;;); 489 for (;;);
515} 490}
516 491
492#ifndef CONFIG_PCI
493void pSeries_final_fixup(void) { }
494#endif
495
517define_machine(pseries) { 496define_machine(pseries) {
518 .name = "pSeries", 497 .name = "pSeries",
519 .probe = pSeries_probe, 498 .probe = pSeries_probe,
@@ -532,7 +511,6 @@ define_machine(pseries) {
532 .set_rtc_time = rtas_set_rtc_time, 511 .set_rtc_time = rtas_set_rtc_time,
533 .calibrate_decr = generic_calibrate_decr, 512 .calibrate_decr = generic_calibrate_decr,
534 .progress = rtas_progress, 513 .progress = rtas_progress,
535 .check_legacy_ioport = pSeries_check_legacy_ioport,
536 .system_reset_exception = pSeries_system_reset_exception, 514 .system_reset_exception = pSeries_system_reset_exception,
537 .machine_check_exception = pSeries_machine_check_exception, 515 .machine_check_exception = pSeries_machine_check_exception,
538}; 516};
diff --git a/arch/powerpc/platforms/pseries/xics.c b/arch/powerpc/platforms/pseries/xics.c
index 81d172d65038..896cbf340c42 100644
--- a/arch/powerpc/platforms/pseries/xics.c
+++ b/arch/powerpc/platforms/pseries/xics.c
@@ -576,7 +576,7 @@ static void __init xics_init_one_node(struct device_node *np,
576 * This happens to be the case so far but we are playing with fire... 576 * This happens to be the case so far but we are playing with fire...
577 * should be fixed one of these days. -BenH. 577 * should be fixed one of these days. -BenH.
578 */ 578 */
579 ireg = get_property(np, "ibm,interrupt-server-ranges", NULL); 579 ireg = of_get_property(np, "ibm,interrupt-server-ranges", NULL);
580 580
581 /* Do that ever happen ? we'll know soon enough... but even good'old 581 /* Do that ever happen ? we'll know soon enough... but even good'old
582 * f80 does have that property .. 582 * f80 does have that property ..
@@ -588,7 +588,7 @@ static void __init xics_init_one_node(struct device_node *np,
588 */ 588 */
589 *indx = *ireg; 589 *indx = *ireg;
590 } 590 }
591 ireg = get_property(np, "reg", &ilen); 591 ireg = of_get_property(np, "reg", &ilen);
592 if (!ireg) 592 if (!ireg)
593 panic("xics_init_IRQ: can't find interrupt reg property"); 593 panic("xics_init_IRQ: can't find interrupt reg property");
594 594
@@ -640,10 +640,10 @@ static void __init xics_setup_8259_cascade(void)
640 break; 640 break;
641 if (strcmp(np->name, "pci") != 0) 641 if (strcmp(np->name, "pci") != 0)
642 continue; 642 continue;
643 addrp = get_property(np, "8259-interrupt-acknowledge", NULL); 643 addrp = of_get_property(np, "8259-interrupt-acknowledge", NULL);
644 if (addrp == NULL) 644 if (addrp == NULL)
645 continue; 645 continue;
646 naddr = prom_n_addr_cells(np); 646 naddr = of_n_addr_cells(np);
647 intack = addrp[naddr-1]; 647 intack = addrp[naddr-1];
648 if (naddr > 1) 648 if (naddr > 1)
649 intack |= ((unsigned long)addrp[naddr-2]) << 32; 649 intack |= ((unsigned long)addrp[naddr-2]) << 32;
@@ -664,10 +664,11 @@ static struct device_node *cpuid_to_of_node(int cpu)
664 int i, len; 664 int i, len;
665 const u32 *intserv; 665 const u32 *intserv;
666 666
667 intserv = get_property(np, "ibm,ppc-interrupt-server#s", &len); 667 intserv = of_get_property(np, "ibm,ppc-interrupt-server#s",
668 &len);
668 669
669 if (!intserv) 670 if (!intserv)
670 intserv = get_property(np, "reg", &len); 671 intserv = of_get_property(np, "reg", &len);
671 672
672 i = len / sizeof(u32); 673 i = len / sizeof(u32);
673 674
@@ -709,7 +710,7 @@ void __init xics_init_IRQ(void)
709 /* Find the server numbers for the boot cpu. */ 710 /* Find the server numbers for the boot cpu. */
710 np = cpuid_to_of_node(boot_cpuid); 711 np = cpuid_to_of_node(boot_cpuid);
711 BUG_ON(!np); 712 BUG_ON(!np);
712 ireg = get_property(np, "ibm,ppc-interrupt-gserver#s", &ilen); 713 ireg = of_get_property(np, "ibm,ppc-interrupt-gserver#s", &ilen);
713 if (!ireg) 714 if (!ireg)
714 goto skip_gserver_check; 715 goto skip_gserver_check;
715 i = ilen / sizeof(int); 716 i = ilen / sizeof(int);
@@ -725,7 +726,7 @@ void __init xics_init_IRQ(void)
725 default_server = hcpuid; 726 default_server = hcpuid;
726 default_distrib_server = ireg[j+1]; 727 default_distrib_server = ireg[j+1];
727 728
728 isize = get_property(np, 729 isize = of_get_property(np,
729 "ibm,interrupt-server#-size", NULL); 730 "ibm,interrupt-server#-size", NULL);
730 if (isize) 731 if (isize)
731 interrupt_server_size = *isize; 732 interrupt_server_size = *isize;
diff --git a/arch/powerpc/sysdev/Makefile b/arch/powerpc/sysdev/Makefile
index 26ca3ffbc1de..e96ca9618dbb 100644
--- a/arch/powerpc/sysdev/Makefile
+++ b/arch/powerpc/sysdev/Makefile
@@ -11,12 +11,17 @@ obj-$(CONFIG_PPC_PMI) += pmi.o
11obj-$(CONFIG_U3_DART) += dart_iommu.o 11obj-$(CONFIG_U3_DART) += dart_iommu.o
12obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o 12obj-$(CONFIG_MMIO_NVRAM) += mmio_nvram.o
13obj-$(CONFIG_FSL_SOC) += fsl_soc.o 13obj-$(CONFIG_FSL_SOC) += fsl_soc.o
14obj-$(CONFIG_FSL_PCIE) += fsl_pcie.o
14obj-$(CONFIG_TSI108_BRIDGE) += tsi108_pci.o tsi108_dev.o 15obj-$(CONFIG_TSI108_BRIDGE) += tsi108_pci.o tsi108_dev.o
15obj-$(CONFIG_QUICC_ENGINE) += qe_lib/ 16obj-$(CONFIG_QUICC_ENGINE) += qe_lib/
16 17
18# contains only the suspend handler for time
19obj-$(CONFIG_PM) += timer.o
20
17ifeq ($(CONFIG_PPC_MERGE),y) 21ifeq ($(CONFIG_PPC_MERGE),y)
18obj-$(CONFIG_PPC_I8259) += i8259.o 22obj-$(CONFIG_PPC_I8259) += i8259.o
19obj-$(CONFIG_PPC_83xx) += ipic.o 23obj-$(CONFIG_PPC_83xx) += ipic.o
24obj-$(CONFIG_4xx) += uic.o
20endif 25endif
21 26
22# Temporary hack until we have migrated to asm-powerpc 27# Temporary hack until we have migrated to asm-powerpc
diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c
index 1488535b0e13..336186dd7f10 100644
--- a/arch/powerpc/sysdev/dart_iommu.c
+++ b/arch/powerpc/sysdev/dart_iommu.c
@@ -333,7 +333,7 @@ void iommu_init_early_dart(void)
333 ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_dart; 333 ppc_md.pci_dma_bus_setup = pci_dma_bus_setup_dart;
334 334
335 /* Setup pci_dma ops */ 335 /* Setup pci_dma ops */
336 pci_dma_ops = &dma_iommu_ops; 336 set_pci_dma_ops(&dma_iommu_ops);
337 return; 337 return;
338 } 338 }
339 339
@@ -343,7 +343,7 @@ void iommu_init_early_dart(void)
343 ppc_md.pci_dma_bus_setup = NULL; 343 ppc_md.pci_dma_bus_setup = NULL;
344 344
345 /* Setup pci_dma ops */ 345 /* Setup pci_dma ops */
346 pci_dma_ops = &dma_direct_ops; 346 set_pci_dma_ops(&dma_direct_ops);
347} 347}
348 348
349 349
diff --git a/arch/powerpc/sysdev/dcr.c b/arch/powerpc/sysdev/dcr.c
index 1fc5819e7d18..574b6ef44e0b 100644
--- a/arch/powerpc/sysdev/dcr.c
+++ b/arch/powerpc/sysdev/dcr.c
@@ -26,7 +26,7 @@
26unsigned int dcr_resource_start(struct device_node *np, unsigned int index) 26unsigned int dcr_resource_start(struct device_node *np, unsigned int index)
27{ 27{
28 unsigned int ds; 28 unsigned int ds;
29 const u32 *dr = get_property(np, "dcr-reg", &ds); 29 const u32 *dr = of_get_property(np, "dcr-reg", &ds);
30 30
31 if (dr == NULL || ds & 1 || index >= (ds / 8)) 31 if (dr == NULL || ds & 1 || index >= (ds / 8))
32 return 0; 32 return 0;
@@ -37,7 +37,7 @@ unsigned int dcr_resource_start(struct device_node *np, unsigned int index)
37unsigned int dcr_resource_len(struct device_node *np, unsigned int index) 37unsigned int dcr_resource_len(struct device_node *np, unsigned int index)
38{ 38{
39 unsigned int ds; 39 unsigned int ds;
40 const u32 *dr = get_property(np, "dcr-reg", &ds); 40 const u32 *dr = of_get_property(np, "dcr-reg", &ds);
41 41
42 if (dr == NULL || ds & 1 || index >= (ds / 8)) 42 if (dr == NULL || ds & 1 || index >= (ds / 8))
43 return 0; 43 return 0;
@@ -53,9 +53,9 @@ static struct device_node * find_dcr_parent(struct device_node * node)
53 const u32 *p; 53 const u32 *p;
54 54
55 for (par = of_node_get(node); par;) { 55 for (par = of_node_get(node); par;) {
56 if (get_property(par, "dcr-controller", NULL)) 56 if (of_get_property(par, "dcr-controller", NULL))
57 break; 57 break;
58 p = get_property(par, "dcr-parent", NULL); 58 p = of_get_property(par, "dcr-parent", NULL);
59 tmp = par; 59 tmp = par;
60 if (p == NULL) 60 if (p == NULL)
61 par = of_get_parent(par); 61 par = of_get_parent(par);
@@ -80,13 +80,13 @@ u64 of_translate_dcr_address(struct device_node *dev,
80 return OF_BAD_ADDR; 80 return OF_BAD_ADDR;
81 81
82 /* Stride is not properly defined yet, default to 0x10 for Axon */ 82 /* Stride is not properly defined yet, default to 0x10 for Axon */
83 p = get_property(dp, "dcr-mmio-stride", NULL); 83 p = of_get_property(dp, "dcr-mmio-stride", NULL);
84 stride = (p == NULL) ? 0x10 : *p; 84 stride = (p == NULL) ? 0x10 : *p;
85 85
86 /* XXX FIXME: Which property name is to use of the 2 following ? */ 86 /* XXX FIXME: Which property name is to use of the 2 following ? */
87 p = get_property(dp, "dcr-mmio-range", NULL); 87 p = of_get_property(dp, "dcr-mmio-range", NULL);
88 if (p == NULL) 88 if (p == NULL)
89 p = get_property(dp, "dcr-mmio-space", NULL); 89 p = of_get_property(dp, "dcr-mmio-space", NULL);
90 if (p == NULL) 90 if (p == NULL)
91 return OF_BAD_ADDR; 91 return OF_BAD_ADDR;
92 92
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_pcie.c b/arch/powerpc/sysdev/fsl_pcie.c
index a2f4f730213e..041c07e8b665 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_pcie.c
+++ b/arch/powerpc/sysdev/fsl_pcie.c
@@ -24,8 +24,6 @@
24#include <asm/pci-bridge.h> 24#include <asm/pci-bridge.h>
25#include <asm/machdep.h> 25#include <asm/machdep.h>
26 26
27#include "mpc86xx.h"
28
29#define PCI_CFG_OUT out_be32 27#define PCI_CFG_OUT out_be32
30 28
31/* ERRATA PCI-Ex 14 PCIE Controller timeout */ 29/* ERRATA PCI-Ex 14 PCIE Controller timeout */
diff --git a/arch/powerpc/sysdev/fsl_pcie.h b/arch/powerpc/sysdev/fsl_pcie.h
new file mode 100644
index 000000000000..8d9779c84bea
--- /dev/null
+++ b/arch/powerpc/sysdev/fsl_pcie.h
@@ -0,0 +1,94 @@
1/*
2 * MPC85xx/86xx PCI Express structure define
3 *
4 * Copyright 2007 Freescale Semiconductor, Inc
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
13#ifdef __KERNEL__
14#ifndef __POWERPC_FSL_PCIE_H
15#define __POWERPC_FSL_PCIE_H
16
17/* PCIE Express IO block registers in 85xx/86xx */
18
19struct ccsr_pex {
20 __be32 __iomem pex_config_addr; /* 0x.000 - PCI Express Configuration Address Register */
21 __be32 __iomem pex_config_data; /* 0x.004 - PCI Express Configuration Data Register */
22 u8 __iomem res1[4];
23 __be32 __iomem pex_otb_cpl_tor; /* 0x.00c - PCI Express Outbound completion timeout register */
24 __be32 __iomem pex_conf_tor; /* 0x.010 - PCI Express configuration timeout register */
25 u8 __iomem res2[12];
26 __be32 __iomem pex_pme_mes_dr; /* 0x.020 - PCI Express PME and message detect register */
27 __be32 __iomem pex_pme_mes_disr; /* 0x.024 - PCI Express PME and message disable register */
28 __be32 __iomem pex_pme_mes_ier; /* 0x.028 - PCI Express PME and message interrupt enable register */
29 __be32 __iomem pex_pmcr; /* 0x.02c - PCI Express power management command register */
30 u8 __iomem res3[3024];
31 __be32 __iomem pexotar0; /* 0x.c00 - PCI Express outbound translation address register 0 */
32 __be32 __iomem pexotear0; /* 0x.c04 - PCI Express outbound translation extended address register 0*/
33 u8 __iomem res4[8];
34 __be32 __iomem pexowar0; /* 0x.c10 - PCI Express outbound window attributes register 0*/
35 u8 __iomem res5[12];
36 __be32 __iomem pexotar1; /* 0x.c20 - PCI Express outbound translation address register 1 */
37 __be32 __iomem pexotear1; /* 0x.c24 - PCI Express outbound translation extended address register 1*/
38 __be32 __iomem pexowbar1; /* 0x.c28 - PCI Express outbound window base address register 1*/
39 u8 __iomem res6[4];
40 __be32 __iomem pexowar1; /* 0x.c30 - PCI Express outbound window attributes register 1*/
41 u8 __iomem res7[12];
42 __be32 __iomem pexotar2; /* 0x.c40 - PCI Express outbound translation address register 2 */
43 __be32 __iomem pexotear2; /* 0x.c44 - PCI Express outbound translation extended address register 2*/
44 __be32 __iomem pexowbar2; /* 0x.c48 - PCI Express outbound window base address register 2*/
45 u8 __iomem res8[4];
46 __be32 __iomem pexowar2; /* 0x.c50 - PCI Express outbound window attributes register 2*/
47 u8 __iomem res9[12];
48 __be32 __iomem pexotar3; /* 0x.c60 - PCI Express outbound translation address register 3 */
49 __be32 __iomem pexotear3; /* 0x.c64 - PCI Express outbound translation extended address register 3*/
50 __be32 __iomem pexowbar3; /* 0x.c68 - PCI Express outbound window base address register 3*/
51 u8 __iomem res10[4];
52 __be32 __iomem pexowar3; /* 0x.c70 - PCI Express outbound window attributes register 3*/
53 u8 __iomem res11[12];
54 __be32 __iomem pexotar4; /* 0x.c80 - PCI Express outbound translation address register 4 */
55 __be32 __iomem pexotear4; /* 0x.c84 - PCI Express outbound translation extended address register 4*/
56 __be32 __iomem pexowbar4; /* 0x.c88 - PCI Express outbound window base address register 4*/
57 u8 __iomem res12[4];
58 __be32 __iomem pexowar4; /* 0x.c90 - PCI Express outbound window attributes register 4*/
59 u8 __iomem res13[12];
60 u8 __iomem res14[256];
61 __be32 __iomem pexitar3; /* 0x.da0 - PCI Express inbound translation address register 3 */
62 u8 __iomem res15[4];
63 __be32 __iomem pexiwbar3; /* 0x.da8 - PCI Express inbound window base address register 3 */
64 __be32 __iomem pexiwbear3; /* 0x.dac - PCI Express inbound window base extended address register 3 */
65 __be32 __iomem pexiwar3; /* 0x.db0 - PCI Express inbound window attributes register 3 */
66 u8 __iomem res16[12];
67 __be32 __iomem pexitar2; /* 0x.dc0 - PCI Express inbound translation address register 2 */
68 u8 __iomem res17[4];
69 __be32 __iomem pexiwbar2; /* 0x.dc8 - PCI Express inbound window base address register 2 */
70 __be32 __iomem pexiwbear2; /* 0x.dcc - PCI Express inbound window base extended address register 2 */
71 __be32 __iomem pexiwar2; /* 0x.dd0 - PCI Express inbound window attributes register 2 */
72 u8 __iomem res18[12];
73 __be32 __iomem pexitar1; /* 0x.de0 - PCI Express inbound translation address register 2 */
74 u8 __iomem res19[4];
75 __be32 __iomem pexiwbar1; /* 0x.de8 - PCI Express inbound window base address register 2 */
76 __be32 __iomem pexiwbear1; /* 0x.dec - PCI Express inbound window base extended address register 2 */
77 __be32 __iomem pexiwar1; /* 0x.df0 - PCI Express inbound window attributes register 2 */
78 u8 __iomem res20[12];
79 __be32 __iomem pex_err_dr; /* 0x.e00 - PCI Express error detect register */
80 u8 __iomem res21[4];
81 __be32 __iomem pex_err_en; /* 0x.e08 - PCI Express error interrupt enable register */
82 u8 __iomem res22[4];
83 __be32 __iomem pex_err_disr; /* 0x.e10 - PCI Express error disable register */
84 u8 __iomem res23[12];
85 __be32 __iomem pex_err_cap_stat; /* 0x.e20 - PCI Express error capture status register */
86 u8 __iomem res24[4];
87 __be32 __iomem pex_err_cap_r0; /* 0x.e28 - PCI Express error capture register 0 */
88 __be32 __iomem pex_err_cap_r1; /* 0x.e2c - PCI Express error capture register 0 */
89 __be32 __iomem pex_err_cap_r2; /* 0x.e30 - PCI Express error capture register 0 */
90 __be32 __iomem pex_err_cap_r3; /* 0x.e34 - PCI Express error capture register 0 */
91};
92
93#endif /* __POWERPC_FSL_PCIE_H */
94#endif /* __KERNEL__ */
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index d20f02927f72..8a123c71449f 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -52,7 +52,7 @@ phys_addr_t get_immrbase(void)
52 soc = of_find_node_by_type(NULL, "soc"); 52 soc = of_find_node_by_type(NULL, "soc");
53 if (soc) { 53 if (soc) {
54 unsigned int size; 54 unsigned int size;
55 const void *prop = get_property(soc, "reg", &size); 55 const void *prop = of_get_property(soc, "reg", &size);
56 56
57 if (prop) 57 if (prop)
58 immrbase = of_translate_address(soc, prop); 58 immrbase = of_translate_address(soc, prop);
@@ -78,8 +78,8 @@ u32 get_brgfreq(void)
78 node = of_find_node_by_type(NULL, "cpm"); 78 node = of_find_node_by_type(NULL, "cpm");
79 if (node) { 79 if (node) {
80 unsigned int size; 80 unsigned int size;
81 const unsigned int *prop = get_property(node, "brg-frequency", 81 const unsigned int *prop = of_get_property(node,
82 &size); 82 "brg-frequency", &size);
83 83
84 if (prop) 84 if (prop)
85 brgfreq = *prop; 85 brgfreq = *prop;
@@ -103,8 +103,8 @@ u32 get_baudrate(void)
103 node = of_find_node_by_type(NULL, "serial"); 103 node = of_find_node_by_type(NULL, "serial");
104 if (node) { 104 if (node) {
105 unsigned int size; 105 unsigned int size;
106 const unsigned int *prop = get_property(node, "current-speed", 106 const unsigned int *prop = of_get_property(node,
107 &size); 107 "current-speed", &size);
108 108
109 if (prop) 109 if (prop)
110 fs_baudrate = *prop; 110 fs_baudrate = *prop;
@@ -153,7 +153,8 @@ static int __init gfar_mdio_of_init(void)
153 while ((child = of_get_next_child(np, child)) != NULL) { 153 while ((child = of_get_next_child(np, child)) != NULL) {
154 int irq = irq_of_parse_and_map(child, 0); 154 int irq = irq_of_parse_and_map(child, 0);
155 if (irq != NO_IRQ) { 155 if (irq != NO_IRQ) {
156 const u32 *id = get_property(child, "reg", NULL); 156 const u32 *id = of_get_property(child,
157 "reg", NULL);
157 mdio_data.irq[*id] = irq; 158 mdio_data.irq[*id] = irq;
158 } 159 }
159 } 160 }
@@ -209,7 +210,7 @@ static int __init gfar_of_init(void)
209 210
210 of_irq_to_resource(np, 0, &r[1]); 211 of_irq_to_resource(np, 0, &r[1]);
211 212
212 model = get_property(np, "model", NULL); 213 model = of_get_property(np, "model", NULL);
213 214
214 /* If we aren't the FEC we have multiple interrupts */ 215 /* If we aren't the FEC we have multiple interrupts */
215 if (model && strcasecmp(model, "FEC")) { 216 if (model && strcasecmp(model, "FEC")) {
@@ -253,7 +254,7 @@ static int __init gfar_of_init(void)
253 FSL_GIANFAR_DEV_HAS_VLAN | 254 FSL_GIANFAR_DEV_HAS_VLAN |
254 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH; 255 FSL_GIANFAR_DEV_HAS_EXTENDED_HASH;
255 256
256 ph = get_property(np, "phy-handle", NULL); 257 ph = of_get_property(np, "phy-handle", NULL);
257 phy = of_find_node_by_phandle(*ph); 258 phy = of_find_node_by_phandle(*ph);
258 259
259 if (phy == NULL) { 260 if (phy == NULL) {
@@ -263,7 +264,7 @@ static int __init gfar_of_init(void)
263 264
264 mdio = of_get_parent(phy); 265 mdio = of_get_parent(phy);
265 266
266 id = get_property(phy, "reg", NULL); 267 id = of_get_property(phy, "reg", NULL);
267 ret = of_address_to_resource(mdio, 0, &res); 268 ret = of_address_to_resource(mdio, 0, &res);
268 if (ret) { 269 if (ret) {
269 of_node_put(phy); 270 of_node_put(phy);
@@ -325,11 +326,11 @@ static int __init fsl_i2c_of_init(void)
325 } 326 }
326 327
327 i2c_data.device_flags = 0; 328 i2c_data.device_flags = 0;
328 flags = get_property(np, "dfsrr", NULL); 329 flags = of_get_property(np, "dfsrr", NULL);
329 if (flags) 330 if (flags)
330 i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR; 331 i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
331 332
332 flags = get_property(np, "fsl5200-clocking", NULL); 333 flags = of_get_property(np, "fsl5200-clocking", NULL);
333 if (flags) 334 if (flags)
334 i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200; 335 i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
335 336
@@ -374,7 +375,7 @@ static int __init mpc83xx_wdt_init(void)
374 goto nosoc; 375 goto nosoc;
375 } 376 }
376 377
377 freq = get_property(soc, "bus-frequency", NULL); 378 freq = of_get_property(soc, "bus-frequency", NULL);
378 if (!freq) { 379 if (!freq) {
379 ret = -ENODEV; 380 ret = -ENODEV;
380 goto err; 381 goto err;
@@ -466,15 +467,15 @@ static int __init fsl_usb_of_init(void)
466 467
467 usb_data.operating_mode = FSL_USB2_MPH_HOST; 468 usb_data.operating_mode = FSL_USB2_MPH_HOST;
468 469
469 prop = get_property(np, "port0", NULL); 470 prop = of_get_property(np, "port0", NULL);
470 if (prop) 471 if (prop)
471 usb_data.port_enables |= FSL_USB2_PORT0_ENABLED; 472 usb_data.port_enables |= FSL_USB2_PORT0_ENABLED;
472 473
473 prop = get_property(np, "port1", NULL); 474 prop = of_get_property(np, "port1", NULL);
474 if (prop) 475 if (prop)
475 usb_data.port_enables |= FSL_USB2_PORT1_ENABLED; 476 usb_data.port_enables |= FSL_USB2_PORT1_ENABLED;
476 477
477 prop = get_property(np, "phy_type", NULL); 478 prop = of_get_property(np, "phy_type", NULL);
478 usb_data.phy_mode = determine_usb_phy(prop); 479 usb_data.phy_mode = determine_usb_phy(prop);
479 480
480 ret = 481 ret =
@@ -501,7 +502,7 @@ static int __init fsl_usb_of_init(void)
501 502
502 of_irq_to_resource(np, 0, &r[1]); 503 of_irq_to_resource(np, 0, &r[1]);
503 504
504 prop = get_property(np, "dr_mode", NULL); 505 prop = of_get_property(np, "dr_mode", NULL);
505 506
506 if (!prop || !strcmp(prop, "host")) { 507 if (!prop || !strcmp(prop, "host")) {
507 usb_data.operating_mode = FSL_USB2_DR_HOST; 508 usb_data.operating_mode = FSL_USB2_DR_HOST;
@@ -538,7 +539,7 @@ static int __init fsl_usb_of_init(void)
538 goto err; 539 goto err;
539 } 540 }
540 541
541 prop = get_property(np, "phy_type", NULL); 542 prop = of_get_property(np, "phy_type", NULL);
542 usb_data.phy_mode = determine_usb_phy(prop); 543 usb_data.phy_mode = determine_usb_phy(prop);
543 544
544 if (usb_dev_dr_host) { 545 if (usb_dev_dr_host) {
@@ -633,7 +634,7 @@ static int __init fs_enet_of_init(void)
633 goto err; 634 goto err;
634 } 635 }
635 636
636 model = get_property(np, "model", NULL); 637 model = of_get_property(np, "model", NULL);
637 if (model == NULL) { 638 if (model == NULL) {
638 ret = -ENODEV; 639 ret = -ENODEV;
639 goto unreg; 640 goto unreg;
@@ -643,7 +644,7 @@ static int __init fs_enet_of_init(void)
643 if (mac_addr) 644 if (mac_addr)
644 memcpy(fs_enet_data.macaddr, mac_addr, 6); 645 memcpy(fs_enet_data.macaddr, mac_addr, 6);
645 646
646 ph = get_property(np, "phy-handle", NULL); 647 ph = of_get_property(np, "phy-handle", NULL);
647 phy = of_find_node_by_phandle(*ph); 648 phy = of_find_node_by_phandle(*ph);
648 649
649 if (phy == NULL) { 650 if (phy == NULL) {
@@ -651,12 +652,12 @@ static int __init fs_enet_of_init(void)
651 goto unreg; 652 goto unreg;
652 } 653 }
653 654
654 phy_addr = get_property(phy, "reg", NULL); 655 phy_addr = of_get_property(phy, "reg", NULL);
655 fs_enet_data.phy_addr = *phy_addr; 656 fs_enet_data.phy_addr = *phy_addr;
656 657
657 phy_irq = get_property(phy, "interrupts", NULL); 658 phy_irq = of_get_property(phy, "interrupts", NULL);
658 659
659 id = get_property(np, "device-id", NULL); 660 id = of_get_property(np, "device-id", NULL);
660 fs_enet_data.fs_no = *id; 661 fs_enet_data.fs_no = *id;
661 strcpy(fs_enet_data.fs_type, model); 662 strcpy(fs_enet_data.fs_type, model);
662 663
@@ -668,8 +669,10 @@ static int __init fs_enet_of_init(void)
668 goto unreg; 669 goto unreg;
669 } 670 }
670 671
671 fs_enet_data.clk_rx = *((u32 *) get_property(np, "rx-clock", NULL)); 672 fs_enet_data.clk_rx = *((u32 *)of_get_property(np,
672 fs_enet_data.clk_tx = *((u32 *) get_property(np, "tx-clock", NULL)); 673 "rx-clock", NULL));
674 fs_enet_data.clk_tx = *((u32 *)of_get_property(np,
675 "tx-clock", NULL));
673 676
674 if (strstr(model, "FCC")) { 677 if (strstr(model, "FCC")) {
675 int fcc_index = *id - 1; 678 int fcc_index = *id - 1;
@@ -690,7 +693,7 @@ static int __init fs_enet_of_init(void)
690 fs_enet_data.bus_id = (char*)&bus_id[(*id)]; 693 fs_enet_data.bus_id = (char*)&bus_id[(*id)];
691 fs_enet_data.init_ioports = init_fcc_ioports; 694 fs_enet_data.init_ioports = init_fcc_ioports;
692 695
693 mdio_bb_prop = get_property(phy, "bitbang", NULL); 696 mdio_bb_prop = of_get_property(phy, "bitbang", NULL);
694 if (mdio_bb_prop) { 697 if (mdio_bb_prop) {
695 struct platform_device *fs_enet_mdio_bb_dev; 698 struct platform_device *fs_enet_mdio_bb_dev;
696 struct fs_mii_bb_platform_info fs_enet_mdio_bb_data; 699 struct fs_mii_bb_platform_info fs_enet_mdio_bb_data;
@@ -796,10 +799,10 @@ static int __init cpm_uart_of_init(void)
796 goto err; 799 goto err;
797 } 800 }
798 801
799 id = get_property(np, "device-id", NULL); 802 id = of_get_property(np, "device-id", NULL);
800 cpm_uart_data.fs_no = *id; 803 cpm_uart_data.fs_no = *id;
801 804
802 model = (char*)get_property(np, "model", NULL); 805 model = of_get_property(np, "model", NULL);
803 strcpy(cpm_uart_data.fs_type, model); 806 strcpy(cpm_uart_data.fs_type, model);
804 807
805 cpm_uart_data.uart_clk = ppc_proc_freq; 808 cpm_uart_data.uart_clk = ppc_proc_freq;
@@ -808,8 +811,10 @@ static int __init cpm_uart_of_init(void)
808 cpm_uart_data.tx_buf_size = 32; 811 cpm_uart_data.tx_buf_size = 32;
809 cpm_uart_data.rx_num_fifo = 4; 812 cpm_uart_data.rx_num_fifo = 4;
810 cpm_uart_data.rx_buf_size = 32; 813 cpm_uart_data.rx_buf_size = 32;
811 cpm_uart_data.clk_rx = *((u32 *) get_property(np, "rx-clock", NULL)); 814 cpm_uart_data.clk_rx = *((u32 *)of_get_property(np,
812 cpm_uart_data.clk_tx = *((u32 *) get_property(np, "tx-clock", NULL)); 815 "rx-clock", NULL));
816 cpm_uart_data.clk_tx = *((u32 *)of_get_property(np,
817 "tx-clock", NULL));
813 818
814 ret = 819 ret =
815 platform_device_add_data(cpm_uart_dev, &cpm_uart_data, 820 platform_device_add_data(cpm_uart_dev, &cpm_uart_data,
@@ -833,7 +838,7 @@ arch_initcall(cpm_uart_of_init);
833#ifdef CONFIG_8xx 838#ifdef CONFIG_8xx
834 839
835extern void init_scc_ioports(struct fs_platform_info*); 840extern void init_scc_ioports(struct fs_platform_info*);
836extern int platform_device_skip(char *model, int id); 841extern int platform_device_skip(const char *model, int id);
837 842
838static int __init fs_enet_mdio_of_init(void) 843static int __init fs_enet_mdio_of_init(void)
839{ 844{
@@ -900,21 +905,22 @@ static int __init fs_enet_of_init(void)
900 struct resource r[4]; 905 struct resource r[4];
901 struct device_node *phy = NULL, *mdio = NULL; 906 struct device_node *phy = NULL, *mdio = NULL;
902 struct fs_platform_info fs_enet_data; 907 struct fs_platform_info fs_enet_data;
903 unsigned int *id, *phy_addr; 908 const unsigned int *id;
909 const unsigned int *phy_addr;
904 void *mac_addr; 910 void *mac_addr;
905 phandle *ph; 911 const phandle *ph;
906 char *model; 912 const char *model;
907 913
908 memset(r, 0, sizeof(r)); 914 memset(r, 0, sizeof(r));
909 memset(&fs_enet_data, 0, sizeof(fs_enet_data)); 915 memset(&fs_enet_data, 0, sizeof(fs_enet_data));
910 916
911 model = (char *)get_property(np, "model", NULL); 917 model = of_get_property(np, "model", NULL);
912 if (model == NULL) { 918 if (model == NULL) {
913 ret = -ENODEV; 919 ret = -ENODEV;
914 goto unreg; 920 goto unreg;
915 } 921 }
916 922
917 id = (u32 *) get_property(np, "device-id", NULL); 923 id = of_get_property(np, "device-id", NULL);
918 fs_enet_data.fs_no = *id; 924 fs_enet_data.fs_no = *id;
919 925
920 if (platform_device_skip(model, *id)) 926 if (platform_device_skip(model, *id))
@@ -929,12 +935,12 @@ static int __init fs_enet_of_init(void)
929 if (mac_addr) 935 if (mac_addr)
930 memcpy(fs_enet_data.macaddr, mac_addr, 6); 936 memcpy(fs_enet_data.macaddr, mac_addr, 6);
931 937
932 ph = (phandle *) get_property(np, "phy-handle", NULL); 938 ph = of_get_property(np, "phy-handle", NULL);
933 if (ph != NULL) 939 if (ph != NULL)
934 phy = of_find_node_by_phandle(*ph); 940 phy = of_find_node_by_phandle(*ph);
935 941
936 if (phy != NULL) { 942 if (phy != NULL) {
937 phy_addr = (u32 *) get_property(phy, "reg", NULL); 943 phy_addr = of_get_property(phy, "reg", NULL);
938 fs_enet_data.phy_addr = *phy_addr; 944 fs_enet_data.phy_addr = *phy_addr;
939 fs_enet_data.has_phy = 1; 945 fs_enet_data.has_phy = 1;
940 946
@@ -947,7 +953,7 @@ static int __init fs_enet_of_init(void)
947 } 953 }
948 } 954 }
949 955
950 model = (char*)get_property(np, "model", NULL); 956 model = of_get_property(np, "model", NULL);
951 strcpy(fs_enet_data.fs_type, model); 957 strcpy(fs_enet_data.fs_type, model);
952 958
953 if (strstr(model, "FEC")) { 959 if (strstr(model, "FEC")) {
@@ -1038,8 +1044,8 @@ static int __init cpm_smc_uart_of_init(void)
1038 i++) { 1044 i++) {
1039 struct resource r[3]; 1045 struct resource r[3];
1040 struct fs_uart_platform_info cpm_uart_data; 1046 struct fs_uart_platform_info cpm_uart_data;
1041 int *id; 1047 const int *id;
1042 char *model; 1048 const char *model;
1043 1049
1044 memset(r, 0, sizeof(r)); 1050 memset(r, 0, sizeof(r));
1045 memset(&cpm_uart_data, 0, sizeof(cpm_uart_data)); 1051 memset(&cpm_uart_data, 0, sizeof(cpm_uart_data));
@@ -1066,10 +1072,10 @@ static int __init cpm_smc_uart_of_init(void)
1066 goto err; 1072 goto err;
1067 } 1073 }
1068 1074
1069 model = (char*)get_property(np, "model", NULL); 1075 model = of_get_property(np, "model", NULL);
1070 strcpy(cpm_uart_data.fs_type, model); 1076 strcpy(cpm_uart_data.fs_type, model);
1071 1077
1072 id = (int*)get_property(np, "device-id", NULL); 1078 id = of_get_property(np, "device-id", NULL);
1073 cpm_uart_data.fs_no = *id; 1079 cpm_uart_data.fs_no = *id;
1074 cpm_uart_data.uart_clk = ppc_proc_freq; 1080 cpm_uart_data.uart_clk = ppc_proc_freq;
1075 1081
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index bcfb900481f8..0b84b7c775d8 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -304,7 +304,7 @@ static void __init mpic_test_broken_ipi(struct mpic *mpic)
304 } 304 }
305} 305}
306 306
307#ifdef CONFIG_MPIC_BROKEN_U3 307#ifdef CONFIG_MPIC_U3_HT_IRQS
308 308
309/* Test if an interrupt is sourced from HyperTransport (used on broken U3s) 309/* Test if an interrupt is sourced from HyperTransport (used on broken U3s)
310 * to force the edge setting on the MPIC and do the ack workaround. 310 * to force the edge setting on the MPIC and do the ack workaround.
@@ -476,7 +476,7 @@ static void __init mpic_scan_ht_pics(struct mpic *mpic)
476 } 476 }
477} 477}
478 478
479#else /* CONFIG_MPIC_BROKEN_U3 */ 479#else /* CONFIG_MPIC_U3_HT_IRQS */
480 480
481static inline int mpic_is_ht_interrupt(struct mpic *mpic, unsigned int source) 481static inline int mpic_is_ht_interrupt(struct mpic *mpic, unsigned int source)
482{ 482{
@@ -487,7 +487,7 @@ static void __init mpic_scan_ht_pics(struct mpic *mpic)
487{ 487{
488} 488}
489 489
490#endif /* CONFIG_MPIC_BROKEN_U3 */ 490#endif /* CONFIG_MPIC_U3_HT_IRQS */
491 491
492 492
493#define mpic_irq_to_hw(virq) ((unsigned int)irq_map[virq].hwirq) 493#define mpic_irq_to_hw(virq) ((unsigned int)irq_map[virq].hwirq)
@@ -615,7 +615,7 @@ static void mpic_end_irq(unsigned int irq)
615 mpic_eoi(mpic); 615 mpic_eoi(mpic);
616} 616}
617 617
618#ifdef CONFIG_MPIC_BROKEN_U3 618#ifdef CONFIG_MPIC_U3_HT_IRQS
619 619
620static void mpic_unmask_ht_irq(unsigned int irq) 620static void mpic_unmask_ht_irq(unsigned int irq)
621{ 621{
@@ -665,7 +665,7 @@ static void mpic_end_ht_irq(unsigned int irq)
665 mpic_ht_end_irq(mpic, src); 665 mpic_ht_end_irq(mpic, src);
666 mpic_eoi(mpic); 666 mpic_eoi(mpic);
667} 667}
668#endif /* !CONFIG_MPIC_BROKEN_U3 */ 668#endif /* !CONFIG_MPIC_U3_HT_IRQS */
669 669
670#ifdef CONFIG_SMP 670#ifdef CONFIG_SMP
671 671
@@ -788,7 +788,7 @@ static struct irq_chip mpic_ipi_chip = {
788}; 788};
789#endif /* CONFIG_SMP */ 789#endif /* CONFIG_SMP */
790 790
791#ifdef CONFIG_MPIC_BROKEN_U3 791#ifdef CONFIG_MPIC_U3_HT_IRQS
792static struct irq_chip mpic_irq_ht_chip = { 792static struct irq_chip mpic_irq_ht_chip = {
793 .startup = mpic_startup_ht_irq, 793 .startup = mpic_startup_ht_irq,
794 .shutdown = mpic_shutdown_ht_irq, 794 .shutdown = mpic_shutdown_ht_irq,
@@ -797,7 +797,7 @@ static struct irq_chip mpic_irq_ht_chip = {
797 .eoi = mpic_end_ht_irq, 797 .eoi = mpic_end_ht_irq,
798 .set_type = mpic_set_irq_type, 798 .set_type = mpic_set_irq_type,
799}; 799};
800#endif /* CONFIG_MPIC_BROKEN_U3 */ 800#endif /* CONFIG_MPIC_U3_HT_IRQS */
801 801
802 802
803static int mpic_host_match(struct irq_host *h, struct device_node *node) 803static int mpic_host_match(struct irq_host *h, struct device_node *node)
@@ -837,11 +837,11 @@ static int mpic_host_map(struct irq_host *h, unsigned int virq,
837 /* Default chip */ 837 /* Default chip */
838 chip = &mpic->hc_irq; 838 chip = &mpic->hc_irq;
839 839
840#ifdef CONFIG_MPIC_BROKEN_U3 840#ifdef CONFIG_MPIC_U3_HT_IRQS
841 /* Check for HT interrupts, override vecpri */ 841 /* Check for HT interrupts, override vecpri */
842 if (mpic_is_ht_interrupt(mpic, hw)) 842 if (mpic_is_ht_interrupt(mpic, hw))
843 chip = &mpic->hc_ht_irq; 843 chip = &mpic->hc_ht_irq;
844#endif /* CONFIG_MPIC_BROKEN_U3 */ 844#endif /* CONFIG_MPIC_U3_HT_IRQS */
845 845
846 DBG("mpic: mapping to irq chip @%p\n", chip); 846 DBG("mpic: mapping to irq chip @%p\n", chip);
847 847
@@ -937,12 +937,12 @@ struct mpic * __init mpic_alloc(struct device_node *node,
937 mpic->hc_irq.typename = name; 937 mpic->hc_irq.typename = name;
938 if (flags & MPIC_PRIMARY) 938 if (flags & MPIC_PRIMARY)
939 mpic->hc_irq.set_affinity = mpic_set_affinity; 939 mpic->hc_irq.set_affinity = mpic_set_affinity;
940#ifdef CONFIG_MPIC_BROKEN_U3 940#ifdef CONFIG_MPIC_U3_HT_IRQS
941 mpic->hc_ht_irq = mpic_irq_ht_chip; 941 mpic->hc_ht_irq = mpic_irq_ht_chip;
942 mpic->hc_ht_irq.typename = name; 942 mpic->hc_ht_irq.typename = name;
943 if (flags & MPIC_PRIMARY) 943 if (flags & MPIC_PRIMARY)
944 mpic->hc_ht_irq.set_affinity = mpic_set_affinity; 944 mpic->hc_ht_irq.set_affinity = mpic_set_affinity;
945#endif /* CONFIG_MPIC_BROKEN_U3 */ 945#endif /* CONFIG_MPIC_U3_HT_IRQS */
946 946
947#ifdef CONFIG_SMP 947#ifdef CONFIG_SMP
948 mpic->hc_ipi = mpic_ipi_chip; 948 mpic->hc_ipi = mpic_ipi_chip;
@@ -970,7 +970,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
970 mpic->spurious_vec = intvec_top; 970 mpic->spurious_vec = intvec_top;
971 971
972 /* Check for "big-endian" in device-tree */ 972 /* Check for "big-endian" in device-tree */
973 if (node && get_property(node, "big-endian", NULL) != NULL) 973 if (node && of_get_property(node, "big-endian", NULL) != NULL)
974 mpic->flags |= MPIC_BIG_ENDIAN; 974 mpic->flags |= MPIC_BIG_ENDIAN;
975 975
976 976
@@ -986,13 +986,13 @@ struct mpic * __init mpic_alloc(struct device_node *node,
986 BUG_ON(paddr == 0 && node == NULL); 986 BUG_ON(paddr == 0 && node == NULL);
987 987
988 /* If no physical address passed in, check if it's dcr based */ 988 /* If no physical address passed in, check if it's dcr based */
989 if (paddr == 0 && get_property(node, "dcr-reg", NULL) != NULL) 989 if (paddr == 0 && of_get_property(node, "dcr-reg", NULL) != NULL)
990 mpic->flags |= MPIC_USES_DCR; 990 mpic->flags |= MPIC_USES_DCR;
991 991
992#ifdef CONFIG_PPC_DCR 992#ifdef CONFIG_PPC_DCR
993 if (mpic->flags & MPIC_USES_DCR) { 993 if (mpic->flags & MPIC_USES_DCR) {
994 const u32 *dbasep; 994 const u32 *dbasep;
995 dbasep = get_property(node, "dcr-reg", NULL); 995 dbasep = of_get_property(node, "dcr-reg", NULL);
996 BUG_ON(dbasep == NULL); 996 BUG_ON(dbasep == NULL);
997 mpic->dcr_base = *dbasep; 997 mpic->dcr_base = *dbasep;
998 mpic->reg_type = mpic_access_dcr; 998 mpic->reg_type = mpic_access_dcr;
@@ -1006,7 +1006,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1006 */ 1006 */
1007 if (paddr == 0 && !(mpic->flags & MPIC_USES_DCR)) { 1007 if (paddr == 0 && !(mpic->flags & MPIC_USES_DCR)) {
1008 const u32 *reg; 1008 const u32 *reg;
1009 reg = get_property(node, "reg", NULL); 1009 reg = of_get_property(node, "reg", NULL);
1010 BUG_ON(reg == NULL); 1010 BUG_ON(reg == NULL);
1011 paddr = of_translate_address(node, reg); 1011 paddr = of_translate_address(node, reg);
1012 BUG_ON(paddr == OF_BAD_ADDR); 1012 BUG_ON(paddr == OF_BAD_ADDR);
@@ -1142,7 +1142,7 @@ void __init mpic_init(struct mpic *mpic)
1142 1142
1143 /* Do the HT PIC fixups on U3 broken mpic */ 1143 /* Do the HT PIC fixups on U3 broken mpic */
1144 DBG("MPIC flags: %x\n", mpic->flags); 1144 DBG("MPIC flags: %x\n", mpic->flags);
1145 if ((mpic->flags & MPIC_BROKEN_U3) && (mpic->flags & MPIC_PRIMARY)) 1145 if ((mpic->flags & MPIC_U3_HT_IRQS) && (mpic->flags & MPIC_PRIMARY))
1146 mpic_scan_ht_pics(mpic); 1146 mpic_scan_ht_pics(mpic);
1147 1147
1148 for (i = 0; i < mpic->num_sources; i++) { 1148 for (i = 0; i < mpic->num_sources; i++) {
diff --git a/arch/powerpc/sysdev/pmi.c b/arch/powerpc/sysdev/pmi.c
index a5282011d39e..85a7c99c1003 100644
--- a/arch/powerpc/sysdev/pmi.c
+++ b/arch/powerpc/sysdev/pmi.c
@@ -33,7 +33,7 @@
33#include <asm/of_platform.h> 33#include <asm/of_platform.h>
34#include <asm/io.h> 34#include <asm/io.h>
35#include <asm/pmi.h> 35#include <asm/pmi.h>
36 36#include <asm/prom.h>
37 37
38struct pmi_data { 38struct pmi_data {
39 struct list_head handler; 39 struct list_head handler;
@@ -49,21 +49,6 @@ struct pmi_data {
49}; 49};
50 50
51 51
52
53static void __iomem *of_iomap(struct device_node *np)
54{
55 struct resource res;
56
57 if (of_address_to_resource(np, 0, &res))
58 return NULL;
59
60 pr_debug("Resource start: 0x%lx\n", res.start);
61 pr_debug("Resource end: 0x%lx\n", res.end);
62
63 return ioremap(res.start, 1 + res.end - res.start);
64}
65
66
67static int pmi_irq_handler(int irq, void *dev_id) 52static int pmi_irq_handler(int irq, void *dev_id)
68{ 53{
69 struct pmi_data *data; 54 struct pmi_data *data;
@@ -118,6 +103,7 @@ out:
118 103
119static struct of_device_id pmi_match[] = { 104static struct of_device_id pmi_match[] = {
120 { .type = "ibm,pmi", .name = "ibm,pmi" }, 105 { .type = "ibm,pmi", .name = "ibm,pmi" },
106 { .type = "ibm,pmi" },
121 {}, 107 {},
122}; 108};
123 109
@@ -153,7 +139,7 @@ static int pmi_of_probe(struct of_device *dev,
153 goto out; 139 goto out;
154 } 140 }
155 141
156 data->pmi_reg = of_iomap(np); 142 data->pmi_reg = of_iomap(np, 0);
157 if (!data->pmi_reg) { 143 if (!data->pmi_reg) {
158 printk(KERN_ERR "pmi: invalid register address.\n"); 144 printk(KERN_ERR "pmi: invalid register address.\n");
159 rc = -EFAULT; 145 rc = -EFAULT;
@@ -279,6 +265,9 @@ void pmi_register_handler(struct of_device *device,
279 struct pmi_data *data; 265 struct pmi_data *data;
280 data = device->dev.driver_data; 266 data = device->dev.driver_data;
281 267
268 if (!data)
269 return;
270
282 spin_lock(&data->handler_spinlock); 271 spin_lock(&data->handler_spinlock);
283 list_add_tail(&handler->node, &data->handler); 272 list_add_tail(&handler->node, &data->handler);
284 spin_unlock(&data->handler_spinlock); 273 spin_unlock(&data->handler_spinlock);
@@ -289,10 +278,12 @@ void pmi_unregister_handler(struct of_device *device,
289 struct pmi_handler *handler) 278 struct pmi_handler *handler)
290{ 279{
291 struct pmi_data *data; 280 struct pmi_data *data;
281 data = device->dev.driver_data;
292 282
293 pr_debug("pmi: unregistering handler %p\n", handler); 283 if (!data)
284 return;
294 285
295 data = device->dev.driver_data; 286 pr_debug("pmi: unregistering handler %p\n", handler);
296 287
297 spin_lock(&data->handler_spinlock); 288 spin_lock(&data->handler_spinlock);
298 list_del(&handler->node); 289 list_del(&handler->node);
diff --git a/arch/powerpc/sysdev/qe_lib/Kconfig b/arch/powerpc/sysdev/qe_lib/Kconfig
index a725e80befa8..887739f3badc 100644
--- a/arch/powerpc/sysdev/qe_lib/Kconfig
+++ b/arch/powerpc/sysdev/qe_lib/Kconfig
@@ -2,11 +2,8 @@
2# QE Communication options 2# QE Communication options
3# 3#
4 4
5menu "QE Options"
6 depends on QUICC_ENGINE
7
8config UCC_SLOW 5config UCC_SLOW
9 bool "UCC Slow Protocols Support" 6 bool
10 default n 7 default n
11 select UCC 8 select UCC
12 help 9 help
@@ -14,10 +11,9 @@ config UCC_SLOW
14 protocols: UART, BISYNC, QMC 11 protocols: UART, BISYNC, QMC
15 12
16config UCC_FAST 13config UCC_FAST
17 bool "UCC Fast Protocols Support" 14 bool
18 default n 15 default n
19 select UCC 16 select UCC
20 select UCC_SLOW
21 help 17 help
22 This option provides qe_lib support to UCC fast 18 This option provides qe_lib support to UCC fast
23 protocols: HDLC, Ethernet, ATM, transparent 19 protocols: HDLC, Ethernet, ATM, transparent
@@ -26,5 +22,3 @@ config UCC
26 bool 22 bool
27 default y if UCC_FAST || UCC_SLOW 23 default y if UCC_FAST || UCC_SLOW
28 24
29endmenu
30
diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c
index 43f6cc9d7ea0..7f4c07543961 100644
--- a/arch/powerpc/sysdev/qe_lib/qe.c
+++ b/arch/powerpc/sysdev/qe_lib/qe.c
@@ -71,7 +71,7 @@ phys_addr_t get_qe_base(void)
71 qe = of_find_node_by_type(NULL, "qe"); 71 qe = of_find_node_by_type(NULL, "qe");
72 if (qe) { 72 if (qe) {
73 unsigned int size; 73 unsigned int size;
74 const void *prop = get_property(qe, "reg", &size); 74 const void *prop = of_get_property(qe, "reg", &size);
75 qebase = of_translate_address(qe, prop); 75 qebase = of_translate_address(qe, prop);
76 of_node_put(qe); 76 of_node_put(qe);
77 }; 77 };
@@ -158,7 +158,7 @@ unsigned int get_brg_clk(void)
158 qe = of_find_node_by_type(NULL, "qe"); 158 qe = of_find_node_by_type(NULL, "qe");
159 if (qe) { 159 if (qe) {
160 unsigned int size; 160 unsigned int size;
161 const u32 *prop = get_property(qe, "brg-frequency", &size); 161 const u32 *prop = of_get_property(qe, "brg-frequency", &size);
162 brg_clk = *prop; 162 brg_clk = *prop;
163 of_node_put(qe); 163 of_node_put(qe);
164 }; 164 };
diff --git a/arch/powerpc/sysdev/qe_lib/qe_io.c b/arch/powerpc/sysdev/qe_lib/qe_io.c
index 0afe6bfe3714..e32b45bf9ff5 100644
--- a/arch/powerpc/sysdev/qe_lib/qe_io.c
+++ b/arch/powerpc/sysdev/qe_lib/qe_io.c
@@ -53,7 +53,7 @@ int par_io_init(struct device_node *np)
53 return ret; 53 return ret;
54 par_io = ioremap(res.start, res.end - res.start + 1); 54 par_io = ioremap(res.start, res.end - res.start + 1);
55 55
56 num_ports = get_property(np, "num-ports", NULL); 56 num_ports = of_get_property(np, "num-ports", NULL);
57 if (num_ports) 57 if (num_ports)
58 num_par_io_ports = *num_ports; 58 num_par_io_ports = *num_ports;
59 59
@@ -161,7 +161,7 @@ int par_io_of_config(struct device_node *np)
161 return -1; 161 return -1;
162 } 162 }
163 163
164 ph = get_property(np, "pio-handle", NULL); 164 ph = of_get_property(np, "pio-handle", NULL);
165 if (ph == 0) { 165 if (ph == 0) {
166 printk(KERN_ERR "pio-handle not available \n"); 166 printk(KERN_ERR "pio-handle not available \n");
167 return -1; 167 return -1;
@@ -169,7 +169,7 @@ int par_io_of_config(struct device_node *np)
169 169
170 pio = of_find_node_by_phandle(*ph); 170 pio = of_find_node_by_phandle(*ph);
171 171
172 pio_map = get_property(pio, "pio-map", &pio_map_len); 172 pio_map = of_get_property(pio, "pio-map", &pio_map_len);
173 if (pio_map == NULL) { 173 if (pio_map == NULL) {
174 printk(KERN_ERR "pio-map is not set! \n"); 174 printk(KERN_ERR "pio-map is not set! \n");
175 return -1; 175 return -1;
diff --git a/arch/powerpc/sysdev/qe_lib/ucc_slow.c b/arch/powerpc/sysdev/qe_lib/ucc_slow.c
index 817df73ecf56..b930d686a4d1 100644
--- a/arch/powerpc/sysdev/qe_lib/ucc_slow.c
+++ b/arch/powerpc/sysdev/qe_lib/ucc_slow.c
@@ -187,7 +187,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
187 uccs->us_pram = qe_muram_addr(uccs->us_pram_offset); 187 uccs->us_pram = qe_muram_addr(uccs->us_pram_offset);
188 188
189 /* Init Guemr register */ 189 /* Init Guemr register */
190 if ((ret = ucc_init_guemr((struct ucc_common *) (us_info->regs)))) { 190 if ((ret = ucc_init_guemr((struct ucc_common *) us_regs))) {
191 printk(KERN_ERR "%s: cannot init GUEMR", __FUNCTION__); 191 printk(KERN_ERR "%s: cannot init GUEMR", __FUNCTION__);
192 ucc_slow_free(uccs); 192 ucc_slow_free(uccs);
193 return ret; 193 return ret;
@@ -195,7 +195,7 @@ int ucc_slow_init(struct ucc_slow_info * us_info, struct ucc_slow_private ** ucc
195 195
196 /* Set UCC to slow type */ 196 /* Set UCC to slow type */
197 if ((ret = ucc_set_type(us_info->ucc_num, 197 if ((ret = ucc_set_type(us_info->ucc_num,
198 (struct ucc_common *) (us_info->regs), 198 (struct ucc_common *) us_regs,
199 UCC_SPEED_TYPE_SLOW))) { 199 UCC_SPEED_TYPE_SLOW))) {
200 printk(KERN_ERR "%s: cannot set UCC type", __FUNCTION__); 200 printk(KERN_ERR "%s: cannot set UCC type", __FUNCTION__);
201 ucc_slow_free(uccs); 201 ucc_slow_free(uccs);
diff --git a/arch/powerpc/sysdev/timer.c b/arch/powerpc/sysdev/timer.c
new file mode 100644
index 000000000000..4a01748b4217
--- /dev/null
+++ b/arch/powerpc/sysdev/timer.c
@@ -0,0 +1,71 @@
1/*
2 * Common code to keep time when machine suspends.
3 *
4 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
5 *
6 * GPLv2
7 */
8
9#include <linux/time.h>
10#include <linux/sysdev.h>
11#include <asm/rtc.h>
12
13static unsigned long suspend_rtc_time;
14
15/*
16 * Reset the time after a sleep.
17 */
18static int timer_resume(struct sys_device *dev)
19{
20 struct timeval tv;
21 struct timespec ts;
22 struct rtc_time cur_rtc_tm;
23 unsigned long cur_rtc_time, diff;
24
25 /* get current RTC time and convert to seconds */
26 get_rtc_time(&cur_rtc_tm);
27 rtc_tm_to_time(&cur_rtc_tm, &cur_rtc_time);
28
29 diff = cur_rtc_time - suspend_rtc_time;
30
31 /* adjust time of day by seconds that elapsed while
32 * we were suspended */
33 do_gettimeofday(&tv);
34 ts.tv_sec = tv.tv_sec + diff;
35 ts.tv_nsec = tv.tv_usec * NSEC_PER_USEC;
36 do_settimeofday(&ts);
37
38 return 0;
39}
40
41static int timer_suspend(struct sys_device *dev, pm_message_t state)
42{
43 struct rtc_time suspend_rtc_tm;
44 WARN_ON(!ppc_md.get_rtc_time);
45
46 get_rtc_time(&suspend_rtc_tm);
47 rtc_tm_to_time(&suspend_rtc_tm, &suspend_rtc_time);
48
49 return 0;
50}
51
52static struct sysdev_class timer_sysclass = {
53 .resume = timer_resume,
54 .suspend = timer_suspend,
55 set_kset_name("timer"),
56};
57
58static struct sys_device device_timer = {
59 .id = 0,
60 .cls = &timer_sysclass,
61};
62
63static int time_init_device(void)
64{
65 int error = sysdev_class_register(&timer_sysclass);
66 if (!error)
67 error = sysdev_register(&device_timer);
68 return error;
69}
70
71device_initcall(time_init_device);
diff --git a/arch/powerpc/sysdev/tsi108_dev.c b/arch/powerpc/sysdev/tsi108_dev.c
index 97f37ef4bbbf..337039ee51e6 100644
--- a/arch/powerpc/sysdev/tsi108_dev.c
+++ b/arch/powerpc/sysdev/tsi108_dev.c
@@ -48,7 +48,7 @@ phys_addr_t get_csrbase(void)
48 tsi = of_find_node_by_type(NULL, "tsi-bridge"); 48 tsi = of_find_node_by_type(NULL, "tsi-bridge");
49 if (tsi) { 49 if (tsi) {
50 unsigned int size; 50 unsigned int size;
51 const void *prop = get_property(tsi, "reg", &size); 51 const void *prop = of_get_property(tsi, "reg", &size);
52 tsi108_csr_base = of_translate_address(tsi, prop); 52 tsi108_csr_base = of_translate_address(tsi, prop);
53 of_node_put(tsi); 53 of_node_put(tsi);
54 }; 54 };
@@ -77,10 +77,10 @@ static int __init tsi108_eth_of_init(void)
77 struct resource r[2]; 77 struct resource r[2];
78 struct device_node *phy; 78 struct device_node *phy;
79 hw_info tsi_eth_data; 79 hw_info tsi_eth_data;
80 unsigned int *id; 80 const unsigned int *id;
81 unsigned int *phy_id; 81 const unsigned int *phy_id;
82 const void *mac_addr; 82 const void *mac_addr;
83 phandle *ph; 83 const phandle *ph;
84 84
85 memset(r, 0, sizeof(r)); 85 memset(r, 0, sizeof(r));
86 memset(&tsi_eth_data, 0, sizeof(tsi_eth_data)); 86 memset(&tsi_eth_data, 0, sizeof(tsi_eth_data));
@@ -107,10 +107,10 @@ static int __init tsi108_eth_of_init(void)
107 goto err; 107 goto err;
108 } 108 }
109 109
110 mac_addr = get_property(np, "address", NULL); 110 mac_addr = of_get_property(np, "address", NULL);
111 memcpy(tsi_eth_data.mac_addr, mac_addr, 6); 111 memcpy(tsi_eth_data.mac_addr, mac_addr, 6);
112 112
113 ph = (phandle *) get_property(np, "phy-handle", NULL); 113 ph = of_get_property(np, "phy-handle", NULL);
114 phy = of_find_node_by_phandle(*ph); 114 phy = of_find_node_by_phandle(*ph);
115 115
116 if (phy == NULL) { 116 if (phy == NULL) {
@@ -118,8 +118,8 @@ static int __init tsi108_eth_of_init(void)
118 goto unreg; 118 goto unreg;
119 } 119 }
120 120
121 id = (u32 *) get_property(phy, "reg", NULL); 121 id = of_get_property(phy, "reg", NULL);
122 phy_id = (u32 *) get_property(phy, "phy-id", NULL); 122 phy_id = of_get_property(phy, "phy-id", NULL);
123 ret = of_address_to_resource(phy, 0, &res); 123 ret = of_address_to_resource(phy, 0, &res);
124 if (ret) { 124 if (ret) {
125 of_node_put(phy); 125 of_node_put(phy);
diff --git a/arch/powerpc/sysdev/tsi108_pci.c b/arch/powerpc/sysdev/tsi108_pci.c
index ae249c6bbbcf..58b9e7f8abf2 100644
--- a/arch/powerpc/sysdev/tsi108_pci.c
+++ b/arch/powerpc/sysdev/tsi108_pci.c
@@ -211,7 +211,7 @@ int __init tsi108_setup_pci(struct device_node *dev)
211 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0); 211 has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
212 212
213 /* Get bus range if any */ 213 /* Get bus range if any */
214 bus_range = get_property(dev, "bus-range", &len); 214 bus_range = of_get_property(dev, "bus-range", &len);
215 if (bus_range == NULL || len < 2 * sizeof(int)) { 215 if (bus_range == NULL || len < 2 * sizeof(int)) {
216 printk(KERN_WARNING "Can't get bus-range for %s, assume" 216 printk(KERN_WARNING "Can't get bus-range for %s, assume"
217 " bus 0\n", dev->full_name); 217 " bus 0\n", dev->full_name);
diff --git a/arch/powerpc/sysdev/uic.c b/arch/powerpc/sysdev/uic.c
new file mode 100644
index 000000000000..968fb40af9dc
--- /dev/null
+++ b/arch/powerpc/sysdev/uic.c
@@ -0,0 +1,342 @@
1/*
2 * arch/powerpc/sysdev/uic.c
3 *
4 * IBM PowerPC 4xx Universal Interrupt Controller
5 *
6 * Copyright 2007 David Gibson <dwg@au1.ibm.com>, IBM Corporation.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/errno.h>
16#include <linux/reboot.h>
17#include <linux/slab.h>
18#include <linux/stddef.h>
19#include <linux/sched.h>
20#include <linux/signal.h>
21#include <linux/sysdev.h>
22#include <linux/device.h>
23#include <linux/bootmem.h>
24#include <linux/spinlock.h>
25#include <linux/irq.h>
26#include <linux/interrupt.h>
27#include <asm/irq.h>
28#include <asm/io.h>
29#include <asm/prom.h>
30#include <asm/dcr.h>
31
32#define NR_UIC_INTS 32
33
34#define UIC_SR 0x0
35#define UIC_ER 0x2
36#define UIC_CR 0x3
37#define UIC_PR 0x4
38#define UIC_TR 0x5
39#define UIC_MSR 0x6
40#define UIC_VR 0x7
41#define UIC_VCR 0x8
42
43#define uic_irq_to_hw(virq) (irq_map[virq].hwirq)
44
45struct uic *primary_uic;
46
47struct uic {
48 int index;
49 int dcrbase;
50
51 spinlock_t lock;
52
53 /* The remapper for this UIC */
54 struct irq_host *irqhost;
55
56 /* For secondary UICs, the cascade interrupt's irqaction */
57 struct irqaction cascade;
58
59 /* The device node of the interrupt controller */
60 struct device_node *of_node;
61};
62
63static void uic_unmask_irq(unsigned int virq)
64{
65 struct uic *uic = get_irq_chip_data(virq);
66 unsigned int src = uic_irq_to_hw(virq);
67 unsigned long flags;
68 u32 er;
69
70 spin_lock_irqsave(&uic->lock, flags);
71 er = mfdcr(uic->dcrbase + UIC_ER);
72 er |= 1 << (31 - src);
73 mtdcr(uic->dcrbase + UIC_ER, er);
74 spin_unlock_irqrestore(&uic->lock, flags);
75}
76
77static void uic_mask_irq(unsigned int virq)
78{
79 struct uic *uic = get_irq_chip_data(virq);
80 unsigned int src = uic_irq_to_hw(virq);
81 unsigned long flags;
82 u32 er;
83
84 spin_lock_irqsave(&uic->lock, flags);
85 er = mfdcr(uic->dcrbase + UIC_ER);
86 er &= ~(1 << (31 - src));
87 mtdcr(uic->dcrbase + UIC_ER, er);
88 spin_unlock_irqrestore(&uic->lock, flags);
89}
90
91static void uic_ack_irq(unsigned int virq)
92{
93 struct uic *uic = get_irq_chip_data(virq);
94 unsigned int src = uic_irq_to_hw(virq);
95 unsigned long flags;
96
97 spin_lock_irqsave(&uic->lock, flags);
98 mtdcr(uic->dcrbase + UIC_SR, 1 << (31-src));
99 spin_unlock_irqrestore(&uic->lock, flags);
100}
101
102static int uic_set_irq_type(unsigned int virq, unsigned int flow_type)
103{
104 struct uic *uic = get_irq_chip_data(virq);
105 unsigned int src = uic_irq_to_hw(virq);
106 struct irq_desc *desc = get_irq_desc(virq);
107 unsigned long flags;
108 int trigger, polarity;
109 u32 tr, pr, mask;
110
111 switch (flow_type & IRQ_TYPE_SENSE_MASK) {
112 case IRQ_TYPE_NONE:
113 uic_mask_irq(virq);
114 return 0;
115
116 case IRQ_TYPE_EDGE_RISING:
117 trigger = 1; polarity = 1;
118 break;
119 case IRQ_TYPE_EDGE_FALLING:
120 trigger = 1; polarity = 0;
121 break;
122 case IRQ_TYPE_LEVEL_HIGH:
123 trigger = 0; polarity = 1;
124 break;
125 case IRQ_TYPE_LEVEL_LOW:
126 trigger = 0; polarity = 0;
127 break;
128 default:
129 return -EINVAL;
130 }
131
132 mask = ~(1 << (31 - src));
133
134 spin_lock_irqsave(&uic->lock, flags);
135 tr = mfdcr(uic->dcrbase + UIC_TR);
136 pr = mfdcr(uic->dcrbase + UIC_PR);
137 tr = (tr & mask) | (trigger << (31-src));
138 pr = (pr & mask) | (polarity << (31-src));
139
140 mtdcr(uic->dcrbase + UIC_PR, pr);
141 mtdcr(uic->dcrbase + UIC_TR, tr);
142
143 desc->status &= ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL);
144 desc->status |= flow_type & IRQ_TYPE_SENSE_MASK;
145 if (trigger)
146 desc->status |= IRQ_LEVEL;
147
148 spin_unlock_irqrestore(&uic->lock, flags);
149
150 return 0;
151}
152
153static struct irq_chip uic_irq_chip = {
154 .typename = " UIC ",
155 .unmask = uic_unmask_irq,
156 .mask = uic_mask_irq,
157/* .mask_ack = uic_mask_irq_and_ack, */
158 .ack = uic_ack_irq,
159 .set_type = uic_set_irq_type,
160};
161
162static int uic_host_match(struct irq_host *h, struct device_node *node)
163{
164 struct uic *uic = h->host_data;
165 return uic->of_node == node;
166}
167
168static int uic_host_map(struct irq_host *h, unsigned int virq,
169 irq_hw_number_t hw)
170{
171 struct uic *uic = h->host_data;
172
173 set_irq_chip_data(virq, uic);
174 /* Despite the name, handle_level_irq() works for both level
175 * and edge irqs on UIC. FIXME: check this is correct */
176 set_irq_chip_and_handler(virq, &uic_irq_chip, handle_level_irq);
177
178 /* Set default irq type */
179 set_irq_type(virq, IRQ_TYPE_NONE);
180
181 return 0;
182}
183
184static int uic_host_xlate(struct irq_host *h, struct device_node *ct,
185 u32 *intspec, unsigned int intsize,
186 irq_hw_number_t *out_hwirq, unsigned int *out_type)
187
188{
189 /* UIC intspecs must have 2 cells */
190 BUG_ON(intsize != 2);
191 *out_hwirq = intspec[0];
192 *out_type = intspec[1];
193 return 0;
194}
195
196static struct irq_host_ops uic_host_ops = {
197 .match = uic_host_match,
198 .map = uic_host_map,
199 .xlate = uic_host_xlate,
200};
201
202irqreturn_t uic_cascade(int virq, void *data)
203{
204 struct uic *uic = data;
205 u32 msr;
206 int src;
207 int subvirq;
208
209 msr = mfdcr(uic->dcrbase + UIC_MSR);
210 src = 32 - ffs(msr);
211
212 subvirq = irq_linear_revmap(uic->irqhost, src);
213 generic_handle_irq(subvirq);
214
215 return IRQ_HANDLED;
216}
217
218static struct uic * __init uic_init_one(struct device_node *node)
219{
220 struct uic *uic;
221 const u32 *indexp, *dcrreg;
222 int len;
223
224 BUG_ON(! device_is_compatible(node, "ibm,uic"));
225
226 uic = alloc_bootmem(sizeof(*uic));
227 if (! uic)
228 return NULL; /* FIXME: panic? */
229
230 memset(uic, 0, sizeof(*uic));
231 spin_lock_init(&uic->lock);
232 uic->of_node = of_node_get(node);
233 indexp = of_get_property(node, "cell-index", &len);
234 if (!indexp || (len != sizeof(u32))) {
235 printk(KERN_ERR "uic: Device node %s has missing or invalid "
236 "cell-index property\n", node->full_name);
237 return NULL;
238 }
239 uic->index = *indexp;
240
241 dcrreg = of_get_property(node, "dcr-reg", &len);
242 if (!dcrreg || (len != 2*sizeof(u32))) {
243 printk(KERN_ERR "uic: Device node %s has missing or invalid "
244 "dcr-reg property\n", node->full_name);
245 return NULL;
246 }
247 uic->dcrbase = *dcrreg;
248
249 uic->irqhost = irq_alloc_host(IRQ_HOST_MAP_LINEAR, NR_UIC_INTS,
250 &uic_host_ops, -1);
251 if (! uic->irqhost) {
252 of_node_put(node);
253 return NULL; /* FIXME: panic? */
254 }
255
256 uic->irqhost->host_data = uic;
257
258 /* Start with all interrupts disabled, level and non-critical */
259 mtdcr(uic->dcrbase + UIC_ER, 0);
260 mtdcr(uic->dcrbase + UIC_CR, 0);
261 mtdcr(uic->dcrbase + UIC_TR, 0);
262 /* Clear any pending interrupts, in case the firmware left some */
263 mtdcr(uic->dcrbase + UIC_SR, 0xffffffff);
264
265 printk ("UIC%d (%d IRQ sources) at DCR 0x%x\n", uic->index,
266 NR_UIC_INTS, uic->dcrbase);
267
268 return uic;
269}
270
271void __init uic_init_tree(void)
272{
273 struct device_node *np;
274 struct uic *uic;
275 const u32 *interrupts;
276
277 /* First locate and initialize the top-level UIC */
278
279 np = of_find_compatible_node(NULL, NULL, "ibm,uic");
280 while (np) {
281 interrupts = of_get_property(np, "interrupts", NULL);
282 if (! interrupts)
283 break;
284
285 np = of_find_compatible_node(np, NULL, "ibm,uic");
286 }
287
288 BUG_ON(!np); /* uic_init_tree() assumes there's a UIC as the
289 * top-level interrupt controller */
290 primary_uic = uic_init_one(np);
291 if (! primary_uic)
292 panic("Unable to initialize primary UIC %s\n", np->full_name);
293
294 irq_set_default_host(primary_uic->irqhost);
295 of_node_put(np);
296
297 /* The scan again for cascaded UICs */
298 np = of_find_compatible_node(NULL, NULL, "ibm,uic");
299 while (np) {
300 interrupts = of_get_property(np, "interrupts", NULL);
301 if (interrupts) {
302 /* Secondary UIC */
303 int cascade_virq;
304 int ret;
305
306 uic = uic_init_one(np);
307 if (! uic)
308 panic("Unable to initialize a secondary UIC %s\n",
309 np->full_name);
310
311 cascade_virq = irq_of_parse_and_map(np, 0);
312
313 uic->cascade.handler = uic_cascade;
314 uic->cascade.name = "UIC cascade";
315 uic->cascade.dev_id = uic;
316
317 ret = setup_irq(cascade_virq, &uic->cascade);
318 if (ret)
319 printk(KERN_ERR "Failed to setup_irq(%d) for "
320 "UIC%d cascade\n", cascade_virq,
321 uic->index);
322
323 /* FIXME: setup critical cascade?? */
324 }
325
326 np = of_find_compatible_node(np, NULL, "ibm,uic");
327 }
328}
329
330/* Return an interrupt vector or NO_IRQ if no interrupt is pending. */
331unsigned int uic_get_irq(void)
332{
333 u32 msr;
334 int src;
335
336 BUG_ON(! primary_uic);
337
338 msr = mfdcr(primary_uic->dcrbase + UIC_MSR);
339 src = 32 - ffs(msr);
340
341 return irq_linear_revmap(primary_uic->irqhost, src);
342}
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index bf299b66f3fc..b481db1dacb4 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -330,18 +330,17 @@ static void release_output_lock(void)
330static int xmon_core(struct pt_regs *regs, int fromipi) 330static int xmon_core(struct pt_regs *regs, int fromipi)
331{ 331{
332 int cmd = 0; 332 int cmd = 0;
333 unsigned long msr;
334 struct bpt *bp; 333 struct bpt *bp;
335 long recurse_jmp[JMP_BUF_LEN]; 334 long recurse_jmp[JMP_BUF_LEN];
336 unsigned long offset; 335 unsigned long offset;
336 unsigned long flags;
337#ifdef CONFIG_SMP 337#ifdef CONFIG_SMP
338 int cpu; 338 int cpu;
339 int secondary; 339 int secondary;
340 unsigned long timeout; 340 unsigned long timeout;
341#endif 341#endif
342 342
343 msr = mfmsr(); 343 local_irq_save(flags);
344 mtmsr(msr & ~MSR_EE); /* disable interrupts */
345 344
346 bp = in_breakpoint_table(regs->nip, &offset); 345 bp = in_breakpoint_table(regs->nip, &offset);
347 if (bp != NULL) { 346 if (bp != NULL) {
@@ -516,7 +515,7 @@ static int xmon_core(struct pt_regs *regs, int fromipi)
516 515
517 insert_cpu_bpts(); 516 insert_cpu_bpts();
518 517
519 mtmsr(msr); /* restore interrupt enable */ 518 local_irq_restore(flags);
520 519
521 return cmd != 'X' && cmd != EOF; 520 return cmd != 'X' && cmd != EOF;
522} 521}
@@ -1360,8 +1359,12 @@ static void print_bug_trap(struct pt_regs *regs)
1360 if (is_warning_bug(bug)) 1359 if (is_warning_bug(bug))
1361 return; 1360 return;
1362 1361
1362#ifdef CONFIG_DEBUG_BUGVERBOSE
1363 printf("kernel BUG at %s:%u!\n", 1363 printf("kernel BUG at %s:%u!\n",
1364 bug->file, bug->line); 1364 bug->file, bug->line);
1365#else
1366 printf("kernel BUG at %p!\n", (void *)bug->bug_addr);
1367#endif
1365} 1368}
1366 1369
1367void excprint(struct pt_regs *fp) 1370void excprint(struct pt_regs *fp)
diff --git a/arch/ppc/8xx_io/Kconfig b/arch/ppc/8xx_io/Kconfig
index 57dacf978532..c623e44f01ad 100644
--- a/arch/ppc/8xx_io/Kconfig
+++ b/arch/ppc/8xx_io/Kconfig
@@ -74,10 +74,6 @@ config ENET_BIG_BUFFERS
74 Allocate large buffers for MPC8xx Ethernet. Increases throughput 74 Allocate large buffers for MPC8xx Ethernet. Increases throughput
75 and decreases the likelihood of dropped packets, but costs memory. 75 and decreases the likelihood of dropped packets, but costs memory.
76 76
77config HTDMSOUND
78 bool "Embedded Planet HIOX Audio"
79 depends on SOUND=y
80
81# This doesn't really belong here, but it is convenient to ask 77# This doesn't really belong here, but it is convenient to ask
82# 8xx specific questions. 78# 8xx specific questions.
83comment "Generic MPC8xx Options" 79comment "Generic MPC8xx Options"
diff --git a/arch/ppc/8xx_io/Makefile b/arch/ppc/8xx_io/Makefile
index d8760181fe99..1051a06df7e0 100644
--- a/arch/ppc/8xx_io/Makefile
+++ b/arch/ppc/8xx_io/Makefile
@@ -7,4 +7,3 @@ obj-y := commproc.o
7obj-$(CONFIG_FEC_ENET) += fec.o 7obj-$(CONFIG_FEC_ENET) += fec.o
8obj-$(CONFIG_SCC_ENET) += enet.o 8obj-$(CONFIG_SCC_ENET) += enet.o
9obj-$(CONFIG_UCODE_PATCH) += micropatch.o 9obj-$(CONFIG_UCODE_PATCH) += micropatch.o
10obj-$(CONFIG_HTDMSOUND) += cs4218_tdm.o
diff --git a/arch/ppc/8xx_io/cs4218.h b/arch/ppc/8xx_io/cs4218.h
deleted file mode 100644
index e5f943045afa..000000000000
--- a/arch/ppc/8xx_io/cs4218.h
+++ /dev/null
@@ -1,166 +0,0 @@
1#ifndef _cs4218_h_
2/*
3 * Hacked version of linux/drivers/sound/dmasound/dmasound.h
4 *
5 *
6 * Minor numbers for the sound driver.
7 *
8 * Unfortunately Creative called the codec chip of SB as a DSP. For this
9 * reason the /dev/dsp is reserved for digitized audio use. There is a
10 * device for true DSP processors but it will be called something else.
11 * In v3.0 it's /dev/sndproc but this could be a temporary solution.
12 */
13#define _cs4218_h_
14
15#include <linux/types.h>
16
17#define SND_NDEVS 256 /* Number of supported devices */
18#define SND_DEV_CTL 0 /* Control port /dev/mixer */
19#define SND_DEV_SEQ 1 /* Sequencer output /dev/sequencer (FM
20 synthesizer and MIDI output) */
21#define SND_DEV_MIDIN 2 /* Raw midi access */
22#define SND_DEV_DSP 3 /* Digitized voice /dev/dsp */
23#define SND_DEV_AUDIO 4 /* Sparc compatible /dev/audio */
24#define SND_DEV_DSP16 5 /* Like /dev/dsp but 16 bits/sample */
25#define SND_DEV_STATUS 6 /* /dev/sndstat */
26/* #7 not in use now. Was in 2.4. Free for use after v3.0. */
27#define SND_DEV_SEQ2 8 /* /dev/sequencer, level 2 interface */
28#define SND_DEV_SNDPROC 9 /* /dev/sndproc for programmable devices */
29#define SND_DEV_PSS SND_DEV_SNDPROC
30
31/* switch on various prinks */
32#define DEBUG_DMASOUND 1
33
34#define MAX_AUDIO_DEV 5
35#define MAX_MIXER_DEV 4
36#define MAX_SYNTH_DEV 3
37#define MAX_MIDI_DEV 6
38#define MAX_TIMER_DEV 3
39
40#define MAX_CATCH_RADIUS 10
41
42#define le2be16(x) (((x)<<8 & 0xff00) | ((x)>>8 & 0x00ff))
43#define le2be16dbl(x) (((x)<<8 & 0xff00ff00) | ((x)>>8 & 0x00ff00ff))
44
45#define IOCTL_IN(arg, ret) \
46 do { int error = get_user(ret, (int *)(arg)); \
47 if (error) return error; \
48 } while (0)
49#define IOCTL_OUT(arg, ret) ioctl_return((int *)(arg), ret)
50
51static inline int ioctl_return(int *addr, int value)
52{
53 return value < 0 ? value : put_user(value, addr);
54}
55
56#define HAS_RECORD
57
58 /*
59 * Initialization
60 */
61
62/* description of the set-up applies to either hard or soft settings */
63
64typedef struct {
65 int format; /* AFMT_* */
66 int stereo; /* 0 = mono, 1 = stereo */
67 int size; /* 8/16 bit*/
68 int speed; /* speed */
69} SETTINGS;
70
71 /*
72 * Machine definitions
73 */
74
75typedef struct {
76 const char *name;
77 const char *name2;
78 void (*open)(void);
79 void (*release)(void);
80 void *(*dma_alloc)(unsigned int, gfp_t);
81 void (*dma_free)(void *, unsigned int);
82 int (*irqinit)(void);
83#ifdef MODULE
84 void (*irqcleanup)(void);
85#endif
86 void (*init)(void);
87 void (*silence)(void);
88 int (*setFormat)(int);
89 int (*setVolume)(int);
90 int (*setBass)(int);
91 int (*setTreble)(int);
92 int (*setGain)(int);
93 void (*play)(void);
94 void (*record)(void); /* optional */
95 void (*mixer_init)(void); /* optional */
96 int (*mixer_ioctl)(u_int, u_long); /* optional */
97 int (*write_sq_setup)(void); /* optional */
98 int (*read_sq_setup)(void); /* optional */
99 int (*sq_open)(mode_t); /* optional */
100 int (*state_info)(char *, size_t); /* optional */
101 void (*abort_read)(void); /* optional */
102 int min_dsp_speed;
103 int max_dsp_speed;
104 int version ;
105 int hardware_afmts ; /* OSS says we only return h'ware info */
106 /* when queried via SNDCTL_DSP_GETFMTS */
107 int capabilities ; /* low-level reply to SNDCTL_DSP_GETCAPS */
108 SETTINGS default_hard ; /* open() or init() should set something valid */
109 SETTINGS default_soft ; /* you can make it look like old OSS, if you want to */
110} MACHINE;
111
112 /*
113 * Low level stuff
114 */
115
116typedef struct {
117 ssize_t (*ct_ulaw)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
118 ssize_t (*ct_alaw)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
119 ssize_t (*ct_s8)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
120 ssize_t (*ct_u8)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
121 ssize_t (*ct_s16be)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
122 ssize_t (*ct_u16be)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
123 ssize_t (*ct_s16le)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
124 ssize_t (*ct_u16le)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
125} TRANS;
126
127
128 /*
129 * Sound queue stuff, the heart of the driver
130 */
131
132struct sound_queue {
133 /* buffers allocated for this queue */
134 int numBufs; /* real limits on what the user can have */
135 int bufSize; /* in bytes */
136 char **buffers;
137
138 /* current parameters */
139 int locked ; /* params cannot be modified when != 0 */
140 int user_frags ; /* user requests this many */
141 int user_frag_size ; /* of this size */
142 int max_count; /* actual # fragments <= numBufs */
143 int block_size; /* internal block size in bytes */
144 int max_active; /* in-use fragments <= max_count */
145
146 /* it shouldn't be necessary to declare any of these volatile */
147 int front, rear, count;
148 int rear_size;
149 /*
150 * The use of the playing field depends on the hardware
151 *
152 * Atari, PMac: The number of frames that are loaded/playing
153 *
154 * Amiga: Bit 0 is set: a frame is loaded
155 * Bit 1 is set: a frame is playing
156 */
157 int active;
158 wait_queue_head_t action_queue, open_queue, sync_queue;
159 int open_mode;
160 int busy, syncing, xruns, died;
161};
162
163#define SLEEP(queue) interruptible_sleep_on_timeout(&queue, HZ)
164#define WAKE_UP(queue) (wake_up_interruptible(&queue))
165
166#endif /* _cs4218_h_ */
diff --git a/arch/ppc/8xx_io/cs4218_tdm.c b/arch/ppc/8xx_io/cs4218_tdm.c
deleted file mode 100644
index a956f28ab162..000000000000
--- a/arch/ppc/8xx_io/cs4218_tdm.c
+++ /dev/null
@@ -1,2833 +0,0 @@
1
2/* This is a modified version of linux/drivers/sound/dmasound.c to
3 * support the CS4218 codec on the 8xx TDM port. Thanks to everyone
4 * that contributed to the dmasound software (which includes me :-).
5 *
6 * The CS4218 is configured in Mode 4, sub-mode 0. This provides
7 * left/right data only on the TDM port, as a 32-bit word, per frame
8 * pulse. The control of the CS4218 is provided by some other means,
9 * like the SPI port.
10 * Dan Malek (dmalek@jlc.net)
11 */
12
13#include <linux/module.h>
14#include <linux/sched.h>
15#include <linux/timer.h>
16#include <linux/major.h>
17#include <linux/fcntl.h>
18#include <linux/errno.h>
19#include <linux/mm.h>
20#include <linux/slab.h>
21#include <linux/sound.h>
22#include <linux/init.h>
23#include <linux/delay.h>
24
25#include <asm/system.h>
26#include <asm/irq.h>
27#include <asm/pgtable.h>
28#include <asm/uaccess.h>
29#include <asm/io.h>
30
31/* Should probably do something different with this path name.....
32 * Actually, I should just stop using it...
33 */
34#include "cs4218.h"
35#include <linux/soundcard.h>
36
37#include <asm/mpc8xx.h>
38#include <asm/8xx_immap.h>
39#include <asm/commproc.h>
40
41#define DMASND_CS4218 5
42
43#define MAX_CATCH_RADIUS 10
44#define MIN_BUFFERS 4
45#define MIN_BUFSIZE 4
46#define MAX_BUFSIZE 128
47
48#define HAS_8BIT_TABLES
49
50static int sq_unit = -1;
51static int mixer_unit = -1;
52static int state_unit = -1;
53static int irq_installed = 0;
54static char **sound_buffers = NULL;
55static char **sound_read_buffers = NULL;
56
57static DEFINE_SPINLOCK(cs4218_lock);
58
59/* Local copies of things we put in the control register. Output
60 * volume, like most codecs is really attenuation.
61 */
62static int cs4218_rate_index;
63
64/*
65 * Stuff for outputting a beep. The values range from -327 to +327
66 * so we can multiply by an amplitude in the range 0..100 to get a
67 * signed short value to put in the output buffer.
68 */
69static short beep_wform[256] = {
70 0, 40, 79, 117, 153, 187, 218, 245,
71 269, 288, 304, 316, 323, 327, 327, 324,
72 318, 310, 299, 288, 275, 262, 249, 236,
73 224, 213, 204, 196, 190, 186, 183, 182,
74 182, 183, 186, 189, 192, 196, 200, 203,
75 206, 208, 209, 209, 209, 207, 204, 201,
76 197, 193, 188, 183, 179, 174, 170, 166,
77 163, 161, 160, 159, 159, 160, 161, 162,
78 164, 166, 168, 169, 171, 171, 171, 170,
79 169, 167, 163, 159, 155, 150, 144, 139,
80 133, 128, 122, 117, 113, 110, 107, 105,
81 103, 103, 103, 103, 104, 104, 105, 105,
82 105, 103, 101, 97, 92, 86, 78, 68,
83 58, 45, 32, 18, 3, -11, -26, -41,
84 -55, -68, -79, -88, -95, -100, -102, -102,
85 -99, -93, -85, -75, -62, -48, -33, -16,
86 0, 16, 33, 48, 62, 75, 85, 93,
87 99, 102, 102, 100, 95, 88, 79, 68,
88 55, 41, 26, 11, -3, -18, -32, -45,
89 -58, -68, -78, -86, -92, -97, -101, -103,
90 -105, -105, -105, -104, -104, -103, -103, -103,
91 -103, -105, -107, -110, -113, -117, -122, -128,
92 -133, -139, -144, -150, -155, -159, -163, -167,
93 -169, -170, -171, -171, -171, -169, -168, -166,
94 -164, -162, -161, -160, -159, -159, -160, -161,
95 -163, -166, -170, -174, -179, -183, -188, -193,
96 -197, -201, -204, -207, -209, -209, -209, -208,
97 -206, -203, -200, -196, -192, -189, -186, -183,
98 -182, -182, -183, -186, -190, -196, -204, -213,
99 -224, -236, -249, -262, -275, -288, -299, -310,
100 -318, -324, -327, -327, -323, -316, -304, -288,
101 -269, -245, -218, -187, -153, -117, -79, -40,
102};
103
104#define BEEP_SPEED 5 /* 22050 Hz sample rate */
105#define BEEP_BUFLEN 512
106#define BEEP_VOLUME 15 /* 0 - 100 */
107
108static int beep_volume = BEEP_VOLUME;
109static int beep_playing = 0;
110static int beep_state = 0;
111static short *beep_buf;
112static void (*orig_mksound)(unsigned int, unsigned int);
113
114/* This is found someplace else......I guess in the keyboard driver
115 * we don't include.
116 */
117static void (*kd_mksound)(unsigned int, unsigned int);
118
119static int catchRadius = 0;
120static int numBufs = 4, bufSize = 32;
121static int numReadBufs = 4, readbufSize = 32;
122
123
124/* TDM/Serial transmit and receive buffer descriptors.
125*/
126static volatile cbd_t *rx_base, *rx_cur, *tx_base, *tx_cur;
127
128module_param(catchRadius, int, 0);
129module_param(numBufs, int, 0);
130module_param(bufSize, int, 0);
131module_param(numreadBufs, int, 0);
132module_param(readbufSize, int, 0);
133
134#define arraysize(x) (sizeof(x)/sizeof(*(x)))
135#define le2be16(x) (((x)<<8 & 0xff00) | ((x)>>8 & 0x00ff))
136#define le2be16dbl(x) (((x)<<8 & 0xff00ff00) | ((x)>>8 & 0x00ff00ff))
137
138#define IOCTL_IN(arg, ret) \
139 do { int error = get_user(ret, (int *)(arg)); \
140 if (error) return error; \
141 } while (0)
142#define IOCTL_OUT(arg, ret) ioctl_return((int *)(arg), ret)
143
144/* CS4218 serial port control in mode 4.
145*/
146#define CS_INTMASK ((uint)0x40000000)
147#define CS_DO1 ((uint)0x20000000)
148#define CS_LATTEN ((uint)0x1f000000)
149#define CS_RATTEN ((uint)0x00f80000)
150#define CS_MUTE ((uint)0x00040000)
151#define CS_ISL ((uint)0x00020000)
152#define CS_ISR ((uint)0x00010000)
153#define CS_LGAIN ((uint)0x0000f000)
154#define CS_RGAIN ((uint)0x00000f00)
155
156#define CS_LATTEN_SET(X) (((X) & 0x1f) << 24)
157#define CS_RATTEN_SET(X) (((X) & 0x1f) << 19)
158#define CS_LGAIN_SET(X) (((X) & 0x0f) << 12)
159#define CS_RGAIN_SET(X) (((X) & 0x0f) << 8)
160
161#define CS_LATTEN_GET(X) (((X) >> 24) & 0x1f)
162#define CS_RATTEN_GET(X) (((X) >> 19) & 0x1f)
163#define CS_LGAIN_GET(X) (((X) >> 12) & 0x0f)
164#define CS_RGAIN_GET(X) (((X) >> 8) & 0x0f)
165
166/* The control register is effectively write only. We have to keep a copy
167 * of what we write.
168 */
169static uint cs4218_control;
170
171/* A place to store expanding information.
172*/
173static int expand_bal;
174static int expand_data;
175
176/* Since I can't make the microcode patch work for the SPI, I just
177 * clock the bits using software.
178 */
179static void sw_spi_init(void);
180static void sw_spi_io(u_char *obuf, u_char *ibuf, uint bcnt);
181static uint cs4218_ctl_write(uint ctlreg);
182
183/*** Some low level helpers **************************************************/
184
185/* 16 bit mu-law */
186
187static short ulaw2dma16[] = {
188 -32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956,
189 -23932, -22908, -21884, -20860, -19836, -18812, -17788, -16764,
190 -15996, -15484, -14972, -14460, -13948, -13436, -12924, -12412,
191 -11900, -11388, -10876, -10364, -9852, -9340, -8828, -8316,
192 -7932, -7676, -7420, -7164, -6908, -6652, -6396, -6140,
193 -5884, -5628, -5372, -5116, -4860, -4604, -4348, -4092,
194 -3900, -3772, -3644, -3516, -3388, -3260, -3132, -3004,
195 -2876, -2748, -2620, -2492, -2364, -2236, -2108, -1980,
196 -1884, -1820, -1756, -1692, -1628, -1564, -1500, -1436,
197 -1372, -1308, -1244, -1180, -1116, -1052, -988, -924,
198 -876, -844, -812, -780, -748, -716, -684, -652,
199 -620, -588, -556, -524, -492, -460, -428, -396,
200 -372, -356, -340, -324, -308, -292, -276, -260,
201 -244, -228, -212, -196, -180, -164, -148, -132,
202 -120, -112, -104, -96, -88, -80, -72, -64,
203 -56, -48, -40, -32, -24, -16, -8, 0,
204 32124, 31100, 30076, 29052, 28028, 27004, 25980, 24956,
205 23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764,
206 15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412,
207 11900, 11388, 10876, 10364, 9852, 9340, 8828, 8316,
208 7932, 7676, 7420, 7164, 6908, 6652, 6396, 6140,
209 5884, 5628, 5372, 5116, 4860, 4604, 4348, 4092,
210 3900, 3772, 3644, 3516, 3388, 3260, 3132, 3004,
211 2876, 2748, 2620, 2492, 2364, 2236, 2108, 1980,
212 1884, 1820, 1756, 1692, 1628, 1564, 1500, 1436,
213 1372, 1308, 1244, 1180, 1116, 1052, 988, 924,
214 876, 844, 812, 780, 748, 716, 684, 652,
215 620, 588, 556, 524, 492, 460, 428, 396,
216 372, 356, 340, 324, 308, 292, 276, 260,
217 244, 228, 212, 196, 180, 164, 148, 132,
218 120, 112, 104, 96, 88, 80, 72, 64,
219 56, 48, 40, 32, 24, 16, 8, 0,
220};
221
222/* 16 bit A-law */
223
224static short alaw2dma16[] = {
225 -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736,
226 -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784,
227 -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368,
228 -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392,
229 -22016, -20992, -24064, -23040, -17920, -16896, -19968, -18944,
230 -30208, -29184, -32256, -31232, -26112, -25088, -28160, -27136,
231 -11008, -10496, -12032, -11520, -8960, -8448, -9984, -9472,
232 -15104, -14592, -16128, -15616, -13056, -12544, -14080, -13568,
233 -344, -328, -376, -360, -280, -264, -312, -296,
234 -472, -456, -504, -488, -408, -392, -440, -424,
235 -88, -72, -120, -104, -24, -8, -56, -40,
236 -216, -200, -248, -232, -152, -136, -184, -168,
237 -1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184,
238 -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696,
239 -688, -656, -752, -720, -560, -528, -624, -592,
240 -944, -912, -1008, -976, -816, -784, -880, -848,
241 5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736,
242 7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784,
243 2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368,
244 3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392,
245 22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944,
246 30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136,
247 11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472,
248 15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568,
249 344, 328, 376, 360, 280, 264, 312, 296,
250 472, 456, 504, 488, 408, 392, 440, 424,
251 88, 72, 120, 104, 24, 8, 56, 40,
252 216, 200, 248, 232, 152, 136, 184, 168,
253 1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184,
254 1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696,
255 688, 656, 752, 720, 560, 528, 624, 592,
256 944, 912, 1008, 976, 816, 784, 880, 848,
257};
258
259
260/*** Translations ************************************************************/
261
262
263static ssize_t cs4218_ct_law(const u_char *userPtr, size_t userCount,
264 u_char frame[], ssize_t *frameUsed,
265 ssize_t frameLeft);
266static ssize_t cs4218_ct_s8(const u_char *userPtr, size_t userCount,
267 u_char frame[], ssize_t *frameUsed,
268 ssize_t frameLeft);
269static ssize_t cs4218_ct_u8(const u_char *userPtr, size_t userCount,
270 u_char frame[], ssize_t *frameUsed,
271 ssize_t frameLeft);
272static ssize_t cs4218_ct_s16(const u_char *userPtr, size_t userCount,
273 u_char frame[], ssize_t *frameUsed,
274 ssize_t frameLeft);
275static ssize_t cs4218_ct_u16(const u_char *userPtr, size_t userCount,
276 u_char frame[], ssize_t *frameUsed,
277 ssize_t frameLeft);
278static ssize_t cs4218_ctx_law(const u_char *userPtr, size_t userCount,
279 u_char frame[], ssize_t *frameUsed,
280 ssize_t frameLeft);
281static ssize_t cs4218_ctx_s8(const u_char *userPtr, size_t userCount,
282 u_char frame[], ssize_t *frameUsed,
283 ssize_t frameLeft);
284static ssize_t cs4218_ctx_u8(const u_char *userPtr, size_t userCount,
285 u_char frame[], ssize_t *frameUsed,
286 ssize_t frameLeft);
287static ssize_t cs4218_ctx_s16(const u_char *userPtr, size_t userCount,
288 u_char frame[], ssize_t *frameUsed,
289 ssize_t frameLeft);
290static ssize_t cs4218_ctx_u16(const u_char *userPtr, size_t userCount,
291 u_char frame[], ssize_t *frameUsed,
292 ssize_t frameLeft);
293static ssize_t cs4218_ct_s16_read(const u_char *userPtr, size_t userCount,
294 u_char frame[], ssize_t *frameUsed,
295 ssize_t frameLeft);
296static ssize_t cs4218_ct_u16_read(const u_char *userPtr, size_t userCount,
297 u_char frame[], ssize_t *frameUsed,
298 ssize_t frameLeft);
299
300
301/*** Low level stuff *********************************************************/
302
303struct cs_sound_settings {
304 MACHINE mach; /* machine dependent things */
305 SETTINGS hard; /* hardware settings */
306 SETTINGS soft; /* software settings */
307 SETTINGS dsp; /* /dev/dsp default settings */
308 TRANS *trans_write; /* supported translations for playback */
309 TRANS *trans_read; /* supported translations for record */
310 int volume_left; /* volume (range is machine dependent) */
311 int volume_right;
312 int bass; /* tone (range is machine dependent) */
313 int treble;
314 int gain;
315 int minDev; /* minor device number currently open */
316};
317
318static struct cs_sound_settings sound;
319
320static void *CS_Alloc(unsigned int size, gfp_t flags);
321static void CS_Free(void *ptr, unsigned int size);
322static int CS_IrqInit(void);
323#ifdef MODULE
324static void CS_IrqCleanup(void);
325#endif /* MODULE */
326static void CS_Silence(void);
327static void CS_Init(void);
328static void CS_Play(void);
329static void CS_Record(void);
330static int CS_SetFormat(int format);
331static int CS_SetVolume(int volume);
332static void cs4218_tdm_tx_intr(void *devid);
333static void cs4218_tdm_rx_intr(void *devid);
334static void cs4218_intr(void *devid);
335static int cs_get_volume(uint reg);
336static int cs_volume_setter(int volume, int mute);
337static int cs_get_gain(uint reg);
338static int cs_set_gain(int gain);
339static void cs_mksound(unsigned int hz, unsigned int ticks);
340static void cs_nosound(unsigned long xx);
341
342/*** Mid level stuff *********************************************************/
343
344
345static void sound_silence(void);
346static void sound_init(void);
347static int sound_set_format(int format);
348static int sound_set_speed(int speed);
349static int sound_set_stereo(int stereo);
350static int sound_set_volume(int volume);
351
352static ssize_t sound_copy_translate(const u_char *userPtr,
353 size_t userCount,
354 u_char frame[], ssize_t *frameUsed,
355 ssize_t frameLeft);
356static ssize_t sound_copy_translate_read(const u_char *userPtr,
357 size_t userCount,
358 u_char frame[], ssize_t *frameUsed,
359 ssize_t frameLeft);
360
361
362/*
363 * /dev/mixer abstraction
364 */
365
366struct sound_mixer {
367 int busy;
368 int modify_counter;
369};
370
371static struct sound_mixer mixer;
372
373static struct sound_queue sq;
374static struct sound_queue read_sq;
375
376#define sq_block_address(i) (sq.buffers[i])
377#define SIGNAL_RECEIVED (signal_pending(current))
378#define NON_BLOCKING(open_mode) (open_mode & O_NONBLOCK)
379#define ONE_SECOND HZ /* in jiffies (100ths of a second) */
380#define NO_TIME_LIMIT 0xffffffff
381
382/*
383 * /dev/sndstat
384 */
385
386struct sound_state {
387 int busy;
388 char buf[512];
389 int len, ptr;
390};
391
392static struct sound_state state;
393
394/*** Common stuff ********************************************************/
395
396static long long sound_lseek(struct file *file, long long offset, int orig);
397
398/*** Config & Setup **********************************************************/
399
400void dmasound_setup(char *str, int *ints);
401
402/*** Translations ************************************************************/
403
404
405/* ++TeSche: radically changed for new expanding purposes...
406 *
407 * These two routines now deal with copying/expanding/translating the samples
408 * from user space into our buffer at the right frequency. They take care about
409 * how much data there's actually to read, how much buffer space there is and
410 * to convert samples into the right frequency/encoding. They will only work on
411 * complete samples so it may happen they leave some bytes in the input stream
412 * if the user didn't write a multiple of the current sample size. They both
413 * return the number of bytes they've used from both streams so you may detect
414 * such a situation. Luckily all programs should be able to cope with that.
415 *
416 * I think I've optimized anything as far as one can do in plain C, all
417 * variables should fit in registers and the loops are really short. There's
418 * one loop for every possible situation. Writing a more generalized and thus
419 * parameterized loop would only produce slower code. Feel free to optimize
420 * this in assembler if you like. :)
421 *
422 * I think these routines belong here because they're not yet really hardware
423 * independent, especially the fact that the Falcon can play 16bit samples
424 * only in stereo is hardcoded in both of them!
425 *
426 * ++geert: split in even more functions (one per format)
427 */
428
429static ssize_t cs4218_ct_law(const u_char *userPtr, size_t userCount,
430 u_char frame[], ssize_t *frameUsed,
431 ssize_t frameLeft)
432{
433 short *table = sound.soft.format == AFMT_MU_LAW ? ulaw2dma16: alaw2dma16;
434 ssize_t count, used;
435 short *p = (short *) &frame[*frameUsed];
436 int val, stereo = sound.soft.stereo;
437
438 frameLeft >>= 2;
439 if (stereo)
440 userCount >>= 1;
441 used = count = min(userCount, frameLeft);
442 while (count > 0) {
443 u_char data;
444 if (get_user(data, userPtr++))
445 return -EFAULT;
446 val = table[data];
447 *p++ = val;
448 if (stereo) {
449 if (get_user(data, userPtr++))
450 return -EFAULT;
451 val = table[data];
452 }
453 *p++ = val;
454 count--;
455 }
456 *frameUsed += used * 4;
457 return stereo? used * 2: used;
458}
459
460
461static ssize_t cs4218_ct_s8(const u_char *userPtr, size_t userCount,
462 u_char frame[], ssize_t *frameUsed,
463 ssize_t frameLeft)
464{
465 ssize_t count, used;
466 short *p = (short *) &frame[*frameUsed];
467 int val, stereo = sound.soft.stereo;
468
469 frameLeft >>= 2;
470 if (stereo)
471 userCount >>= 1;
472 used = count = min(userCount, frameLeft);
473 while (count > 0) {
474 u_char data;
475 if (get_user(data, userPtr++))
476 return -EFAULT;
477 val = data << 8;
478 *p++ = val;
479 if (stereo) {
480 if (get_user(data, userPtr++))
481 return -EFAULT;
482 val = data << 8;
483 }
484 *p++ = val;
485 count--;
486 }
487 *frameUsed += used * 4;
488 return stereo? used * 2: used;
489}
490
491
492static ssize_t cs4218_ct_u8(const u_char *userPtr, size_t userCount,
493 u_char frame[], ssize_t *frameUsed,
494 ssize_t frameLeft)
495{
496 ssize_t count, used;
497 short *p = (short *) &frame[*frameUsed];
498 int val, stereo = sound.soft.stereo;
499
500 frameLeft >>= 2;
501 if (stereo)
502 userCount >>= 1;
503 used = count = min(userCount, frameLeft);
504 while (count > 0) {
505 u_char data;
506 if (get_user(data, userPtr++))
507 return -EFAULT;
508 val = (data ^ 0x80) << 8;
509 *p++ = val;
510 if (stereo) {
511 if (get_user(data, userPtr++))
512 return -EFAULT;
513 val = (data ^ 0x80) << 8;
514 }
515 *p++ = val;
516 count--;
517 }
518 *frameUsed += used * 4;
519 return stereo? used * 2: used;
520}
521
522
523/* This is the default format of the codec. Signed, 16-bit stereo
524 * generated by an application shouldn't have to be copied at all.
525 * We should just get the phsical address of the buffers and update
526 * the TDM BDs directly.
527 */
528static ssize_t cs4218_ct_s16(const u_char *userPtr, size_t userCount,
529 u_char frame[], ssize_t *frameUsed,
530 ssize_t frameLeft)
531{
532 ssize_t count, used;
533 int stereo = sound.soft.stereo;
534 short *fp = (short *) &frame[*frameUsed];
535
536 frameLeft >>= 2;
537 userCount >>= (stereo? 2: 1);
538 used = count = min(userCount, frameLeft);
539 if (!stereo) {
540 short *up = (short *) userPtr;
541 while (count > 0) {
542 short data;
543 if (get_user(data, up++))
544 return -EFAULT;
545 *fp++ = data;
546 *fp++ = data;
547 count--;
548 }
549 } else {
550 if (copy_from_user(fp, userPtr, count * 4))
551 return -EFAULT;
552 }
553 *frameUsed += used * 4;
554 return stereo? used * 4: used * 2;
555}
556
557static ssize_t cs4218_ct_u16(const u_char *userPtr, size_t userCount,
558 u_char frame[], ssize_t *frameUsed,
559 ssize_t frameLeft)
560{
561 ssize_t count, used;
562 int mask = (sound.soft.format == AFMT_U16_LE? 0x0080: 0x8000);
563 int stereo = sound.soft.stereo;
564 short *fp = (short *) &frame[*frameUsed];
565 short *up = (short *) userPtr;
566
567 frameLeft >>= 2;
568 userCount >>= (stereo? 2: 1);
569 used = count = min(userCount, frameLeft);
570 while (count > 0) {
571 int data;
572 if (get_user(data, up++))
573 return -EFAULT;
574 data ^= mask;
575 *fp++ = data;
576 if (stereo) {
577 if (get_user(data, up++))
578 return -EFAULT;
579 data ^= mask;
580 }
581 *fp++ = data;
582 count--;
583 }
584 *frameUsed += used * 4;
585 return stereo? used * 4: used * 2;
586}
587
588
589static ssize_t cs4218_ctx_law(const u_char *userPtr, size_t userCount,
590 u_char frame[], ssize_t *frameUsed,
591 ssize_t frameLeft)
592{
593 unsigned short *table = (unsigned short *)
594 (sound.soft.format == AFMT_MU_LAW ? ulaw2dma16: alaw2dma16);
595 unsigned int data = expand_data;
596 unsigned int *p = (unsigned int *) &frame[*frameUsed];
597 int bal = expand_bal;
598 int hSpeed = sound.hard.speed, sSpeed = sound.soft.speed;
599 int utotal, ftotal;
600 int stereo = sound.soft.stereo;
601
602 frameLeft >>= 2;
603 if (stereo)
604 userCount >>= 1;
605 ftotal = frameLeft;
606 utotal = userCount;
607 while (frameLeft) {
608 u_char c;
609 if (bal < 0) {
610 if (userCount == 0)
611 break;
612 if (get_user(c, userPtr++))
613 return -EFAULT;
614 data = table[c];
615 if (stereo) {
616 if (get_user(c, userPtr++))
617 return -EFAULT;
618 data = (data << 16) + table[c];
619 } else
620 data = (data << 16) + data;
621 userCount--;
622 bal += hSpeed;
623 }
624 *p++ = data;
625 frameLeft--;
626 bal -= sSpeed;
627 }
628 expand_bal = bal;
629 expand_data = data;
630 *frameUsed += (ftotal - frameLeft) * 4;
631 utotal -= userCount;
632 return stereo? utotal * 2: utotal;
633}
634
635
636static ssize_t cs4218_ctx_s8(const u_char *userPtr, size_t userCount,
637 u_char frame[], ssize_t *frameUsed,
638 ssize_t frameLeft)
639{
640 unsigned int *p = (unsigned int *) &frame[*frameUsed];
641 unsigned int data = expand_data;
642 int bal = expand_bal;
643 int hSpeed = sound.hard.speed, sSpeed = sound.soft.speed;
644 int stereo = sound.soft.stereo;
645 int utotal, ftotal;
646
647 frameLeft >>= 2;
648 if (stereo)
649 userCount >>= 1;
650 ftotal = frameLeft;
651 utotal = userCount;
652 while (frameLeft) {
653 u_char c;
654 if (bal < 0) {
655 if (userCount == 0)
656 break;
657 if (get_user(c, userPtr++))
658 return -EFAULT;
659 data = c << 8;
660 if (stereo) {
661 if (get_user(c, userPtr++))
662 return -EFAULT;
663 data = (data << 16) + (c << 8);
664 } else
665 data = (data << 16) + data;
666 userCount--;
667 bal += hSpeed;
668 }
669 *p++ = data;
670 frameLeft--;
671 bal -= sSpeed;
672 }
673 expand_bal = bal;
674 expand_data = data;
675 *frameUsed += (ftotal - frameLeft) * 4;
676 utotal -= userCount;
677 return stereo? utotal * 2: utotal;
678}
679
680
681static ssize_t cs4218_ctx_u8(const u_char *userPtr, size_t userCount,
682 u_char frame[], ssize_t *frameUsed,
683 ssize_t frameLeft)
684{
685 unsigned int *p = (unsigned int *) &frame[*frameUsed];
686 unsigned int data = expand_data;
687 int bal = expand_bal;
688 int hSpeed = sound.hard.speed, sSpeed = sound.soft.speed;
689 int stereo = sound.soft.stereo;
690 int utotal, ftotal;
691
692 frameLeft >>= 2;
693 if (stereo)
694 userCount >>= 1;
695 ftotal = frameLeft;
696 utotal = userCount;
697 while (frameLeft) {
698 u_char c;
699 if (bal < 0) {
700 if (userCount == 0)
701 break;
702 if (get_user(c, userPtr++))
703 return -EFAULT;
704 data = (c ^ 0x80) << 8;
705 if (stereo) {
706 if (get_user(c, userPtr++))
707 return -EFAULT;
708 data = (data << 16) + ((c ^ 0x80) << 8);
709 } else
710 data = (data << 16) + data;
711 userCount--;
712 bal += hSpeed;
713 }
714 *p++ = data;
715 frameLeft--;
716 bal -= sSpeed;
717 }
718 expand_bal = bal;
719 expand_data = data;
720 *frameUsed += (ftotal - frameLeft) * 4;
721 utotal -= userCount;
722 return stereo? utotal * 2: utotal;
723}
724
725
726static ssize_t cs4218_ctx_s16(const u_char *userPtr, size_t userCount,
727 u_char frame[], ssize_t *frameUsed,
728 ssize_t frameLeft)
729{
730 unsigned int *p = (unsigned int *) &frame[*frameUsed];
731 unsigned int data = expand_data;
732 unsigned short *up = (unsigned short *) userPtr;
733 int bal = expand_bal;
734 int hSpeed = sound.hard.speed, sSpeed = sound.soft.speed;
735 int stereo = sound.soft.stereo;
736 int utotal, ftotal;
737
738 frameLeft >>= 2;
739 userCount >>= (stereo? 2: 1);
740 ftotal = frameLeft;
741 utotal = userCount;
742 while (frameLeft) {
743 unsigned short c;
744 if (bal < 0) {
745 if (userCount == 0)
746 break;
747 if (get_user(data, up++))
748 return -EFAULT;
749 if (stereo) {
750 if (get_user(c, up++))
751 return -EFAULT;
752 data = (data << 16) + c;
753 } else
754 data = (data << 16) + data;
755 userCount--;
756 bal += hSpeed;
757 }
758 *p++ = data;
759 frameLeft--;
760 bal -= sSpeed;
761 }
762 expand_bal = bal;
763 expand_data = data;
764 *frameUsed += (ftotal - frameLeft) * 4;
765 utotal -= userCount;
766 return stereo? utotal * 4: utotal * 2;
767}
768
769
770static ssize_t cs4218_ctx_u16(const u_char *userPtr, size_t userCount,
771 u_char frame[], ssize_t *frameUsed,
772 ssize_t frameLeft)
773{
774 int mask = (sound.soft.format == AFMT_U16_LE? 0x0080: 0x8000);
775 unsigned int *p = (unsigned int *) &frame[*frameUsed];
776 unsigned int data = expand_data;
777 unsigned short *up = (unsigned short *) userPtr;
778 int bal = expand_bal;
779 int hSpeed = sound.hard.speed, sSpeed = sound.soft.speed;
780 int stereo = sound.soft.stereo;
781 int utotal, ftotal;
782
783 frameLeft >>= 2;
784 userCount >>= (stereo? 2: 1);
785 ftotal = frameLeft;
786 utotal = userCount;
787 while (frameLeft) {
788 unsigned short c;
789 if (bal < 0) {
790 if (userCount == 0)
791 break;
792 if (get_user(data, up++))
793 return -EFAULT;
794 data ^= mask;
795 if (stereo) {
796 if (get_user(c, up++))
797 return -EFAULT;
798 data = (data << 16) + (c ^ mask);
799 } else
800 data = (data << 16) + data;
801 userCount--;
802 bal += hSpeed;
803 }
804 *p++ = data;
805 frameLeft--;
806 bal -= sSpeed;
807 }
808 expand_bal = bal;
809 expand_data = data;
810 *frameUsed += (ftotal - frameLeft) * 4;
811 utotal -= userCount;
812 return stereo? utotal * 4: utotal * 2;
813}
814
815static ssize_t cs4218_ct_s8_read(const u_char *userPtr, size_t userCount,
816 u_char frame[], ssize_t *frameUsed,
817 ssize_t frameLeft)
818{
819 ssize_t count, used;
820 short *p = (short *) &frame[*frameUsed];
821 int val, stereo = sound.soft.stereo;
822
823 frameLeft >>= 2;
824 if (stereo)
825 userCount >>= 1;
826 used = count = min(userCount, frameLeft);
827 while (count > 0) {
828 u_char data;
829
830 val = *p++;
831 data = val >> 8;
832 if (put_user(data, (u_char *)userPtr++))
833 return -EFAULT;
834 if (stereo) {
835 val = *p;
836 data = val >> 8;
837 if (put_user(data, (u_char *)userPtr++))
838 return -EFAULT;
839 }
840 p++;
841 count--;
842 }
843 *frameUsed += used * 4;
844 return stereo? used * 2: used;
845}
846
847
848static ssize_t cs4218_ct_u8_read(const u_char *userPtr, size_t userCount,
849 u_char frame[], ssize_t *frameUsed,
850 ssize_t frameLeft)
851{
852 ssize_t count, used;
853 short *p = (short *) &frame[*frameUsed];
854 int val, stereo = sound.soft.stereo;
855
856 frameLeft >>= 2;
857 if (stereo)
858 userCount >>= 1;
859 used = count = min(userCount, frameLeft);
860 while (count > 0) {
861 u_char data;
862
863 val = *p++;
864 data = (val >> 8) ^ 0x80;
865 if (put_user(data, (u_char *)userPtr++))
866 return -EFAULT;
867 if (stereo) {
868 val = *p;
869 data = (val >> 8) ^ 0x80;
870 if (put_user(data, (u_char *)userPtr++))
871 return -EFAULT;
872 }
873 p++;
874 count--;
875 }
876 *frameUsed += used * 4;
877 return stereo? used * 2: used;
878}
879
880
881static ssize_t cs4218_ct_s16_read(const u_char *userPtr, size_t userCount,
882 u_char frame[], ssize_t *frameUsed,
883 ssize_t frameLeft)
884{
885 ssize_t count, used;
886 int stereo = sound.soft.stereo;
887 short *fp = (short *) &frame[*frameUsed];
888
889 frameLeft >>= 2;
890 userCount >>= (stereo? 2: 1);
891 used = count = min(userCount, frameLeft);
892 if (!stereo) {
893 short *up = (short *) userPtr;
894 while (count > 0) {
895 short data;
896 data = *fp;
897 if (put_user(data, up++))
898 return -EFAULT;
899 fp+=2;
900 count--;
901 }
902 } else {
903 if (copy_to_user((u_char *)userPtr, fp, count * 4))
904 return -EFAULT;
905 }
906 *frameUsed += used * 4;
907 return stereo? used * 4: used * 2;
908}
909
910static ssize_t cs4218_ct_u16_read(const u_char *userPtr, size_t userCount,
911 u_char frame[], ssize_t *frameUsed,
912 ssize_t frameLeft)
913{
914 ssize_t count, used;
915 int mask = (sound.soft.format == AFMT_U16_LE? 0x0080: 0x8000);
916 int stereo = sound.soft.stereo;
917 short *fp = (short *) &frame[*frameUsed];
918 short *up = (short *) userPtr;
919
920 frameLeft >>= 2;
921 userCount >>= (stereo? 2: 1);
922 used = count = min(userCount, frameLeft);
923 while (count > 0) {
924 int data;
925
926 data = *fp++;
927 data ^= mask;
928 if (put_user(data, up++))
929 return -EFAULT;
930 if (stereo) {
931 data = *fp;
932 data ^= mask;
933 if (put_user(data, up++))
934 return -EFAULT;
935 }
936 fp++;
937 count--;
938 }
939 *frameUsed += used * 4;
940 return stereo? used * 4: used * 2;
941}
942
943static TRANS transCSNormal = {
944 cs4218_ct_law, cs4218_ct_law, cs4218_ct_s8, cs4218_ct_u8,
945 cs4218_ct_s16, cs4218_ct_u16, cs4218_ct_s16, cs4218_ct_u16
946};
947
948static TRANS transCSExpand = {
949 cs4218_ctx_law, cs4218_ctx_law, cs4218_ctx_s8, cs4218_ctx_u8,
950 cs4218_ctx_s16, cs4218_ctx_u16, cs4218_ctx_s16, cs4218_ctx_u16
951};
952
953static TRANS transCSNormalRead = {
954 NULL, NULL, cs4218_ct_s8_read, cs4218_ct_u8_read,
955 cs4218_ct_s16_read, cs4218_ct_u16_read,
956 cs4218_ct_s16_read, cs4218_ct_u16_read
957};
958
959/*** Low level stuff *********************************************************/
960
961static void *CS_Alloc(unsigned int size, gfp_t flags)
962{
963 int order;
964
965 size >>= 13;
966 for (order=0; order < 5; order++) {
967 if (size == 0)
968 break;
969 size >>= 1;
970 }
971 return (void *)__get_free_pages(flags, order);
972}
973
974static void CS_Free(void *ptr, unsigned int size)
975{
976 int order;
977
978 size >>= 13;
979 for (order=0; order < 5; order++) {
980 if (size == 0)
981 break;
982 size >>= 1;
983 }
984 free_pages((ulong)ptr, order);
985}
986
987static int __init CS_IrqInit(void)
988{
989 cpm_install_handler(CPMVEC_SMC2, cs4218_intr, NULL);
990 return 1;
991}
992
993#ifdef MODULE
994static void CS_IrqCleanup(void)
995{
996 volatile smc_t *sp;
997 volatile cpm8xx_t *cp;
998
999 /* First disable transmitter and receiver.
1000 */
1001 sp = &cpmp->cp_smc[1];
1002 sp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
1003
1004 /* And now shut down the SMC.
1005 */
1006 cp = cpmp; /* Get pointer to Communication Processor */
1007 cp->cp_cpcr = mk_cr_cmd(CPM_CR_CH_SMC2,
1008 CPM_CR_STOP_TX) | CPM_CR_FLG;
1009 while (cp->cp_cpcr & CPM_CR_FLG);
1010
1011 /* Release the interrupt handler.
1012 */
1013 cpm_free_handler(CPMVEC_SMC2);
1014
1015 kfree(beep_buf);
1016 kd_mksound = orig_mksound;
1017}
1018#endif /* MODULE */
1019
1020static void CS_Silence(void)
1021{
1022 volatile smc_t *sp;
1023
1024 /* Disable transmitter.
1025 */
1026 sp = &cpmp->cp_smc[1];
1027 sp->smc_smcmr &= ~SMCMR_TEN;
1028}
1029
1030/* Frequencies depend upon external oscillator. There are two
1031 * choices, 12.288 and 11.2896 MHz. The RPCG audio supports both through
1032 * and external control register selection bit.
1033 */
1034static int cs4218_freqs[] = {
1035 /* 12.288 11.2896 */
1036 48000, 44100,
1037 32000, 29400,
1038 24000, 22050,
1039 19200, 17640,
1040 16000, 14700,
1041 12000, 11025,
1042 9600, 8820,
1043 8000, 7350
1044};
1045
1046static void CS_Init(void)
1047{
1048 int i, tolerance;
1049
1050 switch (sound.soft.format) {
1051 case AFMT_S16_LE:
1052 case AFMT_U16_LE:
1053 sound.hard.format = AFMT_S16_LE;
1054 break;
1055 default:
1056 sound.hard.format = AFMT_S16_BE;
1057 break;
1058 }
1059 sound.hard.stereo = 1;
1060 sound.hard.size = 16;
1061
1062 /*
1063 * If we have a sample rate which is within catchRadius percent
1064 * of the requested value, we don't have to expand the samples.
1065 * Otherwise choose the next higher rate.
1066 */
1067 i = (sizeof(cs4218_freqs) / sizeof(int));
1068 do {
1069 tolerance = catchRadius * cs4218_freqs[--i] / 100;
1070 } while (sound.soft.speed > cs4218_freqs[i] + tolerance && i > 0);
1071 if (sound.soft.speed >= cs4218_freqs[i] - tolerance)
1072 sound.trans_write = &transCSNormal;
1073 else
1074 sound.trans_write = &transCSExpand;
1075 sound.trans_read = &transCSNormalRead;
1076 sound.hard.speed = cs4218_freqs[i];
1077 cs4218_rate_index = i;
1078
1079 /* The CS4218 has seven selectable clock dividers for the sample
1080 * clock. The HIOX then provides one of two external rates.
1081 * An even numbered frequency table index uses the high external
1082 * clock rate.
1083 */
1084 *(uint *)HIOX_CSR4_ADDR &= ~(HIOX_CSR4_AUDCLKHI | HIOX_CSR4_AUDCLKSEL);
1085 if ((i & 1) == 0)
1086 *(uint *)HIOX_CSR4_ADDR |= HIOX_CSR4_AUDCLKHI;
1087 i >>= 1;
1088 *(uint *)HIOX_CSR4_ADDR |= (i & HIOX_CSR4_AUDCLKSEL);
1089
1090 expand_bal = -sound.soft.speed;
1091}
1092
1093static int CS_SetFormat(int format)
1094{
1095 int size;
1096
1097 switch (format) {
1098 case AFMT_QUERY:
1099 return sound.soft.format;
1100 case AFMT_MU_LAW:
1101 case AFMT_A_LAW:
1102 case AFMT_U8:
1103 case AFMT_S8:
1104 size = 8;
1105 break;
1106 case AFMT_S16_BE:
1107 case AFMT_U16_BE:
1108 case AFMT_S16_LE:
1109 case AFMT_U16_LE:
1110 size = 16;
1111 break;
1112 default: /* :-) */
1113 printk(KERN_ERR "dmasound: unknown format 0x%x, using AFMT_U8\n",
1114 format);
1115 size = 8;
1116 format = AFMT_U8;
1117 }
1118
1119 sound.soft.format = format;
1120 sound.soft.size = size;
1121 if (sound.minDev == SND_DEV_DSP) {
1122 sound.dsp.format = format;
1123 sound.dsp.size = size;
1124 }
1125
1126 CS_Init();
1127
1128 return format;
1129}
1130
1131/* Volume is the amount of attenuation we tell the codec to impose
1132 * on the outputs. There are 32 levels, with 0 the "loudest".
1133 */
1134#define CS_VOLUME_TO_MASK(x) (31 - ((((x) - 1) * 31) / 99))
1135#define CS_MASK_TO_VOLUME(y) (100 - ((y) * 99 / 31))
1136
1137static int cs_get_volume(uint reg)
1138{
1139 int volume;
1140
1141 volume = CS_MASK_TO_VOLUME(CS_LATTEN_GET(reg));
1142 volume |= CS_MASK_TO_VOLUME(CS_RATTEN_GET(reg)) << 8;
1143 return volume;
1144}
1145
1146static int cs_volume_setter(int volume, int mute)
1147{
1148 uint tempctl;
1149
1150 if (mute && volume == 0) {
1151 tempctl = cs4218_control | CS_MUTE;
1152 } else {
1153 tempctl = cs4218_control & ~CS_MUTE;
1154 tempctl = tempctl & ~(CS_LATTEN | CS_RATTEN);
1155 tempctl |= CS_LATTEN_SET(CS_VOLUME_TO_MASK(volume & 0xff));
1156 tempctl |= CS_RATTEN_SET(CS_VOLUME_TO_MASK((volume >> 8) & 0xff));
1157 volume = cs_get_volume(tempctl);
1158 }
1159 if (tempctl != cs4218_control) {
1160 cs4218_ctl_write(tempctl);
1161 }
1162 return volume;
1163}
1164
1165
1166/* Gain has 16 steps from 0 to 15. These are in 1.5dB increments from
1167 * 0 (no gain) to 22.5 dB.
1168 */
1169#define CS_RECLEVEL_TO_GAIN(v) \
1170 ((v) < 0 ? 0 : (v) > 100 ? 15 : (v) * 3 / 20)
1171#define CS_GAIN_TO_RECLEVEL(v) (((v) * 20 + 2) / 3)
1172
1173static int cs_get_gain(uint reg)
1174{
1175 int gain;
1176
1177 gain = CS_GAIN_TO_RECLEVEL(CS_LGAIN_GET(reg));
1178 gain |= CS_GAIN_TO_RECLEVEL(CS_RGAIN_GET(reg)) << 8;
1179 return gain;
1180}
1181
1182static int cs_set_gain(int gain)
1183{
1184 uint tempctl;
1185
1186 tempctl = cs4218_control & ~(CS_LGAIN | CS_RGAIN);
1187 tempctl |= CS_LGAIN_SET(CS_RECLEVEL_TO_GAIN(gain & 0xff));
1188 tempctl |= CS_RGAIN_SET(CS_RECLEVEL_TO_GAIN((gain >> 8) & 0xff));
1189 gain = cs_get_gain(tempctl);
1190
1191 if (tempctl != cs4218_control) {
1192 cs4218_ctl_write(tempctl);
1193 }
1194 return gain;
1195}
1196
1197static int CS_SetVolume(int volume)
1198{
1199 return cs_volume_setter(volume, CS_MUTE);
1200}
1201
1202static void CS_Play(void)
1203{
1204 int i, count;
1205 unsigned long flags;
1206 volatile cbd_t *bdp;
1207 volatile cpm8xx_t *cp;
1208
1209 /* Protect buffer */
1210 spin_lock_irqsave(&cs4218_lock, flags);
1211#if 0
1212 if (awacs_beep_state) {
1213 /* sound takes precedence over beeps */
1214 out_le32(&awacs_txdma->control, (RUN|PAUSE|FLUSH|WAKE) << 16);
1215 out_le32(&awacs->control,
1216 (in_le32(&awacs->control) & ~0x1f00)
1217 | (awacs_rate_index << 8));
1218 out_le32(&awacs->byteswap, sound.hard.format != AFMT_S16_BE);
1219 out_le32(&awacs_txdma->cmdptr, virt_to_bus(&(awacs_tx_cmds[(sq.front+sq.active) % sq.max_count])));
1220
1221 beep_playing = 0;
1222 awacs_beep_state = 0;
1223 }
1224#endif
1225 i = sq.front + sq.active;
1226 if (i >= sq.max_count)
1227 i -= sq.max_count;
1228 while (sq.active < 2 && sq.active < sq.count) {
1229 count = (sq.count == sq.active + 1)?sq.rear_size:sq.block_size;
1230 if (count < sq.block_size && !sq.syncing)
1231 /* last block not yet filled, and we're not syncing. */
1232 break;
1233
1234 bdp = &tx_base[i];
1235 bdp->cbd_datlen = count;
1236
1237 flush_dcache_range((ulong)sound_buffers[i],
1238 (ulong)(sound_buffers[i] + count));
1239
1240 if (++i >= sq.max_count)
1241 i = 0;
1242
1243 if (sq.active == 0) {
1244 /* The SMC does not load its fifo until the first
1245 * TDM frame pulse, so the transmit data gets shifted
1246 * by one word. To compensate for this, we incorrectly
1247 * transmit the first buffer and shorten it by one
1248 * word. Subsequent buffers are then aligned properly.
1249 */
1250 bdp->cbd_datlen -= 2;
1251
1252 /* Start up the SMC Transmitter.
1253 */
1254 cp = cpmp;
1255 cp->cp_smc[1].smc_smcmr |= SMCMR_TEN;
1256 cp->cp_cpcr = mk_cr_cmd(CPM_CR_CH_SMC2,
1257 CPM_CR_RESTART_TX) | CPM_CR_FLG;
1258 while (cp->cp_cpcr & CPM_CR_FLG);
1259 }
1260
1261 /* Buffer is ready now.
1262 */
1263 bdp->cbd_sc |= BD_SC_READY;
1264
1265 ++sq.active;
1266 }
1267 spin_unlock_irqrestore(&cs4218_lock, flags);
1268}
1269
1270
1271static void CS_Record(void)
1272{
1273 unsigned long flags;
1274 volatile smc_t *sp;
1275
1276 if (read_sq.active)
1277 return;
1278
1279 /* Protect buffer */
1280 spin_lock_irqsave(&cs4218_lock, flags);
1281
1282 /* This is all we have to do......Just start it up.
1283 */
1284 sp = &cpmp->cp_smc[1];
1285 sp->smc_smcmr |= SMCMR_REN;
1286
1287 read_sq.active = 1;
1288
1289 spin_unlock_irqrestore(&cs4218_lock, flags);
1290}
1291
1292
1293static void
1294cs4218_tdm_tx_intr(void *devid)
1295{
1296 int i = sq.front;
1297 volatile cbd_t *bdp;
1298
1299 while (sq.active > 0) {
1300 bdp = &tx_base[i];
1301 if (bdp->cbd_sc & BD_SC_READY)
1302 break; /* this frame is still going */
1303 --sq.count;
1304 --sq.active;
1305 if (++i >= sq.max_count)
1306 i = 0;
1307 }
1308 if (i != sq.front)
1309 WAKE_UP(sq.action_queue);
1310 sq.front = i;
1311
1312 CS_Play();
1313
1314 if (!sq.active)
1315 WAKE_UP(sq.sync_queue);
1316}
1317
1318
1319static void
1320cs4218_tdm_rx_intr(void *devid)
1321{
1322
1323 /* We want to blow 'em off when shutting down.
1324 */
1325 if (read_sq.active == 0)
1326 return;
1327
1328 /* Check multiple buffers in case we were held off from
1329 * interrupt processing for a long time. Geeze, I really hope
1330 * this doesn't happen.
1331 */
1332 while ((rx_base[read_sq.rear].cbd_sc & BD_SC_EMPTY) == 0) {
1333
1334 /* Invalidate the data cache range for this buffer.
1335 */
1336 invalidate_dcache_range(
1337 (uint)(sound_read_buffers[read_sq.rear]),
1338 (uint)(sound_read_buffers[read_sq.rear] + read_sq.block_size));
1339
1340 /* Make buffer available again and move on.
1341 */
1342 rx_base[read_sq.rear].cbd_sc |= BD_SC_EMPTY;
1343 read_sq.rear++;
1344
1345 /* Wrap the buffer ring.
1346 */
1347 if (read_sq.rear >= read_sq.max_active)
1348 read_sq.rear = 0;
1349
1350 /* If we have caught up to the front buffer, bump it.
1351 * This will cause weird (but not fatal) results if the
1352 * read loop is currently using this buffer. The user is
1353 * behind in this case anyway, so weird things are going
1354 * to happen.
1355 */
1356 if (read_sq.rear == read_sq.front) {
1357 read_sq.front++;
1358 if (read_sq.front >= read_sq.max_active)
1359 read_sq.front = 0;
1360 }
1361 }
1362
1363 WAKE_UP(read_sq.action_queue);
1364}
1365
1366static void cs_nosound(unsigned long xx)
1367{
1368 unsigned long flags;
1369
1370 /* not sure if this is needed, since hardware command is #if 0'd */
1371 spin_lock_irqsave(&cs4218_lock, flags);
1372 if (beep_playing) {
1373#if 0
1374 st_le16(&beep_dbdma_cmd->command, DBDMA_STOP);
1375#endif
1376 beep_playing = 0;
1377 }
1378 spin_unlock_irqrestore(&cs4218_lock, flags);
1379}
1380
1381static DEFINE_TIMER(beep_timer, cs_nosound, 0, 0);
1382
1383static void cs_mksound(unsigned int hz, unsigned int ticks)
1384{
1385 unsigned long flags;
1386 int beep_speed = BEEP_SPEED;
1387 int srate = cs4218_freqs[beep_speed];
1388 int period, ncycles, nsamples;
1389 int i, j, f;
1390 short *p;
1391 static int beep_hz_cache;
1392 static int beep_nsamples_cache;
1393 static int beep_volume_cache;
1394
1395 if (hz <= srate / BEEP_BUFLEN || hz > srate / 2) {
1396#if 1
1397 /* this is a hack for broken X server code */
1398 hz = 750;
1399 ticks = 12;
1400#else
1401 /* cancel beep currently playing */
1402 awacs_nosound(0);
1403 return;
1404#endif
1405 }
1406 /* lock while modifying beep_timer */
1407 spin_lock_irqsave(&cs4218_lock, flags);
1408 del_timer(&beep_timer);
1409 if (ticks) {
1410 beep_timer.expires = jiffies + ticks;
1411 add_timer(&beep_timer);
1412 }
1413 if (beep_playing || sq.active || beep_buf == NULL) {
1414 spin_unlock_irqrestore(&cs4218_lock, flags);
1415 return; /* too hard, sorry :-( */
1416 }
1417 beep_playing = 1;
1418#if 0
1419 st_le16(&beep_dbdma_cmd->command, OUTPUT_MORE + BR_ALWAYS);
1420#endif
1421 spin_unlock_irqrestore(&cs4218_lock, flags);
1422
1423 if (hz == beep_hz_cache && beep_volume == beep_volume_cache) {
1424 nsamples = beep_nsamples_cache;
1425 } else {
1426 period = srate * 256 / hz; /* fixed point */
1427 ncycles = BEEP_BUFLEN * 256 / period;
1428 nsamples = (period * ncycles) >> 8;
1429 f = ncycles * 65536 / nsamples;
1430 j = 0;
1431 p = beep_buf;
1432 for (i = 0; i < nsamples; ++i, p += 2) {
1433 p[0] = p[1] = beep_wform[j >> 8] * beep_volume;
1434 j = (j + f) & 0xffff;
1435 }
1436 beep_hz_cache = hz;
1437 beep_volume_cache = beep_volume;
1438 beep_nsamples_cache = nsamples;
1439 }
1440
1441#if 0
1442 st_le16(&beep_dbdma_cmd->req_count, nsamples*4);
1443 st_le16(&beep_dbdma_cmd->xfer_status, 0);
1444 st_le32(&beep_dbdma_cmd->cmd_dep, virt_to_bus(beep_dbdma_cmd));
1445 st_le32(&beep_dbdma_cmd->phy_addr, virt_to_bus(beep_buf));
1446 awacs_beep_state = 1;
1447
1448 spin_lock_irqsave(&cs4218_lock, flags);
1449 if (beep_playing) { /* i.e. haven't been terminated already */
1450 out_le32(&awacs_txdma->control, (RUN|WAKE|FLUSH|PAUSE) << 16);
1451 out_le32(&awacs->control,
1452 (in_le32(&awacs->control) & ~0x1f00)
1453 | (beep_speed << 8));
1454 out_le32(&awacs->byteswap, 0);
1455 out_le32(&awacs_txdma->cmdptr, virt_to_bus(beep_dbdma_cmd));
1456 out_le32(&awacs_txdma->control, RUN | (RUN << 16));
1457 }
1458 spin_unlock_irqrestore(&cs4218_lock, flags);
1459#endif
1460}
1461
1462static MACHINE mach_cs4218 = {
1463 .owner = THIS_MODULE,
1464 .name = "HIOX CS4218",
1465 .name2 = "Built-in Sound",
1466 .dma_alloc = CS_Alloc,
1467 .dma_free = CS_Free,
1468 .irqinit = CS_IrqInit,
1469#ifdef MODULE
1470 .irqcleanup = CS_IrqCleanup,
1471#endif /* MODULE */
1472 .init = CS_Init,
1473 .silence = CS_Silence,
1474 .setFormat = CS_SetFormat,
1475 .setVolume = CS_SetVolume,
1476 .play = CS_Play
1477};
1478
1479
1480/*** Mid level stuff *********************************************************/
1481
1482
1483static void sound_silence(void)
1484{
1485 /* update hardware settings one more */
1486 (*sound.mach.init)();
1487
1488 (*sound.mach.silence)();
1489}
1490
1491
1492static void sound_init(void)
1493{
1494 (*sound.mach.init)();
1495}
1496
1497
1498static int sound_set_format(int format)
1499{
1500 return(*sound.mach.setFormat)(format);
1501}
1502
1503
1504static int sound_set_speed(int speed)
1505{
1506 if (speed < 0)
1507 return(sound.soft.speed);
1508
1509 sound.soft.speed = speed;
1510 (*sound.mach.init)();
1511 if (sound.minDev == SND_DEV_DSP)
1512 sound.dsp.speed = sound.soft.speed;
1513
1514 return(sound.soft.speed);
1515}
1516
1517
1518static int sound_set_stereo(int stereo)
1519{
1520 if (stereo < 0)
1521 return(sound.soft.stereo);
1522
1523 stereo = !!stereo; /* should be 0 or 1 now */
1524
1525 sound.soft.stereo = stereo;
1526 if (sound.minDev == SND_DEV_DSP)
1527 sound.dsp.stereo = stereo;
1528 (*sound.mach.init)();
1529
1530 return(stereo);
1531}
1532
1533
1534static int sound_set_volume(int volume)
1535{
1536 return(*sound.mach.setVolume)(volume);
1537}
1538
1539static ssize_t sound_copy_translate(const u_char *userPtr,
1540 size_t userCount,
1541 u_char frame[], ssize_t *frameUsed,
1542 ssize_t frameLeft)
1543{
1544 ssize_t (*ct_func)(const u_char *, size_t, u_char *, ssize_t *, ssize_t) = NULL;
1545
1546 switch (sound.soft.format) {
1547 case AFMT_MU_LAW:
1548 ct_func = sound.trans_write->ct_ulaw;
1549 break;
1550 case AFMT_A_LAW:
1551 ct_func = sound.trans_write->ct_alaw;
1552 break;
1553 case AFMT_S8:
1554 ct_func = sound.trans_write->ct_s8;
1555 break;
1556 case AFMT_U8:
1557 ct_func = sound.trans_write->ct_u8;
1558 break;
1559 case AFMT_S16_BE:
1560 ct_func = sound.trans_write->ct_s16be;
1561 break;
1562 case AFMT_U16_BE:
1563 ct_func = sound.trans_write->ct_u16be;
1564 break;
1565 case AFMT_S16_LE:
1566 ct_func = sound.trans_write->ct_s16le;
1567 break;
1568 case AFMT_U16_LE:
1569 ct_func = sound.trans_write->ct_u16le;
1570 break;
1571 }
1572 if (ct_func)
1573 return ct_func(userPtr, userCount, frame, frameUsed, frameLeft);
1574 else
1575 return 0;
1576}
1577
1578static ssize_t sound_copy_translate_read(const u_char *userPtr,
1579 size_t userCount,
1580 u_char frame[], ssize_t *frameUsed,
1581 ssize_t frameLeft)
1582{
1583 ssize_t (*ct_func)(const u_char *, size_t, u_char *, ssize_t *, ssize_t) = NULL;
1584
1585 switch (sound.soft.format) {
1586 case AFMT_MU_LAW:
1587 ct_func = sound.trans_read->ct_ulaw;
1588 break;
1589 case AFMT_A_LAW:
1590 ct_func = sound.trans_read->ct_alaw;
1591 break;
1592 case AFMT_S8:
1593 ct_func = sound.trans_read->ct_s8;
1594 break;
1595 case AFMT_U8:
1596 ct_func = sound.trans_read->ct_u8;
1597 break;
1598 case AFMT_S16_BE:
1599 ct_func = sound.trans_read->ct_s16be;
1600 break;
1601 case AFMT_U16_BE:
1602 ct_func = sound.trans_read->ct_u16be;
1603 break;
1604 case AFMT_S16_LE:
1605 ct_func = sound.trans_read->ct_s16le;
1606 break;
1607 case AFMT_U16_LE:
1608 ct_func = sound.trans_read->ct_u16le;
1609 break;
1610 }
1611 if (ct_func)
1612 return ct_func(userPtr, userCount, frame, frameUsed, frameLeft);
1613 else
1614 return 0;
1615}
1616
1617
1618/*
1619 * /dev/mixer abstraction
1620 */
1621
1622static int mixer_open(struct inode *inode, struct file *file)
1623{
1624 mixer.busy = 1;
1625 return nonseekable_open(inode, file);
1626}
1627
1628
1629static int mixer_release(struct inode *inode, struct file *file)
1630{
1631 mixer.busy = 0;
1632 return 0;
1633}
1634
1635
1636static int mixer_ioctl(struct inode *inode, struct file *file, u_int cmd,
1637 u_long arg)
1638{
1639 int data;
1640 uint tmpcs;
1641
1642 if (_SIOC_DIR(cmd) & _SIOC_WRITE)
1643 mixer.modify_counter++;
1644 if (cmd == OSS_GETVERSION)
1645 return IOCTL_OUT(arg, SOUND_VERSION);
1646 switch (cmd) {
1647 case SOUND_MIXER_INFO: {
1648 mixer_info info;
1649 strlcpy(info.id, "CS4218_TDM", sizeof(info.id));
1650 strlcpy(info.name, "CS4218_TDM", sizeof(info.name));
1651 info.name[sizeof(info.name)-1] = 0;
1652 info.modify_counter = mixer.modify_counter;
1653 if (copy_to_user((int *)arg, &info, sizeof(info)))
1654 return -EFAULT;
1655 return 0;
1656 }
1657 case SOUND_MIXER_READ_DEVMASK:
1658 data = SOUND_MASK_VOLUME | SOUND_MASK_LINE
1659 | SOUND_MASK_MIC | SOUND_MASK_RECLEV
1660 | SOUND_MASK_ALTPCM;
1661 return IOCTL_OUT(arg, data);
1662 case SOUND_MIXER_READ_RECMASK:
1663 data = SOUND_MASK_LINE | SOUND_MASK_MIC;
1664 return IOCTL_OUT(arg, data);
1665 case SOUND_MIXER_READ_RECSRC:
1666 if (cs4218_control & CS_DO1)
1667 data = SOUND_MASK_LINE;
1668 else
1669 data = SOUND_MASK_MIC;
1670 return IOCTL_OUT(arg, data);
1671 case SOUND_MIXER_WRITE_RECSRC:
1672 IOCTL_IN(arg, data);
1673 data &= (SOUND_MASK_LINE | SOUND_MASK_MIC);
1674 if (data & SOUND_MASK_LINE)
1675 tmpcs = cs4218_control |
1676 (CS_ISL | CS_ISR | CS_DO1);
1677 if (data & SOUND_MASK_MIC)
1678 tmpcs = cs4218_control &
1679 ~(CS_ISL | CS_ISR | CS_DO1);
1680 if (tmpcs != cs4218_control)
1681 cs4218_ctl_write(tmpcs);
1682 return IOCTL_OUT(arg, data);
1683 case SOUND_MIXER_READ_STEREODEVS:
1684 data = SOUND_MASK_VOLUME | SOUND_MASK_RECLEV;
1685 return IOCTL_OUT(arg, data);
1686 case SOUND_MIXER_READ_CAPS:
1687 return IOCTL_OUT(arg, 0);
1688 case SOUND_MIXER_READ_VOLUME:
1689 data = (cs4218_control & CS_MUTE)? 0:
1690 cs_get_volume(cs4218_control);
1691 return IOCTL_OUT(arg, data);
1692 case SOUND_MIXER_WRITE_VOLUME:
1693 IOCTL_IN(arg, data);
1694 return IOCTL_OUT(arg, sound_set_volume(data));
1695 case SOUND_MIXER_WRITE_ALTPCM: /* really bell volume */
1696 IOCTL_IN(arg, data);
1697 beep_volume = data & 0xff;
1698 /* fall through */
1699 case SOUND_MIXER_READ_ALTPCM:
1700 return IOCTL_OUT(arg, beep_volume);
1701 case SOUND_MIXER_WRITE_RECLEV:
1702 IOCTL_IN(arg, data);
1703 data = cs_set_gain(data);
1704 return IOCTL_OUT(arg, data);
1705 case SOUND_MIXER_READ_RECLEV:
1706 data = cs_get_gain(cs4218_control);
1707 return IOCTL_OUT(arg, data);
1708 }
1709
1710 return -EINVAL;
1711}
1712
1713
1714static const struct file_operations mixer_fops =
1715{
1716 .owner = THIS_MODULE,
1717 .llseek = sound_lseek,
1718 .ioctl = mixer_ioctl,
1719 .open = mixer_open,
1720 .release = mixer_release,
1721};
1722
1723
1724static void __init mixer_init(void)
1725{
1726 mixer_unit = register_sound_mixer(&mixer_fops, -1);
1727 if (mixer_unit < 0)
1728 return;
1729
1730 mixer.busy = 0;
1731 sound.treble = 0;
1732 sound.bass = 0;
1733
1734 /* Set Line input, no gain, no attenuation.
1735 */
1736 cs4218_control = CS_ISL | CS_ISR | CS_DO1;
1737 cs4218_control |= CS_LGAIN_SET(0) | CS_RGAIN_SET(0);
1738 cs4218_control |= CS_LATTEN_SET(0) | CS_RATTEN_SET(0);
1739 cs4218_ctl_write(cs4218_control);
1740}
1741
1742
1743/*
1744 * Sound queue stuff, the heart of the driver
1745 */
1746
1747
1748static int sq_allocate_buffers(void)
1749{
1750 int i;
1751
1752 if (sound_buffers)
1753 return 0;
1754 sound_buffers = kmalloc (numBufs * sizeof(char *), GFP_KERNEL);
1755 if (!sound_buffers)
1756 return -ENOMEM;
1757 for (i = 0; i < numBufs; i++) {
1758 sound_buffers[i] = sound.mach.dma_alloc (bufSize << 10, GFP_KERNEL);
1759 if (!sound_buffers[i]) {
1760 while (i--)
1761 sound.mach.dma_free (sound_buffers[i], bufSize << 10);
1762 kfree (sound_buffers);
1763 sound_buffers = 0;
1764 return -ENOMEM;
1765 }
1766 }
1767 return 0;
1768}
1769
1770
1771static void sq_release_buffers(void)
1772{
1773 int i;
1774
1775 if (sound_buffers) {
1776 for (i = 0; i < numBufs; i++)
1777 sound.mach.dma_free (sound_buffers[i], bufSize << 10);
1778 kfree (sound_buffers);
1779 sound_buffers = 0;
1780 }
1781}
1782
1783
1784static int sq_allocate_read_buffers(void)
1785{
1786 int i;
1787
1788 if (sound_read_buffers)
1789 return 0;
1790 sound_read_buffers = kmalloc(numReadBufs * sizeof(char *), GFP_KERNEL);
1791 if (!sound_read_buffers)
1792 return -ENOMEM;
1793 for (i = 0; i < numBufs; i++) {
1794 sound_read_buffers[i] = sound.mach.dma_alloc (readbufSize<<10,
1795 GFP_KERNEL);
1796 if (!sound_read_buffers[i]) {
1797 while (i--)
1798 sound.mach.dma_free (sound_read_buffers[i],
1799 readbufSize << 10);
1800 kfree (sound_read_buffers);
1801 sound_read_buffers = 0;
1802 return -ENOMEM;
1803 }
1804 }
1805 return 0;
1806}
1807
1808static void sq_release_read_buffers(void)
1809{
1810 int i;
1811
1812 if (sound_read_buffers) {
1813 cpmp->cp_smc[1].smc_smcmr &= ~SMCMR_REN;
1814 for (i = 0; i < numReadBufs; i++)
1815 sound.mach.dma_free (sound_read_buffers[i],
1816 bufSize << 10);
1817 kfree (sound_read_buffers);
1818 sound_read_buffers = 0;
1819 }
1820}
1821
1822
1823static void sq_setup(int numBufs, int bufSize, char **write_buffers)
1824{
1825 int i;
1826 volatile cbd_t *bdp;
1827 volatile cpm8xx_t *cp;
1828 volatile smc_t *sp;
1829
1830 /* Make sure the SMC transmit is shut down.
1831 */
1832 cp = cpmp;
1833 sp = &cpmp->cp_smc[1];
1834 sp->smc_smcmr &= ~SMCMR_TEN;
1835
1836 sq.max_count = numBufs;
1837 sq.max_active = numBufs;
1838 sq.block_size = bufSize;
1839 sq.buffers = write_buffers;
1840
1841 sq.front = sq.count = 0;
1842 sq.rear = -1;
1843 sq.syncing = 0;
1844 sq.active = 0;
1845
1846 bdp = tx_base;
1847 for (i=0; i<numBufs; i++) {
1848 bdp->cbd_bufaddr = virt_to_bus(write_buffers[i]);
1849 bdp++;
1850 }
1851
1852 /* This causes the SMC to sync up with the first buffer again.
1853 */
1854 cp->cp_cpcr = mk_cr_cmd(CPM_CR_CH_SMC2, CPM_CR_INIT_TX) | CPM_CR_FLG;
1855 while (cp->cp_cpcr & CPM_CR_FLG);
1856}
1857
1858static void read_sq_setup(int numBufs, int bufSize, char **read_buffers)
1859{
1860 int i;
1861 volatile cbd_t *bdp;
1862 volatile cpm8xx_t *cp;
1863 volatile smc_t *sp;
1864
1865 /* Make sure the SMC receive is shut down.
1866 */
1867 cp = cpmp;
1868 sp = &cpmp->cp_smc[1];
1869 sp->smc_smcmr &= ~SMCMR_REN;
1870
1871 read_sq.max_count = numBufs;
1872 read_sq.max_active = numBufs;
1873 read_sq.block_size = bufSize;
1874 read_sq.buffers = read_buffers;
1875
1876 read_sq.front = read_sq.count = 0;
1877 read_sq.rear = 0;
1878 read_sq.rear_size = 0;
1879 read_sq.syncing = 0;
1880 read_sq.active = 0;
1881
1882 bdp = rx_base;
1883 for (i=0; i<numReadBufs; i++) {
1884 bdp->cbd_bufaddr = virt_to_bus(read_buffers[i]);
1885 bdp->cbd_datlen = read_sq.block_size;
1886 bdp++;
1887 }
1888
1889 /* This causes the SMC to sync up with the first buffer again.
1890 */
1891 cp->cp_cpcr = mk_cr_cmd(CPM_CR_CH_SMC2, CPM_CR_INIT_RX) | CPM_CR_FLG;
1892 while (cp->cp_cpcr & CPM_CR_FLG);
1893}
1894
1895
1896static void sq_play(void)
1897{
1898 (*sound.mach.play)();
1899}
1900
1901
1902/* ++TeSche: radically changed this one too */
1903
1904static ssize_t sq_write(struct file *file, const char *src, size_t uLeft,
1905 loff_t *ppos)
1906{
1907 ssize_t uWritten = 0;
1908 u_char *dest;
1909 ssize_t uUsed, bUsed, bLeft;
1910
1911 /* ++TeSche: Is something like this necessary?
1912 * Hey, that's an honest question! Or does any other part of the
1913 * filesystem already checks this situation? I really don't know.
1914 */
1915 if (uLeft == 0)
1916 return 0;
1917
1918 /* The interrupt doesn't start to play the last, incomplete frame.
1919 * Thus we can append to it without disabling the interrupts! (Note
1920 * also that sq.rear isn't affected by the interrupt.)
1921 */
1922
1923 if (sq.count > 0 && (bLeft = sq.block_size-sq.rear_size) > 0) {
1924 dest = sq_block_address(sq.rear);
1925 bUsed = sq.rear_size;
1926 uUsed = sound_copy_translate(src, uLeft, dest, &bUsed, bLeft);
1927 if (uUsed <= 0)
1928 return uUsed;
1929 src += uUsed;
1930 uWritten += uUsed;
1931 uLeft -= uUsed;
1932 sq.rear_size = bUsed;
1933 }
1934
1935 do {
1936 while (sq.count == sq.max_active) {
1937 sq_play();
1938 if (NON_BLOCKING(sq.open_mode))
1939 return uWritten > 0 ? uWritten : -EAGAIN;
1940 SLEEP(sq.action_queue);
1941 if (SIGNAL_RECEIVED)
1942 return uWritten > 0 ? uWritten : -EINTR;
1943 }
1944
1945 /* Here, we can avoid disabling the interrupt by first
1946 * copying and translating the data, and then updating
1947 * the sq variables. Until this is done, the interrupt
1948 * won't see the new frame and we can work on it
1949 * undisturbed.
1950 */
1951
1952 dest = sq_block_address((sq.rear+1) % sq.max_count);
1953 bUsed = 0;
1954 bLeft = sq.block_size;
1955 uUsed = sound_copy_translate(src, uLeft, dest, &bUsed, bLeft);
1956 if (uUsed <= 0)
1957 break;
1958 src += uUsed;
1959 uWritten += uUsed;
1960 uLeft -= uUsed;
1961 if (bUsed) {
1962 sq.rear = (sq.rear+1) % sq.max_count;
1963 sq.rear_size = bUsed;
1964 sq.count++;
1965 }
1966 } while (bUsed); /* uUsed may have been 0 */
1967
1968 sq_play();
1969
1970 return uUsed < 0? uUsed: uWritten;
1971}
1972
1973
1974/***********/
1975
1976/* Here is how the values are used for reading.
1977 * The value 'active' simply indicates the DMA is running. This is
1978 * done so the driver semantics are DMA starts when the first read is
1979 * posted. The value 'front' indicates the buffer we should next
1980 * send to the user. The value 'rear' indicates the buffer the DMA is
1981 * currently filling. When 'front' == 'rear' the buffer "ring" is
1982 * empty (we always have an empty available). The 'rear_size' is used
1983 * to track partial offsets into the current buffer. Right now, I just keep
1984 * The DMA running. If the reader can't keep up, the interrupt tosses
1985 * the oldest buffer. We could also shut down the DMA in this case.
1986 */
1987static ssize_t sq_read(struct file *file, char *dst, size_t uLeft,
1988 loff_t *ppos)
1989{
1990
1991 ssize_t uRead, bLeft, bUsed, uUsed;
1992
1993 if (uLeft == 0)
1994 return 0;
1995
1996 if (!read_sq.active)
1997 CS_Record(); /* Kick off the record process. */
1998
1999 uRead = 0;
2000
2001 /* Move what the user requests, depending upon other options.
2002 */
2003 while (uLeft > 0) {
2004
2005 /* When front == rear, the DMA is not done yet.
2006 */
2007 while (read_sq.front == read_sq.rear) {
2008 if (NON_BLOCKING(read_sq.open_mode)) {
2009 return uRead > 0 ? uRead : -EAGAIN;
2010 }
2011 SLEEP(read_sq.action_queue);
2012 if (SIGNAL_RECEIVED)
2013 return uRead > 0 ? uRead : -EINTR;
2014 }
2015
2016 /* The amount we move is either what is left in the
2017 * current buffer or what the user wants.
2018 */
2019 bLeft = read_sq.block_size - read_sq.rear_size;
2020 bUsed = read_sq.rear_size;
2021 uUsed = sound_copy_translate_read(dst, uLeft,
2022 read_sq.buffers[read_sq.front], &bUsed, bLeft);
2023 if (uUsed <= 0)
2024 return uUsed;
2025 dst += uUsed;
2026 uRead += uUsed;
2027 uLeft -= uUsed;
2028 read_sq.rear_size += bUsed;
2029 if (read_sq.rear_size >= read_sq.block_size) {
2030 read_sq.rear_size = 0;
2031 read_sq.front++;
2032 if (read_sq.front >= read_sq.max_active)
2033 read_sq.front = 0;
2034 }
2035 }
2036 return uRead;
2037}
2038
2039static int sq_open(struct inode *inode, struct file *file)
2040{
2041 int rc = 0;
2042
2043 if (file->f_mode & FMODE_WRITE) {
2044 if (sq.busy) {
2045 rc = -EBUSY;
2046 if (NON_BLOCKING(file->f_flags))
2047 goto err_out;
2048 rc = -EINTR;
2049 while (sq.busy) {
2050 SLEEP(sq.open_queue);
2051 if (SIGNAL_RECEIVED)
2052 goto err_out;
2053 }
2054 }
2055 sq.busy = 1; /* Let's play spot-the-race-condition */
2056
2057 if (sq_allocate_buffers()) goto err_out_nobusy;
2058
2059 sq_setup(numBufs, bufSize<<10,sound_buffers);
2060 sq.open_mode = file->f_mode;
2061 }
2062
2063
2064 if (file->f_mode & FMODE_READ) {
2065 if (read_sq.busy) {
2066 rc = -EBUSY;
2067 if (NON_BLOCKING(file->f_flags))
2068 goto err_out;
2069 rc = -EINTR;
2070 while (read_sq.busy) {
2071 SLEEP(read_sq.open_queue);
2072 if (SIGNAL_RECEIVED)
2073 goto err_out;
2074 }
2075 rc = 0;
2076 }
2077 read_sq.busy = 1;
2078 if (sq_allocate_read_buffers()) goto err_out_nobusy;
2079
2080 read_sq_setup(numReadBufs,readbufSize<<10, sound_read_buffers);
2081 read_sq.open_mode = file->f_mode;
2082 }
2083
2084 /* Start up the 4218 by:
2085 * Reset.
2086 * Enable, unreset.
2087 */
2088 *((volatile uint *)HIOX_CSR4_ADDR) &= ~HIOX_CSR4_RSTAUDIO;
2089 eieio();
2090 *((volatile uint *)HIOX_CSR4_ADDR) |= HIOX_CSR4_ENAUDIO;
2091 mdelay(50);
2092 *((volatile uint *)HIOX_CSR4_ADDR) |= HIOX_CSR4_RSTAUDIO;
2093
2094 /* We need to send the current control word in case someone
2095 * opened /dev/mixer and changed things while we were shut
2096 * down. Chances are good the initialization that follows
2097 * would have done this, but it is still possible it wouldn't.
2098 */
2099 cs4218_ctl_write(cs4218_control);
2100
2101 sound.minDev = iminor(inode) & 0x0f;
2102 sound.soft = sound.dsp;
2103 sound.hard = sound.dsp;
2104 sound_init();
2105 if ((iminor(inode) & 0x0f) == SND_DEV_AUDIO) {
2106 sound_set_speed(8000);
2107 sound_set_stereo(0);
2108 sound_set_format(AFMT_MU_LAW);
2109 }
2110
2111 return nonseekable_open(inode, file);
2112
2113err_out_nobusy:
2114 if (file->f_mode & FMODE_WRITE) {
2115 sq.busy = 0;
2116 WAKE_UP(sq.open_queue);
2117 }
2118 if (file->f_mode & FMODE_READ) {
2119 read_sq.busy = 0;
2120 WAKE_UP(read_sq.open_queue);
2121 }
2122err_out:
2123 return rc;
2124}
2125
2126
2127static void sq_reset(void)
2128{
2129 sound_silence();
2130 sq.active = 0;
2131 sq.count = 0;
2132 sq.front = (sq.rear+1) % sq.max_count;
2133#if 0
2134 init_tdm_buffers();
2135#endif
2136}
2137
2138
2139static int sq_fsync(struct file *filp, struct dentry *dentry)
2140{
2141 int rc = 0;
2142
2143 sq.syncing = 1;
2144 sq_play(); /* there may be an incomplete frame waiting */
2145
2146 while (sq.active) {
2147 SLEEP(sq.sync_queue);
2148 if (SIGNAL_RECEIVED) {
2149 /* While waiting for audio output to drain, an
2150 * interrupt occurred. Stop audio output immediately
2151 * and clear the queue. */
2152 sq_reset();
2153 rc = -EINTR;
2154 break;
2155 }
2156 }
2157
2158 sq.syncing = 0;
2159 return rc;
2160}
2161
2162static int sq_release(struct inode *inode, struct file *file)
2163{
2164 int rc = 0;
2165
2166 if (sq.busy)
2167 rc = sq_fsync(file, file->f_path.dentry);
2168 sound.soft = sound.dsp;
2169 sound.hard = sound.dsp;
2170 sound_silence();
2171
2172 sq_release_read_buffers();
2173 sq_release_buffers();
2174
2175 if (file->f_mode & FMODE_READ) {
2176 read_sq.busy = 0;
2177 WAKE_UP(read_sq.open_queue);
2178 }
2179
2180 if (file->f_mode & FMODE_WRITE) {
2181 sq.busy = 0;
2182 WAKE_UP(sq.open_queue);
2183 }
2184
2185 /* Shut down the SMC.
2186 */
2187 cpmp->cp_smc[1].smc_smcmr &= ~(SMCMR_TEN | SMCMR_REN);
2188
2189 /* Shut down the codec.
2190 */
2191 *((volatile uint *)HIOX_CSR4_ADDR) |= HIOX_CSR4_RSTAUDIO;
2192 eieio();
2193 *((volatile uint *)HIOX_CSR4_ADDR) &= ~HIOX_CSR4_ENAUDIO;
2194
2195 /* Wake up a process waiting for the queue being released.
2196 * Note: There may be several processes waiting for a call
2197 * to open() returning. */
2198
2199 return rc;
2200}
2201
2202
2203static int sq_ioctl(struct inode *inode, struct file *file, u_int cmd,
2204 u_long arg)
2205{
2206 u_long fmt;
2207 int data;
2208#if 0
2209 int size, nbufs;
2210#else
2211 int size;
2212#endif
2213
2214 switch (cmd) {
2215 case SNDCTL_DSP_RESET:
2216 sq_reset();
2217 return 0;
2218 case SNDCTL_DSP_POST:
2219 case SNDCTL_DSP_SYNC:
2220 return sq_fsync(file, file->f_path.dentry);
2221
2222 /* ++TeSche: before changing any of these it's
2223 * probably wise to wait until sound playing has
2224 * settled down. */
2225 case SNDCTL_DSP_SPEED:
2226 sq_fsync(file, file->f_path.dentry);
2227 IOCTL_IN(arg, data);
2228 return IOCTL_OUT(arg, sound_set_speed(data));
2229 case SNDCTL_DSP_STEREO:
2230 sq_fsync(file, file->f_path.dentry);
2231 IOCTL_IN(arg, data);
2232 return IOCTL_OUT(arg, sound_set_stereo(data));
2233 case SOUND_PCM_WRITE_CHANNELS:
2234 sq_fsync(file, file->f_path.dentry);
2235 IOCTL_IN(arg, data);
2236 return IOCTL_OUT(arg, sound_set_stereo(data-1)+1);
2237 case SNDCTL_DSP_SETFMT:
2238 sq_fsync(file, file->f_path.dentry);
2239 IOCTL_IN(arg, data);
2240 return IOCTL_OUT(arg, sound_set_format(data));
2241 case SNDCTL_DSP_GETFMTS:
2242 fmt = 0;
2243 if (sound.trans_write) {
2244 if (sound.trans_write->ct_ulaw)
2245 fmt |= AFMT_MU_LAW;
2246 if (sound.trans_write->ct_alaw)
2247 fmt |= AFMT_A_LAW;
2248 if (sound.trans_write->ct_s8)
2249 fmt |= AFMT_S8;
2250 if (sound.trans_write->ct_u8)
2251 fmt |= AFMT_U8;
2252 if (sound.trans_write->ct_s16be)
2253 fmt |= AFMT_S16_BE;
2254 if (sound.trans_write->ct_u16be)
2255 fmt |= AFMT_U16_BE;
2256 if (sound.trans_write->ct_s16le)
2257 fmt |= AFMT_S16_LE;
2258 if (sound.trans_write->ct_u16le)
2259 fmt |= AFMT_U16_LE;
2260 }
2261 return IOCTL_OUT(arg, fmt);
2262 case SNDCTL_DSP_GETBLKSIZE:
2263 size = sq.block_size
2264 * sound.soft.size * (sound.soft.stereo + 1)
2265 / (sound.hard.size * (sound.hard.stereo + 1));
2266 return IOCTL_OUT(arg, size);
2267 case SNDCTL_DSP_SUBDIVIDE:
2268 break;
2269#if 0 /* Sorry can't do this at the moment. The CPM allocated buffers
2270 * long ago that can't be changed.
2271 */
2272 case SNDCTL_DSP_SETFRAGMENT:
2273 if (sq.count || sq.active || sq.syncing)
2274 return -EINVAL;
2275 IOCTL_IN(arg, size);
2276 nbufs = size >> 16;
2277 if (nbufs < 2 || nbufs > numBufs)
2278 nbufs = numBufs;
2279 size &= 0xffff;
2280 if (size >= 8 && size <= 30) {
2281 size = 1 << size;
2282 size *= sound.hard.size * (sound.hard.stereo + 1);
2283 size /= sound.soft.size * (sound.soft.stereo + 1);
2284 if (size > (bufSize << 10))
2285 size = bufSize << 10;
2286 } else
2287 size = bufSize << 10;
2288 sq_setup(numBufs, size, sound_buffers);
2289 sq.max_active = nbufs;
2290 return 0;
2291#endif
2292
2293 default:
2294 return mixer_ioctl(inode, file, cmd, arg);
2295 }
2296 return -EINVAL;
2297}
2298
2299
2300
2301static const struct file_operations sq_fops =
2302{
2303 .owner = THIS_MODULE,
2304 .llseek = sound_lseek,
2305 .read = sq_read, /* sq_read */
2306 .write = sq_write,
2307 .ioctl = sq_ioctl,
2308 .open = sq_open,
2309 .release = sq_release,
2310};
2311
2312
2313static void __init sq_init(void)
2314{
2315 sq_unit = register_sound_dsp(&sq_fops, -1);
2316 if (sq_unit < 0)
2317 return;
2318
2319 init_waitqueue_head(&sq.action_queue);
2320 init_waitqueue_head(&sq.open_queue);
2321 init_waitqueue_head(&sq.sync_queue);
2322 init_waitqueue_head(&read_sq.action_queue);
2323 init_waitqueue_head(&read_sq.open_queue);
2324 init_waitqueue_head(&read_sq.sync_queue);
2325
2326 sq.busy = 0;
2327 read_sq.busy = 0;
2328
2329 /* whatever you like as startup mode for /dev/dsp,
2330 * (/dev/audio hasn't got a startup mode). note that
2331 * once changed a new open() will *not* restore these!
2332 */
2333 sound.dsp.format = AFMT_S16_BE;
2334 sound.dsp.stereo = 1;
2335 sound.dsp.size = 16;
2336
2337 /* set minimum rate possible without expanding */
2338 sound.dsp.speed = 8000;
2339
2340 /* before the first open to /dev/dsp this wouldn't be set */
2341 sound.soft = sound.dsp;
2342 sound.hard = sound.dsp;
2343
2344 sound_silence();
2345}
2346
2347/*
2348 * /dev/sndstat
2349 */
2350
2351
2352/* state.buf should not overflow! */
2353
2354static int state_open(struct inode *inode, struct file *file)
2355{
2356 char *buffer = state.buf, *mach = "", cs4218_buf[50];
2357 int len = 0;
2358
2359 if (state.busy)
2360 return -EBUSY;
2361
2362 state.ptr = 0;
2363 state.busy = 1;
2364
2365 sprintf(cs4218_buf, "Crystal CS4218 on TDM, ");
2366 mach = cs4218_buf;
2367
2368 len += sprintf(buffer+len, "%sDMA sound driver:\n", mach);
2369
2370 len += sprintf(buffer+len, "\tsound.format = 0x%x", sound.soft.format);
2371 switch (sound.soft.format) {
2372 case AFMT_MU_LAW:
2373 len += sprintf(buffer+len, " (mu-law)");
2374 break;
2375 case AFMT_A_LAW:
2376 len += sprintf(buffer+len, " (A-law)");
2377 break;
2378 case AFMT_U8:
2379 len += sprintf(buffer+len, " (unsigned 8 bit)");
2380 break;
2381 case AFMT_S8:
2382 len += sprintf(buffer+len, " (signed 8 bit)");
2383 break;
2384 case AFMT_S16_BE:
2385 len += sprintf(buffer+len, " (signed 16 bit big)");
2386 break;
2387 case AFMT_U16_BE:
2388 len += sprintf(buffer+len, " (unsigned 16 bit big)");
2389 break;
2390 case AFMT_S16_LE:
2391 len += sprintf(buffer+len, " (signed 16 bit little)");
2392 break;
2393 case AFMT_U16_LE:
2394 len += sprintf(buffer+len, " (unsigned 16 bit little)");
2395 break;
2396 }
2397 len += sprintf(buffer+len, "\n");
2398 len += sprintf(buffer+len, "\tsound.speed = %dHz (phys. %dHz)\n",
2399 sound.soft.speed, sound.hard.speed);
2400 len += sprintf(buffer+len, "\tsound.stereo = 0x%x (%s)\n",
2401 sound.soft.stereo, sound.soft.stereo ? "stereo" : "mono");
2402 len += sprintf(buffer+len, "\tsq.block_size = %d sq.max_count = %d"
2403 " sq.max_active = %d\n",
2404 sq.block_size, sq.max_count, sq.max_active);
2405 len += sprintf(buffer+len, "\tsq.count = %d sq.rear_size = %d\n", sq.count,
2406 sq.rear_size);
2407 len += sprintf(buffer+len, "\tsq.active = %d sq.syncing = %d\n",
2408 sq.active, sq.syncing);
2409 state.len = len;
2410 return nonseekable_open(inode, file);
2411}
2412
2413
2414static int state_release(struct inode *inode, struct file *file)
2415{
2416 state.busy = 0;
2417 return 0;
2418}
2419
2420
2421static ssize_t state_read(struct file *file, char *buf, size_t count,
2422 loff_t *ppos)
2423{
2424 int n = state.len - state.ptr;
2425 if (n > count)
2426 n = count;
2427 if (n <= 0)
2428 return 0;
2429 if (copy_to_user(buf, &state.buf[state.ptr], n))
2430 return -EFAULT;
2431 state.ptr += n;
2432 return n;
2433}
2434
2435
2436static const struct file_operations state_fops =
2437{
2438 .owner = THIS_MODULE,
2439 .llseek = sound_lseek,
2440 .read = state_read,
2441 .open = state_open,
2442 .release = state_release,
2443};
2444
2445
2446static void __init state_init(void)
2447{
2448 state_unit = register_sound_special(&state_fops, SND_DEV_STATUS);
2449 if (state_unit < 0)
2450 return;
2451 state.busy = 0;
2452}
2453
2454
2455/*** Common stuff ********************************************************/
2456
2457static long long sound_lseek(struct file *file, long long offset, int orig)
2458{
2459 return -ESPIPE;
2460}
2461
2462
2463/*** Config & Setup **********************************************************/
2464
2465
2466int __init tdm8xx_sound_init(void)
2467{
2468 int i, has_sound;
2469 uint dp_offset;
2470 volatile uint *sirp;
2471 volatile cbd_t *bdp;
2472 volatile cpm8xx_t *cp;
2473 volatile smc_t *sp;
2474 volatile smc_uart_t *up;
2475 volatile immap_t *immap;
2476
2477 has_sound = 0;
2478
2479 /* Program the SI/TSA to use TDMa, connected to SMC2, for 4 bytes.
2480 */
2481 cp = cpmp; /* Get pointer to Communication Processor */
2482 immap = (immap_t *)IMAP_ADDR; /* and to internal registers */
2483
2484 /* Set all TDMa control bits to zero. This enables most features
2485 * we want.
2486 */
2487 cp->cp_simode &= ~0x00000fff;
2488
2489 /* Enable common receive/transmit clock pins, use IDL format.
2490 * Sync on falling edge, transmit rising clock, receive falling
2491 * clock, delay 1 bit on both Tx and Rx. Common Tx/Rx clocks and
2492 * sync.
2493 * Connect SMC2 to TSA.
2494 */
2495 cp->cp_simode |= 0x80000141;
2496
2497 /* Configure port A pins for TDMa operation.
2498 * The RPX-Lite (MPC850/823) loses SMC2 when TDM is used.
2499 */
2500 immap->im_ioport.iop_papar |= 0x01c0; /* Enable TDMa functions */
2501 immap->im_ioport.iop_padir |= 0x00c0; /* Enable TDMa Tx/Rx */
2502 immap->im_ioport.iop_padir &= ~0x0100; /* Enable L1RCLKa */
2503
2504 immap->im_ioport.iop_pcpar |= 0x0800; /* Enable L1RSYNCa */
2505 immap->im_ioport.iop_pcdir &= ~0x0800;
2506
2507 /* Initialize the SI TDM routing table. We use TDMa only.
2508 * The receive table and transmit table each have only one
2509 * entry, to capture/send four bytes after each frame pulse.
2510 * The 16-bit ram entry is 0000 0001 1000 1111. (SMC2)
2511 */
2512 cp->cp_sigmr = 0;
2513 sirp = (uint *)cp->cp_siram;
2514
2515 *sirp = 0x018f0000; /* Receive entry */
2516 sirp += 64;
2517 *sirp = 0x018f0000; /* Tramsmit entry */
2518
2519 /* Enable single TDMa routing.
2520 */
2521 cp->cp_sigmr = 0x04;
2522
2523 /* Initialize the SMC for transparent operation.
2524 */
2525 sp = &cpmp->cp_smc[1];
2526 up = (smc_uart_t *)&cp->cp_dparam[PROFF_SMC2];
2527
2528 /* We need to allocate a transmit and receive buffer
2529 * descriptors from dual port ram.
2530 */
2531 dp_addr = cpm_dpalloc(sizeof(cbd_t) * numReadBufs, 8);
2532
2533 /* Set the physical address of the host memory
2534 * buffers in the buffer descriptors, and the
2535 * virtual address for us to work with.
2536 */
2537 bdp = (cbd_t *)&cp->cp_dpmem[dp_addr];
2538 up->smc_rbase = dp_offset;
2539 rx_cur = rx_base = (cbd_t *)bdp;
2540
2541 for (i=0; i<(numReadBufs-1); i++) {
2542 bdp->cbd_bufaddr = 0;
2543 bdp->cbd_datlen = 0;
2544 bdp->cbd_sc = BD_SC_EMPTY | BD_SC_INTRPT;
2545 bdp++;
2546 }
2547 bdp->cbd_bufaddr = 0;
2548 bdp->cbd_datlen = 0;
2549 bdp->cbd_sc = BD_SC_WRAP | BD_SC_EMPTY | BD_SC_INTRPT;
2550
2551 /* Now, do the same for the transmit buffers.
2552 */
2553 dp_offset = cpm_dpalloc(sizeof(cbd_t) * numBufs, 8);
2554
2555 bdp = (cbd_t *)&cp->cp_dpmem[dp_addr];
2556 up->smc_tbase = dp_offset;
2557 tx_cur = tx_base = (cbd_t *)bdp;
2558
2559 for (i=0; i<(numBufs-1); i++) {
2560 bdp->cbd_bufaddr = 0;
2561 bdp->cbd_datlen = 0;
2562 bdp->cbd_sc = BD_SC_INTRPT;
2563 bdp++;
2564 }
2565 bdp->cbd_bufaddr = 0;
2566 bdp->cbd_datlen = 0;
2567 bdp->cbd_sc = (BD_SC_WRAP | BD_SC_INTRPT);
2568
2569 /* Set transparent SMC mode.
2570 * A few things are specific to our application. The codec interface
2571 * is MSB first, hence the REVD selection. The CD/CTS pulse are
2572 * used by the TSA to indicate the frame start to the SMC.
2573 */
2574 up->smc_rfcr = SCC_EB;
2575 up->smc_tfcr = SCC_EB;
2576 up->smc_mrblr = readbufSize * 1024;
2577
2578 /* Set 16-bit reversed data, transparent mode.
2579 */
2580 sp->smc_smcmr = smcr_mk_clen(15) |
2581 SMCMR_SM_TRANS | SMCMR_REVD | SMCMR_BS;
2582
2583 /* Enable and clear events.
2584 * Because of FIFO delays, all we need is the receive interrupt
2585 * and we can process both the current receive and current
2586 * transmit interrupt within a few microseconds of the transmit.
2587 */
2588 sp->smc_smce = 0xff;
2589 sp->smc_smcm = SMCM_TXE | SMCM_TX | SMCM_RX;
2590
2591 /* Send the CPM an initialize command.
2592 */
2593 cp->cp_cpcr = mk_cr_cmd(CPM_CR_CH_SMC2,
2594 CPM_CR_INIT_TRX) | CPM_CR_FLG;
2595 while (cp->cp_cpcr & CPM_CR_FLG);
2596
2597 sound.mach = mach_cs4218;
2598 has_sound = 1;
2599
2600 /* Initialize beep stuff */
2601 orig_mksound = kd_mksound;
2602 kd_mksound = cs_mksound;
2603 beep_buf = kmalloc(BEEP_BUFLEN * 4, GFP_KERNEL);
2604 if (beep_buf == NULL)
2605 printk(KERN_WARNING "dmasound: no memory for "
2606 "beep buffer\n");
2607
2608 if (!has_sound)
2609 return -ENODEV;
2610
2611 /* Initialize the software SPI.
2612 */
2613 sw_spi_init();
2614
2615 /* Set up sound queue, /dev/audio and /dev/dsp. */
2616
2617 /* Set default settings. */
2618 sq_init();
2619
2620 /* Set up /dev/sndstat. */
2621 state_init();
2622
2623 /* Set up /dev/mixer. */
2624 mixer_init();
2625
2626 if (!sound.mach.irqinit()) {
2627 printk(KERN_ERR "DMA sound driver: Interrupt initialization failed\n");
2628 return -ENODEV;
2629 }
2630#ifdef MODULE
2631 irq_installed = 1;
2632#endif
2633
2634 printk(KERN_INFO "DMA sound driver installed, using %d buffers of %dk.\n",
2635 numBufs, bufSize);
2636
2637 return 0;
2638}
2639
2640/* Due to FIFOs and bit delays, the transmit interrupt occurs a few
2641 * microseconds ahead of the receive interrupt.
2642 * When we get an interrupt, we service the transmit first, then
2643 * check for a receive to prevent the overhead of returning through
2644 * the interrupt handler only to get back here right away during
2645 * full duplex operation.
2646 */
2647static void
2648cs4218_intr(void *dev_id)
2649{
2650 volatile smc_t *sp;
2651 volatile cpm8xx_t *cp;
2652
2653 sp = &cpmp->cp_smc[1];
2654
2655 if (sp->smc_smce & SCCM_TX) {
2656 sp->smc_smce = SCCM_TX;
2657 cs4218_tdm_tx_intr((void *)sp);
2658 }
2659
2660 if (sp->smc_smce & SCCM_RX) {
2661 sp->smc_smce = SCCM_RX;
2662 cs4218_tdm_rx_intr((void *)sp);
2663 }
2664
2665 if (sp->smc_smce & SCCM_TXE) {
2666 /* Transmit underrun. This happens with the application
2667 * didn't keep up sending buffers. We tell the SMC to
2668 * restart, which will cause it to poll the current (next)
2669 * BD. If the user supplied data since this occurred,
2670 * we just start running again. If they didn't, the SMC
2671 * will poll the descriptor until data is placed there.
2672 */
2673 sp->smc_smce = SCCM_TXE;
2674 cp = cpmp; /* Get pointer to Communication Processor */
2675 cp->cp_cpcr = mk_cr_cmd(CPM_CR_CH_SMC2,
2676 CPM_CR_RESTART_TX) | CPM_CR_FLG;
2677 while (cp->cp_cpcr & CPM_CR_FLG);
2678 }
2679}
2680
2681
2682#define MAXARGS 8 /* Should be sufficient for now */
2683
2684void __init dmasound_setup(char *str, int *ints)
2685{
2686 /* check the bootstrap parameter for "dmasound=" */
2687
2688 switch (ints[0]) {
2689 case 3:
2690 if ((ints[3] < 0) || (ints[3] > MAX_CATCH_RADIUS))
2691 printk("dmasound_setup: invalid catch radius, using default = %d\n", catchRadius);
2692 else
2693 catchRadius = ints[3];
2694 /* fall through */
2695 case 2:
2696 if (ints[1] < MIN_BUFFERS)
2697 printk("dmasound_setup: invalid number of buffers, using default = %d\n", numBufs);
2698 else
2699 numBufs = ints[1];
2700 if (ints[2] < MIN_BUFSIZE || ints[2] > MAX_BUFSIZE)
2701 printk("dmasound_setup: invalid buffer size, using default = %d\n", bufSize);
2702 else
2703 bufSize = ints[2];
2704 break;
2705 case 0:
2706 break;
2707 default:
2708 printk("dmasound_setup: invalid number of arguments\n");
2709 }
2710}
2711
2712/* Software SPI functions.
2713 * These are on Port B.
2714 */
2715#define PB_SPICLK ((uint)0x00000002)
2716#define PB_SPIMOSI ((uint)0x00000004)
2717#define PB_SPIMISO ((uint)0x00000008)
2718
2719static
2720void sw_spi_init(void)
2721{
2722 volatile cpm8xx_t *cp;
2723 volatile uint *hcsr4;
2724
2725 hcsr4 = (volatile uint *)HIOX_CSR4_ADDR;
2726 cp = cpmp; /* Get pointer to Communication Processor */
2727
2728 *hcsr4 &= ~HIOX_CSR4_AUDSPISEL; /* Disable SPI select */
2729
2730 /* Make these Port B signals general purpose I/O.
2731 * First, make sure the clock is low.
2732 */
2733 cp->cp_pbdat &= ~PB_SPICLK;
2734 cp->cp_pbpar &= ~(PB_SPICLK | PB_SPIMOSI | PB_SPIMISO);
2735
2736 /* Clock and Master Output are outputs.
2737 */
2738 cp->cp_pbdir |= (PB_SPICLK | PB_SPIMOSI);
2739
2740 /* Master Input.
2741 */
2742 cp->cp_pbdir &= ~PB_SPIMISO;
2743
2744}
2745
2746/* Write the CS4218 control word out the SPI port. While the
2747 * the control word is going out, the status word is arriving.
2748 */
2749static
2750uint cs4218_ctl_write(uint ctlreg)
2751{
2752 uint status;
2753
2754 sw_spi_io((u_char *)&ctlreg, (u_char *)&status, 4);
2755
2756 /* Shadow the control register.....I guess we could do
2757 * the same for the status, but for now we just return it
2758 * and let the caller decide.
2759 */
2760 cs4218_control = ctlreg;
2761 return status;
2762}
2763
2764static
2765void sw_spi_io(u_char *obuf, u_char *ibuf, uint bcnt)
2766{
2767 int bits, i;
2768 u_char outbyte, inbyte;
2769 volatile cpm8xx_t *cp;
2770 volatile uint *hcsr4;
2771
2772 hcsr4 = (volatile uint *)HIOX_CSR4_ADDR;
2773 cp = cpmp; /* Get pointer to Communication Processor */
2774
2775 /* The timing on the bus is pretty slow. Code inefficiency
2776 * and eieio() is our friend here :-).
2777 */
2778 cp->cp_pbdat &= ~PB_SPICLK;
2779 *hcsr4 |= HIOX_CSR4_AUDSPISEL; /* Enable SPI select */
2780 eieio();
2781
2782 /* Clock in/out the bytes. Data is valid on the falling edge
2783 * of the clock. Data is MSB first.
2784 */
2785 for (i=0; i<bcnt; i++) {
2786 outbyte = *obuf++;
2787 inbyte = 0;
2788 for (bits=0; bits<8; bits++) {
2789 eieio();
2790 cp->cp_pbdat |= PB_SPICLK;
2791 eieio();
2792 if (outbyte & 0x80)
2793 cp->cp_pbdat |= PB_SPIMOSI;
2794 else
2795 cp->cp_pbdat &= ~PB_SPIMOSI;
2796 eieio();
2797 cp->cp_pbdat &= ~PB_SPICLK;
2798 eieio();
2799 outbyte <<= 1;
2800 inbyte <<= 1;
2801 if (cp->cp_pbdat & PB_SPIMISO)
2802 inbyte |= 1;
2803 }
2804 *ibuf++ = inbyte;
2805 }
2806
2807 *hcsr4 &= ~HIOX_CSR4_AUDSPISEL; /* Disable SPI select */
2808 eieio();
2809}
2810
2811void cleanup_module(void)
2812{
2813 if (irq_installed) {
2814 sound_silence();
2815#ifdef MODULE
2816 sound.mach.irqcleanup();
2817#endif
2818 }
2819
2820 sq_release_read_buffers();
2821 sq_release_buffers();
2822
2823 if (mixer_unit >= 0)
2824 unregister_sound_mixer(mixer_unit);
2825 if (state_unit >= 0)
2826 unregister_sound_special(state_unit);
2827 if (sq_unit >= 0)
2828 unregister_sound_dsp(sq_unit);
2829}
2830
2831module_init(tdm8xx_sound_init);
2832module_exit(cleanup_module);
2833
diff --git a/arch/ppc/boot/common/misc-common.c b/arch/ppc/boot/common/misc-common.c
index 8e1fccd96fc0..9589969cec72 100644
--- a/arch/ppc/boot/common/misc-common.c
+++ b/arch/ppc/boot/common/misc-common.c
@@ -57,7 +57,8 @@ unsigned char *ISA_io = NULL;
57 57
58#if defined(CONFIG_SERIAL_CPM_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) \ 58#if defined(CONFIG_SERIAL_CPM_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) \
59 || defined(CONFIG_SERIAL_MPC52xx_CONSOLE) \ 59 || defined(CONFIG_SERIAL_MPC52xx_CONSOLE) \
60 || defined(CONFIG_SERIAL_MPSC_CONSOLE) 60 || defined(CONFIG_SERIAL_MPSC_CONSOLE) \
61 || defined(CONFIG_SERIAL_UARTLITE_CONSOLE)
61extern unsigned long com_port; 62extern unsigned long com_port;
62 63
63extern int serial_tstc(unsigned long com_port); 64extern int serial_tstc(unsigned long com_port);
@@ -80,7 +81,8 @@ int tstc(void)
80{ 81{
81#if defined(CONFIG_SERIAL_CPM_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) \ 82#if defined(CONFIG_SERIAL_CPM_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) \
82 || defined(CONFIG_SERIAL_MPC52xx_CONSOLE) \ 83 || defined(CONFIG_SERIAL_MPC52xx_CONSOLE) \
83 || defined(CONFIG_SERIAL_MPSC_CONSOLE) 84 || defined(CONFIG_SERIAL_MPSC_CONSOLE) \
85 || defined(CONFIG_SERIAL_UARTLITE_CONSOLE)
84 if(keyb_present) 86 if(keyb_present)
85 return (CRT_tstc() || serial_tstc(com_port)); 87 return (CRT_tstc() || serial_tstc(com_port));
86 else 88 else
@@ -95,7 +97,8 @@ int getc(void)
95 while (1) { 97 while (1) {
96#if defined(CONFIG_SERIAL_CPM_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) \ 98#if defined(CONFIG_SERIAL_CPM_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) \
97 || defined(CONFIG_SERIAL_MPC52xx_CONSOLE) \ 99 || defined(CONFIG_SERIAL_MPC52xx_CONSOLE) \
98 || defined(CONFIG_SERIAL_MPSC_CONSOLE) 100 || defined(CONFIG_SERIAL_MPSC_CONSOLE) \
101 || defined(CONFIG_SERIAL_UARTLITE_CONSOLE)
99 if (serial_tstc(com_port)) 102 if (serial_tstc(com_port))
100 return (serial_getc(com_port)); 103 return (serial_getc(com_port));
101#endif /* serial console */ 104#endif /* serial console */
@@ -112,7 +115,8 @@ putc(const char c)
112 115
113#if defined(CONFIG_SERIAL_CPM_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) \ 116#if defined(CONFIG_SERIAL_CPM_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) \
114 || defined(CONFIG_SERIAL_MPC52xx_CONSOLE) \ 117 || defined(CONFIG_SERIAL_MPC52xx_CONSOLE) \
115 || defined(CONFIG_SERIAL_MPSC_CONSOLE) 118 || defined(CONFIG_SERIAL_MPSC_CONSOLE) \
119 || defined(CONFIG_SERIAL_UARTLITE_CONSOLE)
116 serial_putc(com_port, c); 120 serial_putc(com_port, c);
117 if ( c == '\n' ) 121 if ( c == '\n' )
118 serial_putc(com_port, '\r'); 122 serial_putc(com_port, '\r');
@@ -161,7 +165,8 @@ void puts(const char *s)
161 while ( ( c = *s++ ) != '\0' ) { 165 while ( ( c = *s++ ) != '\0' ) {
162#if defined(CONFIG_SERIAL_CPM_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) \ 166#if defined(CONFIG_SERIAL_CPM_CONSOLE) || defined(CONFIG_SERIAL_8250_CONSOLE) \
163 || defined(CONFIG_SERIAL_MPC52xx_CONSOLE) \ 167 || defined(CONFIG_SERIAL_MPC52xx_CONSOLE) \
164 || defined(CONFIG_SERIAL_MPSC_CONSOLE) 168 || defined(CONFIG_SERIAL_MPSC_CONSOLE) \
169 || defined(CONFIG_SERIAL_UARTLITE_CONSOLE)
165 serial_putc(com_port, c); 170 serial_putc(com_port, c);
166 if ( c == '\n' ) serial_putc(com_port, '\r'); 171 if ( c == '\n' ) serial_putc(com_port, '\r');
167#endif /* serial console */ 172#endif /* serial console */
diff --git a/arch/ppc/boot/simple/Makefile b/arch/ppc/boot/simple/Makefile
index bcfb6cde70c4..5b877792d14f 100644
--- a/arch/ppc/boot/simple/Makefile
+++ b/arch/ppc/boot/simple/Makefile
@@ -201,6 +201,7 @@ boot-$(CONFIG_8260) += m8260_tty.o
201endif 201endif
202boot-$(CONFIG_SERIAL_MPC52xx_CONSOLE) += mpc52xx_tty.o 202boot-$(CONFIG_SERIAL_MPC52xx_CONSOLE) += mpc52xx_tty.o
203boot-$(CONFIG_SERIAL_MPSC_CONSOLE) += mv64x60_tty.o 203boot-$(CONFIG_SERIAL_MPSC_CONSOLE) += mv64x60_tty.o
204boot-$(CONFIG_SERIAL_UARTLITE_CONSOLE) += uartlite_tty.o
204 205
205LIBS := $(common)/lib.a $(bootlib)/lib.a 206LIBS := $(common)/lib.a $(bootlib)/lib.a
206ifeq ($(CONFIG_PPC_PREP),y) 207ifeq ($(CONFIG_PPC_PREP),y)
diff --git a/arch/ppc/boot/simple/uartlite_tty.c b/arch/ppc/boot/simple/uartlite_tty.c
new file mode 100644
index 000000000000..0eae1eab38d4
--- /dev/null
+++ b/arch/ppc/boot/simple/uartlite_tty.c
@@ -0,0 +1,37 @@
1/*
2 * Xilinx UARTLITE bootloader driver
3 *
4 * Copyright (c) 2007 Secret Lab Technologies Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/types.h>
13#include <asm/serial.h>
14#include <asm/io.h>
15#include <platforms/4xx/xparameters/xparameters.h>
16
17#define UARTLITE_BASEADDR ((void*)(XPAR_UARTLITE_0_BASEADDR))
18
19void
20serial_putc(unsigned long com_port, unsigned char c)
21{
22 while ((in_be32(UARTLITE_BASEADDR + 0x8) & 0x08) != 0); /* spin */
23 out_be32(UARTLITE_BASEADDR + 0x4, c);
24}
25
26unsigned char
27serial_getc(unsigned long com_port)
28{
29 while ((in_be32(UARTLITE_BASEADDR + 0x8) & 0x01) == 0); /* spin */
30 return in_be32(UARTLITE_BASEADDR);
31}
32
33int
34serial_tstc(unsigned long com_port)
35{
36 return ((in_be32(UARTLITE_BASEADDR + 0x8) & 0x01) != 0);
37}
diff --git a/arch/ppc/kernel/asm-offsets.c b/arch/ppc/kernel/asm-offsets.c
index 1f91eca2f3d7..c5850a272650 100644
--- a/arch/ppc/kernel/asm-offsets.c
+++ b/arch/ppc/kernel/asm-offsets.c
@@ -40,7 +40,6 @@ main(void)
40 DEFINE(PTRACE, offsetof(struct task_struct, ptrace)); 40 DEFINE(PTRACE, offsetof(struct task_struct, ptrace));
41 DEFINE(KSP, offsetof(struct thread_struct, ksp)); 41 DEFINE(KSP, offsetof(struct thread_struct, ksp));
42 DEFINE(PGDIR, offsetof(struct thread_struct, pgdir)); 42 DEFINE(PGDIR, offsetof(struct thread_struct, pgdir));
43 DEFINE(LAST_SYSCALL, offsetof(struct thread_struct, last_syscall));
44 DEFINE(PT_REGS, offsetof(struct thread_struct, regs)); 43 DEFINE(PT_REGS, offsetof(struct thread_struct, regs));
45 DEFINE(THREAD_FPEXC_MODE, offsetof(struct thread_struct, fpexc_mode)); 44 DEFINE(THREAD_FPEXC_MODE, offsetof(struct thread_struct, fpexc_mode));
46 DEFINE(THREAD_FPR0, offsetof(struct thread_struct, fpr[0])); 45 DEFINE(THREAD_FPR0, offsetof(struct thread_struct, fpr[0]));
diff --git a/arch/ppc/kernel/entry.S b/arch/ppc/kernel/entry.S
index a9d455369dc6..ab64256110bd 100644
--- a/arch/ppc/kernel/entry.S
+++ b/arch/ppc/kernel/entry.S
@@ -191,7 +191,6 @@ stack_ovf:
1910: 1910:
192 192
193_GLOBAL(DoSyscall) 193_GLOBAL(DoSyscall)
194 stw r0,THREAD+LAST_SYSCALL(r2)
195 stw r3,ORIG_GPR3(r1) 194 stw r3,ORIG_GPR3(r1)
196 li r12,0 195 li r12,0
197 stw r12,RESULT(r1) 196 stw r12,RESULT(r1)
diff --git a/arch/ppc/platforms/4xx/Kconfig b/arch/ppc/platforms/4xx/Kconfig
index 705ae56016f0..76551b679030 100644
--- a/arch/ppc/platforms/4xx/Kconfig
+++ b/arch/ppc/platforms/4xx/Kconfig
@@ -29,6 +29,7 @@ config CPCI405
29 29
30config EP405 30config EP405
31 bool "EP405/EP405PC" 31 bool "EP405/EP405PC"
32 select EMBEDDEDBOOT
32 help 33 help
33 This option enables support for the EP405/EP405PC boards. 34 This option enables support for the EP405/EP405PC boards.
34 35
@@ -54,11 +55,15 @@ config WALNUT
54 55
55config XILINX_ML300 56config XILINX_ML300
56 bool "Xilinx-ML300" 57 bool "Xilinx-ML300"
58 select XILINX_VIRTEX_II_PRO
59 select EMBEDDEDBOOT
57 help 60 help
58 This option enables support for the Xilinx ML300 evaluation board. 61 This option enables support for the Xilinx ML300 evaluation board.
59 62
60config XILINX_ML403 63config XILINX_ML403
61 bool "Xilinx-ML403" 64 bool "Xilinx-ML403"
65 select XILINX_VIRTEX_4_FX
66 select EMBEDDEDBOOT
62 help 67 help
63 This option enables support for the Xilinx ML403 evaluation board. 68 This option enables support for the Xilinx ML403 evaluation board.
64endchoice 69endchoice
@@ -215,18 +220,14 @@ config 405GPR
215 220
216config XILINX_VIRTEX_II_PRO 221config XILINX_VIRTEX_II_PRO
217 bool 222 bool
218 depends on XILINX_ML300 223 select XILINX_VIRTEX
219 default y
220 224
221config XILINX_VIRTEX_4_FX 225config XILINX_VIRTEX_4_FX
222 bool 226 bool
223 depends on XILINX_ML403 227 select XILINX_VIRTEX
224 default y
225 228
226config XILINX_VIRTEX 229config XILINX_VIRTEX
227 bool 230 bool
228 depends on XILINX_VIRTEX_II_PRO || XILINX_VIRTEX_4_FX
229 default y
230 231
231config STB03xxx 232config STB03xxx
232 bool 233 bool
@@ -235,8 +236,6 @@ config STB03xxx
235 236
236config EMBEDDEDBOOT 237config EMBEDDEDBOOT
237 bool 238 bool
238 depends on EP405 || XILINX_ML300 || XILINX_ML403
239 default y
240 239
241config IBM_OPENBIOS 240config IBM_OPENBIOS
242 bool 241 bool
diff --git a/arch/ppc/platforms/4xx/Makefile b/arch/ppc/platforms/4xx/Makefile
index fa6610bccaf9..723ad7985cc6 100644
--- a/arch/ppc/platforms/4xx/Makefile
+++ b/arch/ppc/platforms/4xx/Makefile
@@ -28,5 +28,4 @@ obj-$(CONFIG_440SP) += ibm440sp.o
28obj-$(CONFIG_440SPE) += ppc440spe.o 28obj-$(CONFIG_440SPE) += ppc440spe.o
29obj-$(CONFIG_405EP) += ibm405ep.o 29obj-$(CONFIG_405EP) += ibm405ep.o
30obj-$(CONFIG_405GPR) += ibm405gpr.o 30obj-$(CONFIG_405GPR) += ibm405gpr.o
31obj-$(CONFIG_XILINX_VIRTEX) += virtex.o
32 31
diff --git a/arch/ppc/platforms/4xx/ocotea.c b/arch/ppc/platforms/4xx/ocotea.c
index 84e999d9a7bb..5e994e146ba8 100644
--- a/arch/ppc/platforms/4xx/ocotea.c
+++ b/arch/ppc/platforms/4xx/ocotea.c
@@ -178,7 +178,7 @@ ocotea_setup_pcix(void)
178 /* Setup 2GB PCI->PLB inbound memory window at 0, enable MSIs */ 178 /* Setup 2GB PCI->PLB inbound memory window at 0, enable MSIs */
179 PCIX_WRITEL(0x00000000, PCIX0_PIM0LAH); 179 PCIX_WRITEL(0x00000000, PCIX0_PIM0LAH);
180 PCIX_WRITEL(0x00000000, PCIX0_PIM0LAL); 180 PCIX_WRITEL(0x00000000, PCIX0_PIM0LAL);
181 PCIX_WRITEL(0xe0000007, PCIX0_PIM0SA); 181 PCIX_WRITEL(0x80000007, PCIX0_PIM0SA);
182 182
183 eieio(); 183 eieio();
184} 184}
@@ -289,7 +289,7 @@ ocotea_setup_arch(void)
289 * from FPGA, because it can be changed by on-board switches 289 * from FPGA, because it can be changed by on-board switches
290 * --ebs 290 * --ebs
291 */ 291 */
292 ibm440gx_get_clocks(&clocks, 33333333, 6 * 1843200); 292 ibm440gx_get_clocks(&clocks, 33300000, 6 * 1843200);
293 ocp_sys_info.opb_bus_freq = clocks.opb; 293 ocp_sys_info.opb_bus_freq = clocks.opb;
294 294
295 /* Setup TODC access */ 295 /* Setup TODC access */
diff --git a/arch/ppc/platforms/4xx/taishan.c b/arch/ppc/platforms/4xx/taishan.c
index bb0253eef45a..5d9af8ddb155 100644
--- a/arch/ppc/platforms/4xx/taishan.c
+++ b/arch/ppc/platforms/4xx/taishan.c
@@ -235,7 +235,7 @@ taishan_setup_pcix(void)
235 /* Setup 2GB PCI->PLB inbound memory window at 0, enable MSIs */ 235 /* Setup 2GB PCI->PLB inbound memory window at 0, enable MSIs */
236 PCIX_WRITEL(0x00000000, PCIX0_PIM0LAH); 236 PCIX_WRITEL(0x00000000, PCIX0_PIM0LAH);
237 PCIX_WRITEL(0x00000000, PCIX0_PIM0LAL); 237 PCIX_WRITEL(0x00000000, PCIX0_PIM0LAL);
238 PCIX_WRITEL(0xe0000007, PCIX0_PIM0SA); 238 PCIX_WRITEL(0x80000007, PCIX0_PIM0SA);
239 PCIX_WRITEL(0xffffffff, PCIX0_PIM0SAH); 239 PCIX_WRITEL(0xffffffff, PCIX0_PIM0SAH);
240 240
241 iounmap(pcix_reg_base); 241 iounmap(pcix_reg_base);
diff --git a/arch/ppc/platforms/4xx/virtex.c b/arch/ppc/platforms/4xx/virtex.c
deleted file mode 100644
index 133a83147199..000000000000
--- a/arch/ppc/platforms/4xx/virtex.c
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * Virtex-II Pro & Virtex-4 FX common infrastructure
3 *
4 * Maintainer: Grant Likely <grant.likely@secretlab.ca>
5 *
6 * Copyright 2005 Secret Lab Technologies Ltd.
7 * Copyright 2005 General Dynamics Canada Ltd.
8 * Copyright 2005 Freescale Semiconductor Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 */
15
16#include <linux/init.h>
17#include <linux/module.h>
18#include <linux/device.h>
19#include <linux/serial_8250.h>
20#include <asm/ppc_sys.h>
21#include <platforms/4xx/virtex.h>
22#include <platforms/4xx/xparameters/xparameters.h>
23
24#define XPAR_UART(num) { \
25 .mapbase = XPAR_UARTNS550_##num##_BASEADDR + 3, \
26 .irq = XPAR_INTC_0_UARTNS550_##num##_VEC_ID, \
27 .iotype = UPIO_MEM, \
28 .uartclk = XPAR_UARTNS550_##num##_CLOCK_FREQ_HZ, \
29 .flags = UPF_BOOT_AUTOCONF, \
30 .regshift = 2, \
31 }
32
33struct plat_serial8250_port serial_platform_data[] = {
34#ifdef XPAR_UARTNS550_0_BASEADDR
35 XPAR_UART(0),
36#endif
37#ifdef XPAR_UARTNS550_1_BASEADDR
38 XPAR_UART(1),
39#endif
40#ifdef XPAR_UARTNS550_2_BASEADDR
41 XPAR_UART(2),
42#endif
43#ifdef XPAR_UARTNS550_3_BASEADDR
44 XPAR_UART(3),
45#endif
46 { }, /* terminated by empty record */
47};
48
49struct platform_device ppc_sys_platform_devices[] = {
50 [VIRTEX_UART] = {
51 .name = "serial8250",
52 .id = 0,
53 .dev.platform_data = serial_platform_data,
54 },
55};
56
diff --git a/arch/ppc/platforms/4xx/virtex.h b/arch/ppc/platforms/4xx/virtex.h
index c14325dfd7b1..738280420be5 100644
--- a/arch/ppc/platforms/4xx/virtex.h
+++ b/arch/ppc/platforms/4xx/virtex.h
@@ -1,35 +1,35 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/virtex.h 2 * Basic Virtex platform defines, included by <asm/ibm4xx.h>
3 * 3 *
4 * Include file that defines the Xilinx Virtex-II Pro processor 4 * 2005-2007 (c) Secret Lab Technologies Ltd.
5 * 2002-2004 (c) MontaVista Software, Inc.
5 * 6 *
6 * Author: MontaVista Software, Inc. 7 * This file is licensed under the terms of the GNU General Public License
7 * source@mvista.com 8 * version 2. This program is licensed "as is" without any warranty of any
8 * 9 * kind, whether express or implied.
9 * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under the
10 * terms of the GNU General Public License version 2. This program is licensed
11 * "as is" without any warranty of any kind, whether express or implied.
12 */ 10 */
13 11
14#ifdef __KERNEL__ 12#ifdef __KERNEL__
15#ifndef __ASM_VIRTEX_H__ 13#ifndef __ASM_VIRTEX_H__
16#define __ASM_VIRTEX_H__ 14#define __ASM_VIRTEX_H__
17 15
18/* serial defines */
19
20#include <asm/ibm405.h> 16#include <asm/ibm405.h>
17#include <asm/ppcboot.h>
21 18
22/* Ugly, ugly, ugly! BASE_BAUD defined here to keep 8250.c happy. */ 19/* Ugly, ugly, ugly! BASE_BAUD defined here to keep 8250.c happy. */
23#if !defined(BASE_BAUD) 20#if !defined(BASE_BAUD)
24 #define BASE_BAUD (0) /* dummy value; not used */ 21 #define BASE_BAUD (0) /* dummy value; not used */
25#endif 22#endif
26 23
27/* Device type enumeration for platform bus definitions */
28#ifndef __ASSEMBLY__ 24#ifndef __ASSEMBLY__
29enum ppc_sys_devices { 25extern const char* virtex_machine_name;
30 VIRTEX_UART, NUM_PPC_SYS_DEVS, 26#define PPC4xx_MACHINE_NAME (virtex_machine_name)
31}; 27#endif /* !__ASSEMBLY__ */
32#endif 28
33 29/* We don't need anything mapped. Size of zero will accomplish that. */
30#define PPC4xx_ONB_IO_PADDR 0u
31#define PPC4xx_ONB_IO_VADDR 0u
32#define PPC4xx_ONB_IO_SIZE 0u
33
34#endif /* __ASM_VIRTEX_H__ */ 34#endif /* __ASM_VIRTEX_H__ */
35#endif /* __KERNEL__ */ 35#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/4xx/xilinx_ml300.c b/arch/ppc/platforms/4xx/xilinx_ml300.c
index fb5f0b5e13d1..6e522fefc26f 100644
--- a/arch/ppc/platforms/4xx/xilinx_ml300.c
+++ b/arch/ppc/platforms/4xx/xilinx_ml300.c
@@ -18,9 +18,9 @@
18#include <linux/serialP.h> 18#include <linux/serialP.h>
19#include <asm/io.h> 19#include <asm/io.h>
20#include <asm/machdep.h> 20#include <asm/machdep.h>
21#include <asm/ppc_sys.h>
22 21
23#include <syslib/gen550.h> 22#include <syslib/gen550.h>
23#include <syslib/virtex_devices.h>
24#include <platforms/4xx/xparameters/xparameters.h> 24#include <platforms/4xx/xparameters/xparameters.h>
25 25
26/* 26/*
@@ -53,24 +53,9 @@
53 * ppc4xx_pic_init arch/ppc/syslib/xilinx_pic.c 53 * ppc4xx_pic_init arch/ppc/syslib/xilinx_pic.c
54 */ 54 */
55 55
56/* Board specifications structures */ 56const char* virtex_machine_name = "ML300 Reference Design";
57struct ppc_sys_spec *cur_ppc_sys_spec;
58struct ppc_sys_spec ppc_sys_specs[] = {
59 {
60 /* Only one entry, always assume the same design */
61 .ppc_sys_name = "Xilinx ML300 Reference Design",
62 .mask = 0x00000000,
63 .value = 0x00000000,
64 .num_devices = 1,
65 .device_list = (enum ppc_sys_devices[])
66 {
67 VIRTEX_UART,
68 },
69 },
70};
71 57
72#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR) 58#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
73
74static volatile unsigned *powerdown_base = 59static volatile unsigned *powerdown_base =
75 (volatile unsigned *) XPAR_POWER_0_POWERDOWN_BASEADDR; 60 (volatile unsigned *) XPAR_POWER_0_POWERDOWN_BASEADDR;
76 61
@@ -95,52 +80,14 @@ ml300_map_io(void)
95#endif 80#endif
96} 81}
97 82
98/* Early serial support functions */
99static void __init
100ml300_early_serial_init(int num, struct plat_serial8250_port *pdata)
101{
102#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
103 struct uart_port serial_req;
104
105 memset(&serial_req, 0, sizeof(serial_req));
106 serial_req.mapbase = pdata->mapbase;
107 serial_req.membase = pdata->membase;
108 serial_req.irq = pdata->irq;
109 serial_req.uartclk = pdata->uartclk;
110 serial_req.regshift = pdata->regshift;
111 serial_req.iotype = pdata->iotype;
112 serial_req.flags = pdata->flags;
113 gen550_init(num, &serial_req);
114#endif
115}
116
117void __init
118ml300_early_serial_map(void)
119{
120#ifdef CONFIG_SERIAL_8250
121 struct plat_serial8250_port *pdata;
122 int i = 0;
123
124 pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(VIRTEX_UART);
125 while(pdata && pdata->flags)
126 {
127 pdata->membase = ioremap(pdata->mapbase, 0x100);
128 ml300_early_serial_init(i, pdata);
129 pdata++;
130 i++;
131 }
132#endif /* CONFIG_SERIAL_8250 */
133}
134
135void __init 83void __init
136ml300_setup_arch(void) 84ml300_setup_arch(void)
137{ 85{
138 ml300_early_serial_map(); 86 virtex_early_serial_map();
139 ppc4xx_setup_arch(); /* calls ppc4xx_find_bridges() */ 87 ppc4xx_setup_arch(); /* calls ppc4xx_find_bridges() */
140 88
141 /* Identify the system */ 89 /* Identify the system */
142 printk(KERN_INFO "Xilinx Virtex-II Pro port\n"); 90 printk(KERN_INFO "Xilinx ML300 Reference System (Virtex-II Pro)\n");
143 printk(KERN_INFO "Port by MontaVista Software, Inc. (source@mvista.com)\n");
144} 91}
145 92
146/* Called after board_setup_irq from ppc4xx_init_IRQ(). */ 93/* Called after board_setup_irq from ppc4xx_init_IRQ(). */
@@ -156,8 +103,6 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
156{ 103{
157 ppc4xx_init(r3, r4, r5, r6, r7); 104 ppc4xx_init(r3, r4, r5, r6, r7);
158 105
159 identify_ppc_sys_by_id(mfspr(SPRN_PVR));
160
161 ppc_md.setup_arch = ml300_setup_arch; 106 ppc_md.setup_arch = ml300_setup_arch;
162 ppc_md.setup_io_mappings = ml300_map_io; 107 ppc_md.setup_io_mappings = ml300_map_io;
163 ppc_md.init_IRQ = ml300_init_irq; 108 ppc_md.init_IRQ = ml300_init_irq;
@@ -167,7 +112,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
167#endif 112#endif
168 113
169#ifdef CONFIG_KGDB 114#ifdef CONFIG_KGDB
170 ppc_md.early_serial_map = ml300_early_serial_map; 115 ppc_md.early_serial_map = virtex_early_serial_map;
171#endif 116#endif
172} 117}
173 118
diff --git a/arch/ppc/platforms/4xx/xilinx_ml300.h b/arch/ppc/platforms/4xx/xilinx_ml300.h
deleted file mode 100644
index 3d57332ba820..000000000000
--- a/arch/ppc/platforms/4xx/xilinx_ml300.h
+++ /dev/null
@@ -1,45 +0,0 @@
1/*
2 * Include file that defines the Xilinx ML300 evaluation board
3 *
4 * Author: MontaVista Software, Inc.
5 * source@mvista.com
6 *
7 * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under the
8 * terms of the GNU General Public License version 2. This program is licensed
9 * "as is" without any warranty of any kind, whether express or implied.
10 */
11
12#ifdef __KERNEL__
13#ifndef __ASM_XILINX_ML300_H__
14#define __ASM_XILINX_ML300_H__
15
16/* ML300 has a Xilinx Virtex-II Pro processor */
17#include <platforms/4xx/virtex.h>
18
19#ifndef __ASSEMBLY__
20
21#include <linux/types.h>
22
23typedef struct board_info {
24 unsigned int bi_memsize; /* DRAM installed, in bytes */
25 unsigned char bi_enetaddr[6]; /* Local Ethernet MAC address */
26 unsigned int bi_intfreq; /* Processor speed, in Hz */
27 unsigned int bi_busfreq; /* PLB Bus speed, in Hz */
28 unsigned int bi_pci_busfreq; /* PCI Bus speed, in Hz */
29} bd_t;
30
31/* Some 4xx parts use a different timebase frequency from the internal clock.
32*/
33#define bi_tbfreq bi_intfreq
34
35#endif /* !__ASSEMBLY__ */
36
37/* We don't need anything mapped. Size of zero will accomplish that. */
38#define PPC4xx_ONB_IO_PADDR 0u
39#define PPC4xx_ONB_IO_VADDR 0u
40#define PPC4xx_ONB_IO_SIZE 0u
41
42#define PPC4xx_MACHINE_NAME "Xilinx ML300 Reference System"
43
44#endif /* __ASM_XILINX_ML300_H__ */
45#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/4xx/xilinx_ml403.c b/arch/ppc/platforms/4xx/xilinx_ml403.c
index cb3bf7a2bcbe..bc3ace3762e7 100644
--- a/arch/ppc/platforms/4xx/xilinx_ml403.c
+++ b/arch/ppc/platforms/4xx/xilinx_ml403.c
@@ -1,11 +1,9 @@
1/* 1/*
2 * arch/ppc/platforms/4xx/xilinx_ml403.c
3 *
4 * Xilinx ML403 evaluation board initialization 2 * Xilinx ML403 evaluation board initialization
5 * 3 *
6 * Author: Grant Likely <grant.likely@secretlab.ca> 4 * Author: Grant Likely <grant.likely@secretlab.ca>
7 * 5 *
8 * 2005 (c) Secret Lab Technologies Ltd. 6 * 2005-2007 (c) Secret Lab Technologies Ltd.
9 * 2002-2004 (c) MontaVista Software, Inc. 7 * 2002-2004 (c) MontaVista Software, Inc.
10 * 8 *
11 * This file is licensed under the terms of the GNU General Public License 9 * This file is licensed under the terms of the GNU General Public License
@@ -22,9 +20,9 @@
22#include <linux/serialP.h> 20#include <linux/serialP.h>
23#include <asm/io.h> 21#include <asm/io.h>
24#include <asm/machdep.h> 22#include <asm/machdep.h>
25#include <asm/ppc_sys.h>
26 23
27#include <syslib/gen550.h> 24#include <syslib/gen550.h>
25#include <syslib/virtex_devices.h>
28#include <platforms/4xx/xparameters/xparameters.h> 26#include <platforms/4xx/xparameters/xparameters.h>
29 27
30/* 28/*
@@ -57,24 +55,9 @@
57 * ppc4xx_pic_init arch/ppc/syslib/xilinx_pic.c 55 * ppc4xx_pic_init arch/ppc/syslib/xilinx_pic.c
58 */ 56 */
59 57
60/* Board specifications structures */ 58const char* virtex_machine_name = "ML403 Reference Design";
61struct ppc_sys_spec *cur_ppc_sys_spec;
62struct ppc_sys_spec ppc_sys_specs[] = {
63 {
64 /* Only one entry, always assume the same design */
65 .ppc_sys_name = "Xilinx ML403 Reference Design",
66 .mask = 0x00000000,
67 .value = 0x00000000,
68 .num_devices = 1,
69 .device_list = (enum ppc_sys_devices[])
70 {
71 VIRTEX_UART,
72 },
73 },
74};
75 59
76#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR) 60#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
77
78static volatile unsigned *powerdown_base = 61static volatile unsigned *powerdown_base =
79 (volatile unsigned *) XPAR_POWER_0_POWERDOWN_BASEADDR; 62 (volatile unsigned *) XPAR_POWER_0_POWERDOWN_BASEADDR;
80 63
@@ -99,47 +82,10 @@ ml403_map_io(void)
99#endif 82#endif
100} 83}
101 84
102/* Early serial support functions */
103static void __init
104ml403_early_serial_init(int num, struct plat_serial8250_port *pdata)
105{
106#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
107 struct uart_port serial_req;
108
109 memset(&serial_req, 0, sizeof(serial_req));
110 serial_req.mapbase = pdata->mapbase;
111 serial_req.membase = pdata->membase;
112 serial_req.irq = pdata->irq;
113 serial_req.uartclk = pdata->uartclk;
114 serial_req.regshift = pdata->regshift;
115 serial_req.iotype = pdata->iotype;
116 serial_req.flags = pdata->flags;
117 gen550_init(num, &serial_req);
118#endif
119}
120
121void __init
122ml403_early_serial_map(void)
123{
124#ifdef CONFIG_SERIAL_8250
125 struct plat_serial8250_port *pdata;
126 int i = 0;
127
128 pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(VIRTEX_UART);
129 while(pdata && pdata->flags)
130 {
131 pdata->membase = ioremap(pdata->mapbase, 0x100);
132 ml403_early_serial_init(i, pdata);
133 pdata++;
134 i++;
135 }
136#endif /* CONFIG_SERIAL_8250 */
137}
138
139void __init 85void __init
140ml403_setup_arch(void) 86ml403_setup_arch(void)
141{ 87{
142 ml403_early_serial_map(); 88 virtex_early_serial_map();
143 ppc4xx_setup_arch(); /* calls ppc4xx_find_bridges() */ 89 ppc4xx_setup_arch(); /* calls ppc4xx_find_bridges() */
144 90
145 /* Identify the system */ 91 /* Identify the system */
@@ -159,8 +105,6 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
159{ 105{
160 ppc4xx_init(r3, r4, r5, r6, r7); 106 ppc4xx_init(r3, r4, r5, r6, r7);
161 107
162 identify_ppc_sys_by_id(mfspr(SPRN_PVR));
163
164 ppc_md.setup_arch = ml403_setup_arch; 108 ppc_md.setup_arch = ml403_setup_arch;
165 ppc_md.setup_io_mappings = ml403_map_io; 109 ppc_md.setup_io_mappings = ml403_map_io;
166 ppc_md.init_IRQ = ml403_init_irq; 110 ppc_md.init_IRQ = ml403_init_irq;
@@ -170,7 +114,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
170#endif 114#endif
171 115
172#ifdef CONFIG_KGDB 116#ifdef CONFIG_KGDB
173 ppc_md.early_serial_map = ml403_early_serial_map; 117 ppc_md.early_serial_map = virtex_early_serial_map;
174#endif 118#endif
175} 119}
176 120
diff --git a/arch/ppc/platforms/4xx/xilinx_ml403.h b/arch/ppc/platforms/4xx/xilinx_ml403.h
deleted file mode 100644
index 473596959902..000000000000
--- a/arch/ppc/platforms/4xx/xilinx_ml403.h
+++ /dev/null
@@ -1,49 +0,0 @@
1/*
2 * arch/ppc/platforms/4xx/xilinx_ml403.h
3 *
4 * Include file that defines the Xilinx ML403 reference design
5 *
6 * Author: Grant Likely <grant.likely@secretlab.ca>
7 *
8 * 2005 (c) Secret Lab Technologies Ltd.
9 * 2002-2004 (c) MontaVista Software, Inc.
10 *
11 * This file is licensed under the terms of the GNU General Public License
12 * version 2. This program is licensed "as is" without any warranty of any
13 * kind, whether express or implied.
14 */
15
16#ifdef __KERNEL__
17#ifndef __ASM_XILINX_ML403_H__
18#define __ASM_XILINX_ML403_H__
19
20/* ML403 has a Xilinx Virtex-4 FPGA with a PPC405 hard core */
21#include <platforms/4xx/virtex.h>
22
23#ifndef __ASSEMBLY__
24
25#include <linux/types.h>
26
27typedef struct board_info {
28 unsigned int bi_memsize; /* DRAM installed, in bytes */
29 unsigned char bi_enetaddr[6]; /* Local Ethernet MAC address */
30 unsigned int bi_intfreq; /* Processor speed, in Hz */
31 unsigned int bi_busfreq; /* PLB Bus speed, in Hz */
32 unsigned int bi_pci_busfreq; /* PCI Bus speed, in Hz */
33} bd_t;
34
35/* Some 4xx parts use a different timebase frequency from the internal clock.
36*/
37#define bi_tbfreq bi_intfreq
38
39#endif /* !__ASSEMBLY__ */
40
41/* We don't need anything mapped. Size of zero will accomplish that. */
42#define PPC4xx_ONB_IO_PADDR 0u
43#define PPC4xx_ONB_IO_VADDR 0u
44#define PPC4xx_ONB_IO_SIZE 0u
45
46#define PPC4xx_MACHINE_NAME "Xilinx ML403 Reference Design"
47
48#endif /* __ASM_XILINX_ML403_H__ */
49#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/4xx/xparameters/xparameters.h b/arch/ppc/platforms/4xx/xparameters/xparameters.h
index 66ec5f35f306..01aa043ff381 100644
--- a/arch/ppc/platforms/4xx/xparameters/xparameters.h
+++ b/arch/ppc/platforms/4xx/xparameters/xparameters.h
@@ -34,3 +34,63 @@
34 .io_type = SERIAL_IO_MEM, \ 34 .io_type = SERIAL_IO_MEM, \
35 }, 35 },
36#endif 36#endif
37
38/*
39 * A few reasonable defaults for the #defines which could be missing depending
40 * on the IP version or variant (e.g. OPB vs PLB)
41 */
42
43#ifndef XPAR_EMAC_0_CAM_EXIST
44#define XPAR_EMAC_0_CAM_EXIST 0
45#endif
46#ifndef XPAR_EMAC_0_JUMBO_EXIST
47#define XPAR_EMAC_0_JUMBO_EXIST 0
48#endif
49#ifndef XPAR_EMAC_0_TX_DRE_TYPE
50#define XPAR_EMAC_0_TX_DRE_TYPE 0
51#endif
52#ifndef XPAR_EMAC_0_RX_DRE_TYPE
53#define XPAR_EMAC_0_RX_DRE_TYPE 0
54#endif
55#ifndef XPAR_EMAC_0_TX_INCLUDE_CSUM
56#define XPAR_EMAC_0_TX_INCLUDE_CSUM 0
57#endif
58#ifndef XPAR_EMAC_0_RX_INCLUDE_CSUM
59#define XPAR_EMAC_0_RX_INCLUDE_CSUM 0
60#endif
61
62#ifndef XPAR_EMAC_1_CAM_EXIST
63#define XPAR_EMAC_1_CAM_EXIST 0
64#endif
65#ifndef XPAR_EMAC_1_JUMBO_EXIST
66#define XPAR_EMAC_1_JUMBO_EXIST 0
67#endif
68#ifndef XPAR_EMAC_1_TX_DRE_TYPE
69#define XPAR_EMAC_1_TX_DRE_TYPE 0
70#endif
71#ifndef XPAR_EMAC_1_RX_DRE_TYPE
72#define XPAR_EMAC_1_RX_DRE_TYPE 0
73#endif
74#ifndef XPAR_EMAC_1_TX_INCLUDE_CSUM
75#define XPAR_EMAC_1_TX_INCLUDE_CSUM 0
76#endif
77#ifndef XPAR_EMAC_1_RX_INCLUDE_CSUM
78#define XPAR_EMAC_1_RX_INCLUDE_CSUM 0
79#endif
80
81#ifndef XPAR_GPIO_0_IS_DUAL
82#define XPAR_GPIO_0_IS_DUAL 0
83#endif
84#ifndef XPAR_GPIO_1_IS_DUAL
85#define XPAR_GPIO_1_IS_DUAL 0
86#endif
87#ifndef XPAR_GPIO_2_IS_DUAL
88#define XPAR_GPIO_2_IS_DUAL 0
89#endif
90#ifndef XPAR_GPIO_3_IS_DUAL
91#define XPAR_GPIO_3_IS_DUAL 0
92#endif
93#ifndef XPAR_GPIO_4_IS_DUAL
94#define XPAR_GPIO_4_IS_DUAL 0
95#endif
96
diff --git a/arch/ppc/platforms/rpxclassic.h b/arch/ppc/platforms/rpxclassic.h
index 57a2a55dab8c..a3c1118e5b09 100644
--- a/arch/ppc/platforms/rpxclassic.h
+++ b/arch/ppc/platforms/rpxclassic.h
@@ -69,10 +69,6 @@ extern bd_t m8xx_board_info;
69#define BCSR2_QSPACESEL ((uint)0x00004000) 69#define BCSR2_QSPACESEL ((uint)0x00004000)
70#define BCSR2_FETHLEDMODE ((uint)0x00000800) /* CLLF */ 70#define BCSR2_FETHLEDMODE ((uint)0x00000800) /* CLLF */
71 71
72#if defined(CONFIG_HTDMSOUND)
73#include <platforms/rpxhiox.h>
74#endif
75
76/* define IO_BASE for pcmcia, CLLF only */ 72/* define IO_BASE for pcmcia, CLLF only */
77#if !defined(CONFIG_PCI) 73#if !defined(CONFIG_PCI)
78#define _IO_BASE 0x80000000 74#define _IO_BASE 0x80000000
diff --git a/arch/ppc/platforms/rpxhiox.h b/arch/ppc/platforms/rpxhiox.h
deleted file mode 100644
index c3fa5a653762..000000000000
--- a/arch/ppc/platforms/rpxhiox.h
+++ /dev/null
@@ -1,41 +0,0 @@
1/*
2 * The Embedded Planet HIOX expansion card definitions.
3 * There were a few different versions of these cards, but only
4 * the one that escaped real production is defined here.
5 *
6 * Copyright (c) 2000 Dan Malek (dmalek@jlc.net)
7 */
8#ifndef __MACH_RPX_HIOX_DEFS
9#define __MACH_RPX_HIOX_DEFS
10
11#define HIOX_CSR_ADDR ((uint)0xfac00000)
12#define HIOX_CSR_SIZE ((uint)(4 * 1024))
13#define HIOX_CSR0_ADDR HIOX_CSR_ADDR
14#define HIOX_CSR4_ADDR ((uint)0xfac00004)
15
16#define HIOX_CSR0_DEFAULT ((uint)0x380f3c00)
17#define HIOX_CSR0_ENSCC2 ((uint)0x80000000)
18#define HIOX_CSR0_ENSMC2 ((uint)0x04000000)
19#define HIOX_CSR0_ENVDOCLK ((uint)0x02000000)
20#define HIOX_CSR0_VDORST_HL ((uint)0x01000000)
21#define HIOX_CSR0_RS232SEL ((uint)0x0000c000)
22#define HIOX_CSR0_SCC3SEL ((uint)0x0000c000)
23#define HIOX_CSR0_SMC1SEL ((uint)0x00008000)
24#define HIOX_CSR0_SCC1SEL ((uint)0x00004000)
25#define HIOX_CSR0_ENTOUCH ((uint)0x00000080)
26#define HIOX_CSR0_PDOWN100 ((uint)0x00000060)
27#define HIOX_CSR0_PDOWN10 ((uint)0x00000040)
28#define HIOX_CSR0_PDOWN1 ((uint)0x00000020)
29#define HIOX_CSR0_TSELSPI ((uint)0x00000010)
30#define HIOX_CSR0_TIRQSTAT ((uint)0x00000008)
31#define HIOX_CSR4_DEFAULT ((uint)0x00000000)
32#define HIOX_CSR4_ENTIRQ2 ((uint)0x20000000)
33#define HIOX_CSR4_ENTIRQ3 ((uint)0x10000000)
34#define HIOX_CSR4_ENAUDIO ((uint)0x00000080)
35#define HIOX_CSR4_RSTAUDIO ((uint)0x00000040) /* 0 == reset */
36#define HIOX_CSR4_AUDCLKHI ((uint)0x00000020)
37#define HIOX_CSR4_AUDSPISEL ((uint)0x00000010)
38#define HIOX_CSR4_AUDIRQSTAT ((uint)0x00000008)
39#define HIOX_CSR4_AUDCLKSEL ((uint)0x00000007)
40
41#endif
diff --git a/arch/ppc/platforms/rpxlite.h b/arch/ppc/platforms/rpxlite.h
index 719780646270..b615501d55fc 100644
--- a/arch/ppc/platforms/rpxlite.h
+++ b/arch/ppc/platforms/rpxlite.h
@@ -57,10 +57,6 @@ extern bd_t m8xx_board_info;
57#define BCSR1_PCVCTL6 ((uint)0x00020000) 57#define BCSR1_PCVCTL6 ((uint)0x00020000)
58#define BCSR1_PCVCTL7 ((uint)0x00010000) 58#define BCSR1_PCVCTL7 ((uint)0x00010000)
59 59
60#if defined(CONFIG_HTDMSOUND)
61#include <platforms/rpxhiox.h>
62#endif
63
64/* define IO_BASE for pcmcia */ 60/* define IO_BASE for pcmcia */
65#define _IO_BASE 0x80000000 61#define _IO_BASE 0x80000000
66#define _IO_BASE_SIZE 0x1000 62#define _IO_BASE_SIZE 0x1000
diff --git a/arch/ppc/syslib/Makefile b/arch/ppc/syslib/Makefile
index 09911118c675..95694159b226 100644
--- a/arch/ppc/syslib/Makefile
+++ b/arch/ppc/syslib/Makefile
@@ -18,7 +18,8 @@ obj-$(CONFIG_440SP) += ibm440gx_common.o ibm440sp_common.o
18obj-$(CONFIG_440SPE) += ibm440gx_common.o ibm440sp_common.o ppc440spe_pcie.o 18obj-$(CONFIG_440SPE) += ibm440gx_common.o ibm440sp_common.o ppc440spe_pcie.o
19ifeq ($(CONFIG_4xx),y) 19ifeq ($(CONFIG_4xx),y)
20ifeq ($(CONFIG_XILINX_VIRTEX),y) 20ifeq ($(CONFIG_XILINX_VIRTEX),y)
21obj-$(CONFIG_40x) += xilinx_pic.o ppc_sys.o 21obj-$(CONFIG_40x) += xilinx_pic.o
22obj-y += virtex_devices.o
22else 23else
23ifeq ($(CONFIG_403),y) 24ifeq ($(CONFIG_403),y)
24obj-$(CONFIG_40x) += ppc403_pic.o 25obj-$(CONFIG_40x) += ppc403_pic.o
diff --git a/arch/ppc/syslib/cpc710.h b/arch/ppc/syslib/cpc710.h
deleted file mode 100644
index 5299bf8b5d01..000000000000
--- a/arch/ppc/syslib/cpc710.h
+++ /dev/null
@@ -1,81 +0,0 @@
1/*
2 * Definitions for the IBM CPC710 PCI Host Bridge
3 *
4 * Author: Matt Porter <mporter@mvista.com>
5 *
6 * 2001 (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
12#ifndef __PPC_PLATFORMS_CPC710_H
13#define __PPC_PLATFORMS_CPC710_H
14
15/* General bridge and memory controller registers */
16#define PIDR 0xff000008
17#define CNFR 0xff00000c
18#define RSTR 0xff000010
19#define UCTL 0xff001000
20#define MPSR 0xff001010
21#define SIOC 0xff001020
22#define ABCNTL 0xff001030
23#define SRST 0xff001040
24#define ERRC 0xff001050
25#define SESR 0xff001060
26#define SEAR 0xff001070
27#define SIOC1 0xff001090
28#define PGCHP 0xff001100
29#define GPDIR 0xff001130
30#define GPOUT 0xff001150
31#define ATAS 0xff001160
32#define AVDG 0xff001170
33#define MCCR 0xff001200
34#define MESR 0xff001220
35#define MEAR 0xff001230
36#define MCER0 0xff001300
37#define MCER1 0xff001310
38#define MCER2 0xff001320
39#define MCER3 0xff001330
40#define MCER4 0xff001340
41#define MCER5 0xff001350
42#define MCER6 0xff001360
43#define MCER7 0xff001370
44
45/*
46 * PCI32/64 configuration registers
47 * Given as offsets from their
48 * respective physical segment BAR
49 */
50#define PIBAR 0x000f7800
51#define PMBAR 0x000f7810
52#define MSIZE 0x000f7f40
53#define IOSIZE 0x000f7f60
54#define SMBAR 0x000f7f80
55#define SIBAR 0x000f7fc0
56#define PSSIZE 0x000f8100
57#define PPSIZE 0x000f8110
58#define BARPS 0x000f8120
59#define BARPP 0x000f8130
60#define PSBAR 0x000f8140
61#define PPBAR 0x000f8150
62#define BPMDLK 0x000f8200 /* Bottom of Peripheral Memory Space */
63#define TPMDLK 0x000f8210 /* Top of Peripheral Memory Space */
64#define BIODLK 0x000f8220 /* Bottom of Peripheral I/O Space */
65#define TIODLK 0x000f8230 /* Top of Perioheral I/O Space */
66#define DLKCTRL 0x000f8240 /* Deadlock control */
67#define DLKDEV 0x000f8250 /* Deadlock device */
68
69/* System standard configuration registers space */
70#define DCR 0xff200000
71#define DID 0xff200004
72#define BAR 0xff200018
73
74/* Device specific configuration space */
75#define PCIENB 0xff201000
76
77/* Configuration space registers */
78#define CPC710_BUS_NUMBER 0x40
79#define CPC710_SUB_BUS_NUMBER 0x41
80
81#endif /* __PPC_PLATFORMS_CPC710_H */
diff --git a/arch/ppc/syslib/m8xx_setup.c b/arch/ppc/syslib/m8xx_setup.c
index 01e48d88f22d..9caf850c9b38 100644
--- a/arch/ppc/syslib/m8xx_setup.c
+++ b/arch/ppc/syslib/m8xx_setup.c
@@ -413,7 +413,7 @@ m8xx_map_io(void)
413 io_block_mapping(_IO_BASE,_IO_BASE,_IO_BASE_SIZE, _PAGE_IO); 413 io_block_mapping(_IO_BASE,_IO_BASE,_IO_BASE_SIZE, _PAGE_IO);
414#endif 414#endif
415#endif 415#endif
416#if defined(CONFIG_HTDMSOUND) || defined(CONFIG_RPXTOUCH) || defined(CONFIG_FB_RPX) 416#if defined(CONFIG_RPXTOUCH) || defined(CONFIG_FB_RPX)
417 io_block_mapping(HIOX_CSR_ADDR, HIOX_CSR_ADDR, HIOX_CSR_SIZE, _PAGE_IO); 417 io_block_mapping(HIOX_CSR_ADDR, HIOX_CSR_ADDR, HIOX_CSR_SIZE, _PAGE_IO);
418#endif 418#endif
419#ifdef CONFIG_FADS 419#ifdef CONFIG_FADS
diff --git a/arch/ppc/syslib/ppc4xx_sgdma.c b/arch/ppc/syslib/ppc4xx_sgdma.c
index 2f83e162971f..939abe3c1f45 100644
--- a/arch/ppc/syslib/ppc4xx_sgdma.c
+++ b/arch/ppc/syslib/ppc4xx_sgdma.c
@@ -27,6 +27,7 @@
27 27
28#include <asm/system.h> 28#include <asm/system.h>
29#include <asm/io.h> 29#include <asm/io.h>
30#include <asm/dma-mapping.h>
30#include <asm/ppc4xx_dma.h> 31#include <asm/ppc4xx_dma.h>
31 32
32void 33void
diff --git a/arch/ppc/syslib/virtex_devices.c b/arch/ppc/syslib/virtex_devices.c
new file mode 100644
index 000000000000..16546788e23b
--- /dev/null
+++ b/arch/ppc/syslib/virtex_devices.c
@@ -0,0 +1,233 @@
1/*
2 * Virtex hard ppc405 core common device listing
3 *
4 * Copyright 2005-2007 Secret Lab Technologies Ltd.
5 * Copyright 2005 Freescale Semiconductor Inc.
6 * Copyright 2002-2004 MontaVista Software, Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/init.h>
15#include <linux/module.h>
16#include <linux/device.h>
17#include <linux/serial_8250.h>
18#include <syslib/virtex_devices.h>
19#include <platforms/4xx/xparameters/xparameters.h>
20#include <asm/io.h>
21
22/*
23 * UARTLITE: shortcut macro for single instance
24 */
25#define XPAR_UARTLITE(num) { \
26 .name = "uartlite", \
27 .id = num, \
28 .num_resources = 2, \
29 .resource = (struct resource[]) { \
30 { \
31 .start = XPAR_UARTLITE_##num##_BASEADDR + 3, \
32 .end = XPAR_UARTLITE_##num##_HIGHADDR, \
33 .flags = IORESOURCE_MEM, \
34 }, \
35 { \
36 .start = XPAR_INTC_0_UARTLITE_##num##_VEC_ID, \
37 .flags = IORESOURCE_IRQ, \
38 }, \
39 }, \
40}
41
42/*
43 * Full UART: shortcut macro for single instance + platform data structure
44 */
45#define XPAR_UART(num) { \
46 .mapbase = XPAR_UARTNS550_##num##_BASEADDR + 3, \
47 .irq = XPAR_INTC_0_UARTNS550_##num##_VEC_ID, \
48 .iotype = UPIO_MEM, \
49 .uartclk = XPAR_UARTNS550_##num##_CLOCK_FREQ_HZ, \
50 .flags = UPF_BOOT_AUTOCONF, \
51 .regshift = 2, \
52}
53
54/*
55 * SystemACE: shortcut macro for single instance
56 */
57#define XPAR_SYSACE(num) { \
58 .name = "xsysace", \
59 .id = XPAR_SYSACE_##num##_DEVICE_ID, \
60 .num_resources = 2, \
61 .resource = (struct resource[]) { \
62 { \
63 .start = XPAR_SYSACE_##num##_BASEADDR, \
64 .end = XPAR_SYSACE_##num##_HIGHADDR, \
65 .flags = IORESOURCE_MEM, \
66 }, \
67 { \
68 .start = XPAR_INTC_0_SYSACE_##num##_VEC_ID, \
69 .flags = IORESOURCE_IRQ, \
70 }, \
71 }, \
72}
73
74
75/* UART 8250 driver platform data table */
76struct plat_serial8250_port virtex_serial_platform_data[] = {
77#if defined(XPAR_UARTNS550_0_BASEADDR)
78 XPAR_UART(0),
79#endif
80#if defined(XPAR_UARTNS550_1_BASEADDR)
81 XPAR_UART(1),
82#endif
83#if defined(XPAR_UARTNS550_2_BASEADDR)
84 XPAR_UART(2),
85#endif
86#if defined(XPAR_UARTNS550_3_BASEADDR)
87 XPAR_UART(3),
88#endif
89#if defined(XPAR_UARTNS550_4_BASEADDR)
90 XPAR_UART(4),
91#endif
92#if defined(XPAR_UARTNS550_5_BASEADDR)
93 XPAR_UART(5),
94#endif
95#if defined(XPAR_UARTNS550_6_BASEADDR)
96 XPAR_UART(6),
97#endif
98#if defined(XPAR_UARTNS550_7_BASEADDR)
99 XPAR_UART(7),
100#endif
101 { }, /* terminated by empty record */
102};
103
104
105struct platform_device virtex_platform_devices[] = {
106 /* UARTLITE instances */
107#if defined(XPAR_UARTLITE_0_BASEADDR)
108 XPAR_UARTLITE(0),
109#endif
110#if defined(XPAR_UARTLITE_1_BASEADDR)
111 XPAR_UARTLITE(1),
112#endif
113#if defined(XPAR_UARTLITE_2_BASEADDR)
114 XPAR_UARTLITE(2),
115#endif
116#if defined(XPAR_UARTLITE_3_BASEADDR)
117 XPAR_UARTLITE(3),
118#endif
119#if defined(XPAR_UARTLITE_4_BASEADDR)
120 XPAR_UARTLITE(4),
121#endif
122#if defined(XPAR_UARTLITE_5_BASEADDR)
123 XPAR_UARTLITE(5),
124#endif
125#if defined(XPAR_UARTLITE_6_BASEADDR)
126 XPAR_UARTLITE(6),
127#endif
128#if defined(XPAR_UARTLITE_7_BASEADDR)
129 XPAR_UARTLITE(7),
130#endif
131
132 /* Full UART instances */
133#if defined(XPAR_UARTNS550_0_BASEADDR)
134 {
135 .name = "serial8250",
136 .id = 0,
137 .dev.platform_data = virtex_serial_platform_data,
138 },
139#endif
140
141 /* SystemACE instances */
142#if defined(XPAR_SYSACE_0_BASEADDR)
143 XPAR_SYSACE(0),
144#endif
145#if defined(XPAR_SYSACE_1_BASEADDR)
146 XPAR_SYSACE(1),
147#endif
148
149 /* ML300/403 reference design framebuffer */
150#if defined(XPAR_TFT_0_BASEADDR)
151 {
152 .name = "xilinxfb",
153 .id = 0,
154 .num_resources = 1,
155 .resource = (struct resource[]) {
156 {
157 .start = XPAR_TFT_0_BASEADDR,
158 .end = XPAR_TFT_0_BASEADDR+7,
159 .flags = IORESOURCE_IO,
160 },
161 },
162 },
163#endif
164};
165
166/* Early serial support functions */
167static void __init
168virtex_early_serial_init(int num, struct plat_serial8250_port *pdata)
169{
170#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
171 struct uart_port serial_req;
172
173 memset(&serial_req, 0, sizeof(serial_req));
174 serial_req.mapbase = pdata->mapbase;
175 serial_req.membase = pdata->membase;
176 serial_req.irq = pdata->irq;
177 serial_req.uartclk = pdata->uartclk;
178 serial_req.regshift = pdata->regshift;
179 serial_req.iotype = pdata->iotype;
180 serial_req.flags = pdata->flags;
181 gen550_init(num, &serial_req);
182#endif
183}
184
185void __init
186virtex_early_serial_map(void)
187{
188#ifdef CONFIG_SERIAL_8250
189 struct plat_serial8250_port *pdata;
190 int i = 0;
191
192 pdata = virtex_serial_platform_data;
193 while(pdata && pdata->flags) {
194 pdata->membase = ioremap(pdata->mapbase, 0x100);
195 virtex_early_serial_init(i, pdata);
196 pdata++;
197 i++;
198 }
199#endif /* CONFIG_SERIAL_8250 */
200}
201
202/*
203 * default fixup routine; do nothing and return success.
204 *
205 * Reimplement this routine in your custom board support file to
206 * override the default behaviour
207 */
208int __attribute__ ((weak))
209virtex_device_fixup(struct platform_device *dev)
210{
211 return 0;
212}
213
214static int __init virtex_init(void)
215{
216 struct platform_device *index = virtex_platform_devices;
217 unsigned int ret = 0;
218 int i;
219
220 for (i = 0; i < ARRAY_SIZE(virtex_platform_devices); i++, index++) {
221 if (virtex_device_fixup(index) != 0)
222 continue;
223
224 if (platform_device_register(index)) {
225 ret = 1;
226 printk(KERN_ERR "cannot register dev %s:%d\n",
227 index->name, index->id);
228 }
229 }
230 return ret;
231}
232
233subsys_initcall(virtex_init);
diff --git a/arch/ppc/syslib/virtex_devices.h b/arch/ppc/syslib/virtex_devices.h
new file mode 100644
index 000000000000..4a17dd3927c1
--- /dev/null
+++ b/arch/ppc/syslib/virtex_devices.h
@@ -0,0 +1,27 @@
1/*
2 * Common support header for virtex ppc405 platforms
3 *
4 * Copyright 2007 Secret Lab Technologies Ltd.
5 *
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
9 */
10
11#ifndef __ASM_VIRTEX_DEVICES_H__
12#define __ASM_VIRTEX_DEVICES_H__
13
14#include <linux/platform_device.h>
15
16void __init virtex_early_serial_map(void);
17
18/* Prototype for device fixup routine. Implement this routine in the
19 * board specific fixup code and the generic setup code will call it for
20 * each device is the platform device list.
21 *
22 * If the hook returns a non-zero value, then the device will not get
23 * registered with the platform bus
24 */
25int virtex_device_fixup(struct platform_device *dev);
26
27#endif /* __ASM_VIRTEX_DEVICES_H__ */
diff --git a/drivers/char/briq_panel.c b/drivers/char/briq_panel.c
index 8dcf9d20f449..c70d52ace8b2 100644
--- a/drivers/char/briq_panel.c
+++ b/drivers/char/briq_panel.c
@@ -202,13 +202,16 @@ static struct miscdevice briq_panel_miscdev = {
202 202
203static int __init briq_panel_init(void) 203static int __init briq_panel_init(void)
204{ 204{
205 struct device_node *root = find_path_device("/"); 205 struct device_node *root = of_find_node_by_path("/");
206 const char *machine; 206 const char *machine;
207 int i; 207 int i;
208 208
209 machine = get_property(root, "model", NULL); 209 machine = get_property(root, "model", NULL);
210 if (!machine || strncmp(machine, "TotalImpact,BRIQ-1", 18) != 0) 210 if (!machine || strncmp(machine, "TotalImpact,BRIQ-1", 18) != 0) {
211 of_node_put(root);
211 return -ENODEV; 212 return -ENODEV;
213 }
214 of_node_put(root);
212 215
213 printk(KERN_INFO 216 printk(KERN_INFO
214 "briq_panel: v%s Dr. Karsten Jeppesen (kj@totalimpact.com)\n", 217 "briq_panel: v%s Dr. Karsten Jeppesen (kj@totalimpact.com)\n",
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index a0a88aa23f5b..0f9ed7b46a6d 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -47,8 +47,6 @@
47#define HVC_MAJOR 229 47#define HVC_MAJOR 229
48#define HVC_MINOR 0 48#define HVC_MINOR 0
49 49
50#define TIMEOUT (10)
51
52/* 50/*
53 * Wait this long per iteration while trying to push buffered data to the 51 * Wait this long per iteration while trying to push buffered data to the
54 * hypervisor before allowing the tty to complete a close operation. 52 * hypervisor before allowing the tty to complete a close operation.
@@ -104,12 +102,12 @@ static DEFINE_SPINLOCK(hvc_structs_lock);
104/* 102/*
105 * This value is used to assign a tty->index value to a hvc_struct based 103 * This value is used to assign a tty->index value to a hvc_struct based
106 * upon order of exposure via hvc_probe(), when we can not match it to 104 * upon order of exposure via hvc_probe(), when we can not match it to
107 * a console canidate registered with hvc_instantiate(). 105 * a console candidate registered with hvc_instantiate().
108 */ 106 */
109static int last_hvc = -1; 107static int last_hvc = -1;
110 108
111/* 109/*
112 * Do not call this function with either the hvc_strucst_lock or the hvc_struct 110 * Do not call this function with either the hvc_structs_lock or the hvc_struct
113 * lock held. If successful, this function increments the kobject reference 111 * lock held. If successful, this function increments the kobject reference
114 * count against the target hvc_struct so it should be released when finished. 112 * count against the target hvc_struct so it should be released when finished.
115 */ 113 */
@@ -162,7 +160,7 @@ void hvc_console_print(struct console *co, const char *b, unsigned count)
162 if (index >= MAX_NR_HVC_CONSOLES) 160 if (index >= MAX_NR_HVC_CONSOLES)
163 return; 161 return;
164 162
165 /* This console adapter was removed so it is not useable. */ 163 /* This console adapter was removed so it is not usable. */
166 if (vtermnos[index] < 0) 164 if (vtermnos[index] < 0)
167 return; 165 return;
168 166
@@ -220,7 +218,7 @@ struct console hvc_con_driver = {
220}; 218};
221 219
222/* 220/*
223 * Early console initialization. Preceeds driver initialization. 221 * Early console initialization. Precedes driver initialization.
224 * 222 *
225 * (1) we are first, and the user specified another driver 223 * (1) we are first, and the user specified another driver
226 * -- index will remain -1 224 * -- index will remain -1
@@ -257,7 +255,7 @@ int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops)
257 if (vtermnos[index] != -1) 255 if (vtermnos[index] != -1)
258 return -1; 256 return -1;
259 257
260 /* make sure no no tty has been registerd in this index */ 258 /* make sure no no tty has been registered in this index */
261 hp = hvc_get_by_index(index); 259 hp = hvc_get_by_index(index);
262 if (hp) { 260 if (hp) {
263 kobject_put(&hp->kobj); 261 kobject_put(&hp->kobj);
@@ -267,7 +265,7 @@ int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops)
267 vtermnos[index] = vtermno; 265 vtermnos[index] = vtermno;
268 cons_ops[index] = ops; 266 cons_ops[index] = ops;
269 267
270 /* reserve all indices upto and including this index */ 268 /* reserve all indices up to and including this index */
271 if (last_hvc < index) 269 if (last_hvc < index)
272 last_hvc = index; 270 last_hvc = index;
273 271
@@ -528,7 +526,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
528 526
529/* 527/*
530 * This is actually a contract between the driver and the tty layer outlining 528 * This is actually a contract between the driver and the tty layer outlining
531 * how much write room the driver can guarentee will be sent OR BUFFERED. This 529 * how much write room the driver can guarantee will be sent OR BUFFERED. This
532 * driver MUST honor the return value. 530 * driver MUST honor the return value.
533 */ 531 */
534static int hvc_write_room(struct tty_struct *tty) 532static int hvc_write_room(struct tty_struct *tty)
@@ -550,6 +548,18 @@ static int hvc_chars_in_buffer(struct tty_struct *tty)
550 return hp->n_outbuf; 548 return hp->n_outbuf;
551} 549}
552 550
551/*
552 * timeout will vary between the MIN and MAX values defined here. By default
553 * and during console activity we will use a default MIN_TIMEOUT of 10. When
554 * the console is idle, we increase the timeout value on each pass through
555 * msleep until we reach the max. This may be noticeable as a brief (average
556 * one second) delay on the console before the console responds to input when
557 * there has been no input for some time.
558 */
559#define MIN_TIMEOUT (10)
560#define MAX_TIMEOUT (2000)
561static u32 timeout = MIN_TIMEOUT;
562
553#define HVC_POLL_READ 0x00000001 563#define HVC_POLL_READ 0x00000001
554#define HVC_POLL_WRITE 0x00000002 564#define HVC_POLL_WRITE 0x00000002
555 565
@@ -642,9 +652,14 @@ static int hvc_poll(struct hvc_struct *hp)
642 bail: 652 bail:
643 spin_unlock_irqrestore(&hp->lock, flags); 653 spin_unlock_irqrestore(&hp->lock, flags);
644 654
645 if (read_total) 655 if (read_total) {
656 /* Activity is occurring, so reset the polling backoff value to
657 a minimum for performance. */
658 timeout = MIN_TIMEOUT;
659
646 tty_flip_buffer_push(tty); 660 tty_flip_buffer_push(tty);
647 661 }
662
648 return poll_mask; 663 return poll_mask;
649} 664}
650 665
@@ -688,8 +703,12 @@ int khvcd(void *unused)
688 if (!hvc_kicked) { 703 if (!hvc_kicked) {
689 if (poll_mask == 0) 704 if (poll_mask == 0)
690 schedule(); 705 schedule();
691 else 706 else {
692 msleep_interruptible(TIMEOUT); 707 if (timeout < MAX_TIMEOUT)
708 timeout += (timeout >> 6) + 1;
709
710 msleep_interruptible(timeout);
711 }
693 } 712 }
694 __set_current_state(TASK_RUNNING); 713 __set_current_state(TASK_RUNNING);
695 } while (!kthread_should_stop()); 714 } while (!kthread_should_stop());
@@ -794,7 +813,7 @@ int __devexit hvc_remove(struct hvc_struct *hp)
794 813
795 /* 814 /*
796 * We 'put' the instance that was grabbed when the kobject instance 815 * We 'put' the instance that was grabbed when the kobject instance
797 * was intialized using kobject_init(). Let the last holder of this 816 * was initialized using kobject_init(). Let the last holder of this
798 * kobject cause it to be removed, which will probably be the tty_hangup 817 * kobject cause it to be removed, which will probably be the tty_hangup
799 * below. 818 * below.
800 */ 819 */
@@ -850,7 +869,7 @@ int __init hvc_init(void)
850} 869}
851module_init(hvc_init); 870module_init(hvc_init);
852 871
853/* This isn't particularily necessary due to this being a console driver 872/* This isn't particularly necessary due to this being a console driver
854 * but it is nice to be thorough. 873 * but it is nice to be thorough.
855 */ 874 */
856static void __exit hvc_exit(void) 875static void __exit hvc_exit(void)
diff --git a/drivers/char/hvc_iseries.c b/drivers/char/hvc_iseries.c
index f144a947bd17..ec420fe8a908 100644
--- a/drivers/char/hvc_iseries.c
+++ b/drivers/char/hvc_iseries.c
@@ -575,7 +575,7 @@ static int hvc_find_vtys(void)
575 (num_found >= VTTY_PORTS)) 575 (num_found >= VTTY_PORTS))
576 break; 576 break;
577 577
578 vtermno = get_property(vty, "reg", NULL); 578 vtermno = of_get_property(vty, "reg", NULL);
579 if (!vtermno) 579 if (!vtermno)
580 continue; 580 continue;
581 581
diff --git a/drivers/char/hvc_vio.c b/drivers/char/hvc_vio.c
index f9c00844d2bf..94a542e20efb 100644
--- a/drivers/char/hvc_vio.c
+++ b/drivers/char/hvc_vio.c
@@ -153,7 +153,7 @@ static int hvc_find_vtys(void)
153 if (num_found >= MAX_NR_HVC_CONSOLES) 153 if (num_found >= MAX_NR_HVC_CONSOLES)
154 break; 154 break;
155 155
156 vtermno = get_property(vty, "reg", NULL); 156 vtermno = of_get_property(vty, "reg", NULL);
157 if (!vtermno) 157 if (!vtermno)
158 continue; 158 continue;
159 159
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c
index 50315d6364fd..d5a752da322f 100644
--- a/drivers/char/hvsi.c
+++ b/drivers/char/hvsi.c
@@ -1279,8 +1279,8 @@ static int __init hvsi_console_init(void)
1279 struct hvsi_struct *hp; 1279 struct hvsi_struct *hp;
1280 const uint32_t *vtermno, *irq; 1280 const uint32_t *vtermno, *irq;
1281 1281
1282 vtermno = get_property(vty, "reg", NULL); 1282 vtermno = of_get_property(vty, "reg", NULL);
1283 irq = get_property(vty, "interrupts", NULL); 1283 irq = of_get_property(vty, "interrupts", NULL);
1284 if (!vtermno || !irq) 1284 if (!vtermno || !irq)
1285 continue; 1285 continue;
1286 1286
diff --git a/drivers/char/tpm/tpm_atmel.h b/drivers/char/tpm/tpm_atmel.h
index aefd683c60b7..3c852009196e 100644
--- a/drivers/char/tpm/tpm_atmel.h
+++ b/drivers/char/tpm/tpm_atmel.h
@@ -53,8 +53,8 @@ static void __iomem * atmel_get_base_addr(unsigned long *base, int *region_size)
53 } 53 }
54 54
55 reg = get_property(dn, "reg", &reglen); 55 reg = get_property(dn, "reg", &reglen);
56 naddrc = prom_n_addr_cells(dn); 56 naddrc = of_n_addr_cells(dn);
57 nsizec = prom_n_size_cells(dn); 57 nsizec = of_n_size_cells(dn);
58 58
59 of_node_put(dn); 59 of_node_put(dn);
60 60
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
index e812aa129e28..60198a78974c 100644
--- a/drivers/char/watchdog/Kconfig
+++ b/drivers/char/watchdog/Kconfig
@@ -548,7 +548,7 @@ config MV64X60_WDT
548 depends on WATCHDOG && MV64X60 548 depends on WATCHDOG && MV64X60
549 549
550config BOOKE_WDT 550config BOOKE_WDT
551 tristate "PowerPC Book-E Watchdog Timer" 551 bool "PowerPC Book-E Watchdog Timer"
552 depends on WATCHDOG && (BOOKE || 4xx) 552 depends on WATCHDOG && (BOOKE || 4xx)
553 ---help--- 553 ---help---
554 Please see Documentation/watchdog/watchdog-api.txt for 554 Please see Documentation/watchdog/watchdog-api.txt for
diff --git a/drivers/hwmon/ams/ams-core.c b/drivers/hwmon/ams/ams-core.c
index f1f0f5d0442c..f5ebad561412 100644
--- a/drivers/hwmon/ams/ams-core.c
+++ b/drivers/hwmon/ams/ams-core.c
@@ -141,10 +141,10 @@ static void ams_worker(struct work_struct *work)
141int ams_sensor_attach(void) 141int ams_sensor_attach(void)
142{ 142{
143 int result; 143 int result;
144 u32 *prop; 144 const u32 *prop;
145 145
146 /* Get orientation */ 146 /* Get orientation */
147 prop = (u32*)get_property(ams_info.of_node, "orientation", NULL); 147 prop = get_property(ams_info.of_node, "orientation", NULL);
148 if (!prop) 148 if (!prop)
149 return -ENODEV; 149 return -ENODEV;
150 ams_info.orient1 = *prop; 150 ams_info.orient1 = *prop;
diff --git a/drivers/hwmon/ams/ams-i2c.c b/drivers/hwmon/ams/ams-i2c.c
index 0d24bdfea53e..485d333bcb3e 100644
--- a/drivers/hwmon/ams/ams-i2c.c
+++ b/drivers/hwmon/ams/ams-i2c.c
@@ -263,7 +263,7 @@ int __init ams_i2c_init(struct device_node *np)
263{ 263{
264 char *tmp_bus; 264 char *tmp_bus;
265 int result; 265 int result;
266 u32 *prop; 266 const u32 *prop;
267 267
268 mutex_lock(&ams_info.lock); 268 mutex_lock(&ams_info.lock);
269 269
@@ -276,7 +276,7 @@ int __init ams_i2c_init(struct device_node *np)
276 ams_info.bustype = BUS_I2C; 276 ams_info.bustype = BUS_I2C;
277 277
278 /* look for bus either using "reg" or by path */ 278 /* look for bus either using "reg" or by path */
279 prop = (u32*)get_property(ams_info.of_node, "reg", NULL); 279 prop = get_property(ams_info.of_node, "reg", NULL);
280 if (!prop) { 280 if (!prop) {
281 result = -ENODEV; 281 result = -ENODEV;
282 282
diff --git a/drivers/hwmon/ams/ams-pmu.c b/drivers/hwmon/ams/ams-pmu.c
index 4636ae031a53..1b01c215bfe7 100644
--- a/drivers/hwmon/ams/ams-pmu.c
+++ b/drivers/hwmon/ams/ams-pmu.c
@@ -146,7 +146,7 @@ static void ams_pmu_exit(void)
146 146
147int __init ams_pmu_init(struct device_node *np) 147int __init ams_pmu_init(struct device_node *np)
148{ 148{
149 u32 *prop; 149 const u32 *prop;
150 int result; 150 int result;
151 151
152 mutex_lock(&ams_info.lock); 152 mutex_lock(&ams_info.lock);
@@ -160,7 +160,7 @@ int __init ams_pmu_init(struct device_node *np)
160 ams_info.bustype = BUS_HOST; 160 ams_info.bustype = BUS_HOST;
161 161
162 /* Get PMU command, should be 0x4e, but we can never know */ 162 /* Get PMU command, should be 0x4e, but we can never know */
163 prop = (u32*)get_property(ams_info.of_node, "reg", NULL); 163 prop = get_property(ams_info.of_node, "reg", NULL);
164 if (!prop) { 164 if (!prop) {
165 result = -ENODEV; 165 result = -ENODEV;
166 goto exit; 166 goto exit;
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index 3b23d677cb86..4700085ba834 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -565,11 +565,11 @@ static int __devinit ehca_probe(struct ibmebus_dev *dev,
565 const struct of_device_id *id) 565 const struct of_device_id *id)
566{ 566{
567 struct ehca_shca *shca; 567 struct ehca_shca *shca;
568 u64 *handle; 568 const u64 *handle;
569 struct ib_pd *ibpd; 569 struct ib_pd *ibpd;
570 int ret; 570 int ret;
571 571
572 handle = (u64 *)get_property(dev->ofdev.node, "ibm,hca-handle", NULL); 572 handle = get_property(dev->ofdev.node, "ibm,hca-handle", NULL);
573 if (!handle) { 573 if (!handle) {
574 ehca_gen_err("Cannot get eHCA handle for adapter: %s.", 574 ehca_gen_err("Cannot get eHCA handle for adapter: %s.",
575 dev->ofdev.node->full_name); 575 dev->ofdev.node->full_name);
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index f729eebf771f..adfea3c7c62a 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -90,7 +90,7 @@ static int autopoll_devs;
90int __adb_probe_sync; 90int __adb_probe_sync;
91 91
92#ifdef CONFIG_PM 92#ifdef CONFIG_PM
93static int adb_notify_sleep(struct pmu_sleep_notifier *self, int when); 93static void adb_notify_sleep(struct pmu_sleep_notifier *self, int when);
94static struct pmu_sleep_notifier adb_sleep_notifier = { 94static struct pmu_sleep_notifier adb_sleep_notifier = {
95 adb_notify_sleep, 95 adb_notify_sleep,
96 SLEEP_LEVEL_ADB, 96 SLEEP_LEVEL_ADB,
@@ -340,11 +340,9 @@ __initcall(adb_init);
340/* 340/*
341 * notify clients before sleep and reset bus afterwards 341 * notify clients before sleep and reset bus afterwards
342 */ 342 */
343int 343void
344adb_notify_sleep(struct pmu_sleep_notifier *self, int when) 344adb_notify_sleep(struct pmu_sleep_notifier *self, int when)
345{ 345{
346 int ret;
347
348 switch (when) { 346 switch (when) {
349 case PBOOK_SLEEP_REQUEST: 347 case PBOOK_SLEEP_REQUEST:
350 adb_got_sleep = 1; 348 adb_got_sleep = 1;
@@ -353,22 +351,8 @@ adb_notify_sleep(struct pmu_sleep_notifier *self, int when)
353 /* Stop autopoll */ 351 /* Stop autopoll */
354 if (adb_controller->autopoll) 352 if (adb_controller->autopoll)
355 adb_controller->autopoll(0); 353 adb_controller->autopoll(0);
356 ret = blocking_notifier_call_chain(&adb_client_list, 354 blocking_notifier_call_chain(&adb_client_list,
357 ADB_MSG_POWERDOWN, NULL); 355 ADB_MSG_POWERDOWN, NULL);
358 if (ret & NOTIFY_STOP_MASK) {
359 up(&adb_probe_mutex);
360 return PBOOK_SLEEP_REFUSE;
361 }
362 break;
363 case PBOOK_SLEEP_REJECT:
364 if (adb_got_sleep) {
365 adb_got_sleep = 0;
366 up(&adb_probe_mutex);
367 adb_reset_bus();
368 }
369 break;
370
371 case PBOOK_SLEEP_NOW:
372 break; 356 break;
373 case PBOOK_WAKE: 357 case PBOOK_WAKE:
374 adb_got_sleep = 0; 358 adb_got_sleep = 0;
@@ -376,14 +360,13 @@ adb_notify_sleep(struct pmu_sleep_notifier *self, int when)
376 adb_reset_bus(); 360 adb_reset_bus();
377 break; 361 break;
378 } 362 }
379 return PBOOK_SLEEP_OK;
380} 363}
381#endif /* CONFIG_PM */ 364#endif /* CONFIG_PM */
382 365
383static int 366static int
384do_adb_reset_bus(void) 367do_adb_reset_bus(void)
385{ 368{
386 int ret, nret; 369 int ret;
387 370
388 if (adb_controller == NULL) 371 if (adb_controller == NULL)
389 return -ENXIO; 372 return -ENXIO;
@@ -391,13 +374,8 @@ do_adb_reset_bus(void)
391 if (adb_controller->autopoll) 374 if (adb_controller->autopoll)
392 adb_controller->autopoll(0); 375 adb_controller->autopoll(0);
393 376
394 nret = blocking_notifier_call_chain(&adb_client_list, 377 blocking_notifier_call_chain(&adb_client_list,
395 ADB_MSG_PRE_RESET, NULL); 378 ADB_MSG_PRE_RESET, NULL);
396 if (nret & NOTIFY_STOP_MASK) {
397 if (adb_controller->autopoll)
398 adb_controller->autopoll(autopoll_devs);
399 return -EBUSY;
400 }
401 379
402 if (sleepy_trackpad) { 380 if (sleepy_trackpad) {
403 /* Let the trackpad settle down */ 381 /* Let the trackpad settle down */
@@ -427,10 +405,8 @@ do_adb_reset_bus(void)
427 } 405 }
428 up(&adb_handler_sem); 406 up(&adb_handler_sem);
429 407
430 nret = blocking_notifier_call_chain(&adb_client_list, 408 blocking_notifier_call_chain(&adb_client_list,
431 ADB_MSG_POST_RESET, NULL); 409 ADB_MSG_POST_RESET, NULL);
432 if (nret & NOTIFY_STOP_MASK)
433 return -EBUSY;
434 410
435 return ret; 411 return ret;
436} 412}
diff --git a/drivers/macintosh/ans-lcd.c b/drivers/macintosh/ans-lcd.c
index cdd5a0f72e3c..e54c4d9f6365 100644
--- a/drivers/macintosh/ans-lcd.c
+++ b/drivers/macintosh/ans-lcd.c
@@ -145,11 +145,12 @@ anslcd_init(void)
145 int retval; 145 int retval;
146 struct device_node* node; 146 struct device_node* node;
147 147
148 node = find_devices("lcd"); 148 node = of_find_node_by_name(NULL, "lcd");
149 if (!node || !node->parent) 149 if (!node || !node->parent || strcmp(node->parent->name, "gc")) {
150 return -ENODEV; 150 of_node_put(node);
151 if (strcmp(node->parent->name, "gc"))
152 return -ENODEV; 151 return -ENODEV;
152 }
153 of_node_put(node);
153 154
154 anslcd_ptr = ioremap(ANSLCD_ADDR, 0x20); 155 anslcd_ptr = ioremap(ANSLCD_ADDR, 0x20);
155 156
diff --git a/drivers/macintosh/apm_emu.c b/drivers/macintosh/apm_emu.c
index c5e4d43f97fc..cdb0bead9917 100644
--- a/drivers/macintosh/apm_emu.c
+++ b/drivers/macintosh/apm_emu.c
@@ -96,7 +96,7 @@ static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue);
96static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue); 96static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
97static struct apm_user * user_list; 97static struct apm_user * user_list;
98 98
99static int apm_notify_sleep(struct pmu_sleep_notifier *self, int when); 99static void apm_notify_sleep(struct pmu_sleep_notifier *self, int when);
100static struct pmu_sleep_notifier apm_sleep_notifier = { 100static struct pmu_sleep_notifier apm_sleep_notifier = {
101 apm_notify_sleep, 101 apm_notify_sleep,
102 SLEEP_LEVEL_USERLAND, 102 SLEEP_LEVEL_USERLAND,
@@ -352,7 +352,7 @@ static int do_open(struct inode * inode, struct file * filp)
352 * doesn't provide a way to NAK, but this could be added 352 * doesn't provide a way to NAK, but this could be added
353 * here. 353 * here.
354 */ 354 */
355static int wait_all_suspend(void) 355static void wait_all_suspend(void)
356{ 356{
357 DECLARE_WAITQUEUE(wait, current); 357 DECLARE_WAITQUEUE(wait, current);
358 358
@@ -366,24 +366,19 @@ static int wait_all_suspend(void)
366 remove_wait_queue(&apm_suspend_waitqueue, &wait); 366 remove_wait_queue(&apm_suspend_waitqueue, &wait);
367 367
368 DBG("apm_emu: wait_all_suspend() - complete !\n"); 368 DBG("apm_emu: wait_all_suspend() - complete !\n");
369
370 return 1;
371} 369}
372 370
373static int apm_notify_sleep(struct pmu_sleep_notifier *self, int when) 371static void apm_notify_sleep(struct pmu_sleep_notifier *self, int when)
374{ 372{
375 switch(when) { 373 switch(when) {
376 case PBOOK_SLEEP_REQUEST: 374 case PBOOK_SLEEP_REQUEST:
377 queue_event(APM_SYS_SUSPEND, NULL); 375 queue_event(APM_SYS_SUSPEND, NULL);
378 if (!wait_all_suspend()) 376 wait_all_suspend();
379 return PBOOK_SLEEP_REFUSE;
380 break; 377 break;
381 case PBOOK_SLEEP_REJECT:
382 case PBOOK_WAKE: 378 case PBOOK_WAKE:
383 queue_event(APM_NORMAL_RESUME, NULL); 379 queue_event(APM_NORMAL_RESUME, NULL);
384 break; 380 break;
385 } 381 }
386 return PBOOK_SLEEP_OK;
387} 382}
388 383
389#define APM_CRITICAL 10 384#define APM_CRITICAL 10
diff --git a/drivers/macintosh/mac_hid.c b/drivers/macintosh/mac_hid.c
index c1fd816e9f09..1599dc34f15f 100644
--- a/drivers/macintosh/mac_hid.c
+++ b/drivers/macintosh/mac_hid.c
@@ -102,8 +102,6 @@ int mac_hid_mouse_emulate_buttons(int caller, unsigned int keycode, int down)
102 return 0; 102 return 0;
103} 103}
104 104
105EXPORT_SYMBOL(mac_hid_mouse_emulate_buttons);
106
107static int emumousebtn_input_register(void) 105static int emumousebtn_input_register(void)
108{ 106{
109 int ret; 107 int ret;
diff --git a/drivers/macintosh/macio-adb.c b/drivers/macintosh/macio-adb.c
index 026b67f4f659..79119f56e82d 100644
--- a/drivers/macintosh/macio-adb.c
+++ b/drivers/macintosh/macio-adb.c
@@ -82,7 +82,14 @@ struct adb_driver macio_adb_driver = {
82 82
83int macio_probe(void) 83int macio_probe(void)
84{ 84{
85 return find_compatible_devices("adb", "chrp,adb0")? 0: -ENODEV; 85 struct device_node *np;
86
87 np = of_find_compatible_node(NULL, "adb", "chrp,adb0");
88 if (np) {
89 of_node_put(np);
90 return 0;
91 }
92 return -ENODEV;
86} 93}
87 94
88int macio_init(void) 95int macio_init(void)
@@ -91,12 +98,14 @@ int macio_init(void)
91 struct resource r; 98 struct resource r;
92 unsigned int irq; 99 unsigned int irq;
93 100
94 adbs = find_compatible_devices("adb", "chrp,adb0"); 101 adbs = of_find_compatible_node(NULL, "adb", "chrp,adb0");
95 if (adbs == 0) 102 if (adbs == 0)
96 return -ENXIO; 103 return -ENXIO;
97 104
98 if (of_address_to_resource(adbs, 0, &r)) 105 if (of_address_to_resource(adbs, 0, &r)) {
106 of_node_put(adbs);
99 return -ENXIO; 107 return -ENXIO;
108 }
100 adb = ioremap(r.start, sizeof(struct adb_regs)); 109 adb = ioremap(r.start, sizeof(struct adb_regs));
101 110
102 out_8(&adb->ctrl.r, 0); 111 out_8(&adb->ctrl.r, 0);
@@ -107,6 +116,7 @@ int macio_init(void)
107 out_8(&adb->autopoll.r, APE); 116 out_8(&adb->autopoll.r, APE);
108 117
109 irq = irq_of_parse_and_map(adbs, 0); 118 irq = irq_of_parse_and_map(adbs, 0);
119 of_node_put(adbs);
110 if (request_irq(irq, macio_adb_interrupt, 0, "ADB", (void *)0)) { 120 if (request_irq(irq, macio_adb_interrupt, 0, "ADB", (void *)0)) {
111 printk(KERN_ERR "ADB: can't get irq %d\n", irq); 121 printk(KERN_ERR "ADB: can't get irq %d\n", irq);
112 return -EAGAIN; 122 return -EAGAIN;
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index d56216067549..c96b7fe882a4 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -134,108 +134,12 @@ static int macio_device_resume(struct device * dev)
134 return 0; 134 return 0;
135} 135}
136 136
137static int macio_uevent(struct device *dev, char **envp, int num_envp,
138 char *buffer, int buffer_size)
139{
140 struct macio_dev * macio_dev;
141 struct of_device * of;
142 char *scratch;
143 const char *compat, *compat2;
144
145 int i = 0;
146 int length, cplen, cplen2, seen = 0;
147
148 if (!dev)
149 return -ENODEV;
150
151 macio_dev = to_macio_device(dev);
152 if (!macio_dev)
153 return -ENODEV;
154
155 of = &macio_dev->ofdev;
156
157 /* stuff we want to pass to /sbin/hotplug */
158 envp[i++] = scratch = buffer;
159 length = scnprintf (scratch, buffer_size, "OF_NAME=%s", of->node->name);
160 ++length;
161 buffer_size -= length;
162 if ((buffer_size <= 0) || (i >= num_envp))
163 return -ENOMEM;
164 scratch += length;
165
166 envp[i++] = scratch;
167 length = scnprintf (scratch, buffer_size, "OF_TYPE=%s", of->node->type);
168 ++length;
169 buffer_size -= length;
170 if ((buffer_size <= 0) || (i >= num_envp))
171 return -ENOMEM;
172 scratch += length;
173
174 /* Since the compatible field can contain pretty much anything
175 * it's not really legal to split it out with commas. We split it
176 * up using a number of environment variables instead. */
177
178 compat = get_property(of->node, "compatible", &cplen);
179 compat2 = compat;
180 cplen2= cplen;
181 while (compat && cplen > 0) {
182 envp[i++] = scratch;
183 length = scnprintf (scratch, buffer_size,
184 "OF_COMPATIBLE_%d=%s", seen, compat);
185 ++length;
186 buffer_size -= length;
187 if ((buffer_size <= 0) || (i >= num_envp))
188 return -ENOMEM;
189 scratch += length;
190 length = strlen (compat) + 1;
191 compat += length;
192 cplen -= length;
193 seen++;
194 }
195
196 envp[i++] = scratch;
197 length = scnprintf (scratch, buffer_size, "OF_COMPATIBLE_N=%d", seen);
198 ++length;
199 buffer_size -= length;
200 if ((buffer_size <= 0) || (i >= num_envp))
201 return -ENOMEM;
202 scratch += length;
203
204 envp[i++] = scratch;
205 length = scnprintf (scratch, buffer_size, "MODALIAS=of:N%sT%s",
206 of->node->name, of->node->type);
207 /* overwrite '\0' */
208 buffer_size -= length;
209 if ((buffer_size <= 0) || (i >= num_envp))
210 return -ENOMEM;
211 scratch += length;
212
213 if (!compat2) {
214 compat2 = "";
215 cplen2 = 1;
216 }
217 while (cplen2 > 0) {
218 length = snprintf (scratch, buffer_size, "C%s", compat2);
219 buffer_size -= length;
220 if (buffer_size <= 0)
221 return -ENOMEM;
222 scratch += length;
223 length = strlen (compat2) + 1;
224 compat2 += length;
225 cplen2 -= length;
226 }
227
228 envp[i] = NULL;
229
230 return 0;
231}
232
233extern struct device_attribute macio_dev_attrs[]; 137extern struct device_attribute macio_dev_attrs[];
234 138
235struct bus_type macio_bus_type = { 139struct bus_type macio_bus_type = {
236 .name = "macio", 140 .name = "macio",
237 .match = macio_bus_match, 141 .match = macio_bus_match,
238 .uevent = macio_uevent, 142 .uevent = of_device_uevent,
239 .probe = macio_device_probe, 143 .probe = macio_device_probe,
240 .remove = macio_device_remove, 144 .remove = macio_device_remove,
241 .shutdown = macio_device_shutdown, 145 .shutdown = macio_device_shutdown,
@@ -491,7 +395,7 @@ static struct macio_dev * macio_add_one_device(struct macio_chip *chip,
491#endif 395#endif
492 MAX_NODE_NAME_SIZE, np->name); 396 MAX_NODE_NAME_SIZE, np->name);
493 } else { 397 } else {
494 reg = get_property(np, "reg", NULL); 398 reg = of_get_property(np, "reg", NULL);
495 sprintf(dev->ofdev.dev.bus_id, "%1d.%08x:%.*s", 399 sprintf(dev->ofdev.dev.bus_id, "%1d.%08x:%.*s",
496 chip->lbus.index, 400 chip->lbus.index,
497 reg ? *reg : 0, MAX_NODE_NAME_SIZE, np->name); 401 reg ? *reg : 0, MAX_NODE_NAME_SIZE, np->name);
diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c
index 8566bdfdd4b8..cc8267912656 100644
--- a/drivers/macintosh/macio_sysfs.c
+++ b/drivers/macintosh/macio_sysfs.c
@@ -21,7 +21,7 @@ compatible_show (struct device *dev, struct device_attribute *attr, char *buf)
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 = get_property(of->node, "compatible", &cplen); 24 compat = of_get_property(of->node, "compatible", &cplen);
25 if (!compat) { 25 if (!compat) {
26 *buf = '\0'; 26 *buf = '\0';
27 return 0; 27 return 0;
@@ -47,18 +47,20 @@ static ssize_t modalias_show (struct device *dev, struct device_attribute *attr,
47 int length; 47 int length;
48 48
49 of = &to_macio_device (dev)->ofdev; 49 of = &to_macio_device (dev)->ofdev;
50 compat = get_property(of->node, "compatible", &cplen); 50 compat = of_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;
54 while (cplen > 0) { 54 while (cplen > 0) {
55 int l; 55 int l;
56 length += sprintf (buf, "C%s", compat); 56 l = sprintf (buf, "C%s", compat);
57 buf += length; 57 length += l;
58 buf += l;
58 l = strlen (compat) + 1; 59 l = strlen (compat) + 1;
59 compat += l; 60 compat += l;
60 cplen -= l; 61 cplen -= l;
61 } 62 }
63 length += sprintf(buf, "\n");
62 64
63 return length; 65 return length;
64} 66}
diff --git a/drivers/macintosh/rack-meter.c b/drivers/macintosh/rack-meter.c
index f83fad2a3ff4..4177ff004753 100644
--- a/drivers/macintosh/rack-meter.c
+++ b/drivers/macintosh/rack-meter.c
@@ -387,7 +387,7 @@ static int __devinit rackmeter_probe(struct macio_dev* mdev,
387 if (strcmp(np->name, "lightshow") == 0) 387 if (strcmp(np->name, "lightshow") == 0)
388 break; 388 break;
389 if ((strcmp(np->name, "sound") == 0) && 389 if ((strcmp(np->name, "sound") == 0) &&
390 get_property(np, "virtual", NULL) != NULL) 390 of_get_property(np, "virtual", NULL) != NULL)
391 break; 391 break;
392 } 392 }
393 if (np == NULL) { 393 if (np == NULL) {
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index c9f3dc4fd3ee..a98a328b1cfc 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -491,7 +491,7 @@ int __init smu_init (void)
491 printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n"); 491 printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n");
492 goto fail; 492 goto fail;
493 } 493 }
494 data = get_property(smu->db_node, "reg", NULL); 494 data = of_get_property(smu->db_node, "reg", NULL);
495 if (data == NULL) { 495 if (data == NULL) {
496 of_node_put(smu->db_node); 496 of_node_put(smu->db_node);
497 smu->db_node = NULL; 497 smu->db_node = NULL;
@@ -512,7 +512,7 @@ int __init smu_init (void)
512 smu->msg_node = of_find_node_by_name(NULL, "smu-interrupt"); 512 smu->msg_node = of_find_node_by_name(NULL, "smu-interrupt");
513 if (smu->msg_node == NULL) 513 if (smu->msg_node == NULL)
514 break; 514 break;
515 data = get_property(smu->msg_node, "reg", NULL); 515 data = of_get_property(smu->msg_node, "reg", NULL);
516 if (data == NULL) { 516 if (data == NULL) {
517 of_node_put(smu->msg_node); 517 of_node_put(smu->msg_node);
518 smu->msg_node = NULL; 518 smu->msg_node = NULL;
@@ -952,7 +952,7 @@ static struct smu_sdbp_header *smu_create_sdb_partition(int id)
952 prop->name = ((char *)prop) + tlen - 18; 952 prop->name = ((char *)prop) + tlen - 18;
953 sprintf(prop->name, "sdb-partition-%02x", id); 953 sprintf(prop->name, "sdb-partition-%02x", id);
954 prop->length = len; 954 prop->length = len;
955 prop->value = (unsigned char *)hdr; 955 prop->value = hdr;
956 prop->next = NULL; 956 prop->next = NULL;
957 957
958 /* Read the datablock */ 958 /* Read the datablock */
@@ -1004,7 +1004,7 @@ const struct smu_sdbp_header *__smu_get_sdb_partition(int id,
1004 } else 1004 } else
1005 mutex_lock(&smu_part_access); 1005 mutex_lock(&smu_part_access);
1006 1006
1007 part = get_property(smu->of_node, pname, size); 1007 part = of_get_property(smu->of_node, pname, size);
1008 if (part == NULL) { 1008 if (part == NULL) {
1009 DPRINTK("trying to extract from SMU ...\n"); 1009 DPRINTK("trying to extract from SMU ...\n");
1010 part = smu_create_sdb_partition(id); 1010 part = smu_create_sdb_partition(id);
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index a7ce55926638..228903403cfc 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -567,13 +567,13 @@ thermostat_init(void)
567 else 567 else
568 return -ENODEV; 568 return -ENODEV;
569 569
570 prop = get_property(np, "hwsensor-params-version", NULL); 570 prop = of_get_property(np, "hwsensor-params-version", NULL);
571 printk(KERN_INFO "adt746x: version %d (%ssupported)\n", *prop, 571 printk(KERN_INFO "adt746x: version %d (%ssupported)\n", *prop,
572 (*prop == 1)?"":"un"); 572 (*prop == 1)?"":"un");
573 if (*prop != 1) 573 if (*prop != 1)
574 return -ENODEV; 574 return -ENODEV;
575 575
576 prop = get_property(np, "reg", NULL); 576 prop = of_get_property(np, "reg", NULL);
577 if (!prop) 577 if (!prop)
578 return -ENODEV; 578 return -ENODEV;
579 579
@@ -591,9 +591,9 @@ thermostat_init(void)
591 "limit_adjust: %d, fan_speed: %d\n", 591 "limit_adjust: %d, fan_speed: %d\n",
592 therm_bus, therm_address, limit_adjust, fan_speed); 592 therm_bus, therm_address, limit_adjust, fan_speed);
593 593
594 if (get_property(np, "hwsensor-location", NULL)) { 594 if (of_get_property(np, "hwsensor-location", NULL)) {
595 for (i = 0; i < 3; i++) { 595 for (i = 0; i < 3; i++) {
596 sensor_location[i] = get_property(np, 596 sensor_location[i] = of_get_property(np,
597 "hwsensor-location", NULL) + offset; 597 "hwsensor-location", NULL) + offset;
598 598
599 if (sensor_location[i] == NULL) 599 if (sensor_location[i] == NULL)
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 2e4ad44a8636..78ff18617139 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -674,7 +674,7 @@ static int read_eeprom(int cpu, struct mpu_data *out)
674 printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid node from device-tree\n"); 674 printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid node from device-tree\n");
675 return -ENODEV; 675 return -ENODEV;
676 } 676 }
677 data = get_property(np, "cpuid", &len); 677 data = of_get_property(np, "cpuid", &len);
678 if (data == NULL) { 678 if (data == NULL) {
679 printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid property from device-tree\n"); 679 printk(KERN_ERR "therm_pm72: Failed to retrieve cpuid property from device-tree\n");
680 of_node_put(np); 680 of_node_put(np);
@@ -1337,7 +1337,7 @@ static int init_backside_state(struct backside_pid_state *state)
1337 */ 1337 */
1338 u3 = of_find_node_by_path("/u3@0,f8000000"); 1338 u3 = of_find_node_by_path("/u3@0,f8000000");
1339 if (u3 != NULL) { 1339 if (u3 != NULL) {
1340 const u32 *vers = get_property(u3, "device-rev", NULL); 1340 const u32 *vers = of_get_property(u3, "device-rev", NULL);
1341 if (vers) 1341 if (vers)
1342 if (((*vers) & 0x3f) < 0x34) 1342 if (((*vers) & 0x3f) < 0x34)
1343 u3h = 0; 1343 u3h = 0;
@@ -2129,8 +2129,8 @@ static void fcu_lookup_fans(struct device_node *fcu_node)
2129 continue; 2129 continue;
2130 2130
2131 /* Lookup for a matching location */ 2131 /* Lookup for a matching location */
2132 loc = get_property(np, "location", NULL); 2132 loc = of_get_property(np, "location", NULL);
2133 reg = get_property(np, "reg", NULL); 2133 reg = of_get_property(np, "reg", NULL);
2134 if (loc == NULL || reg == NULL) 2134 if (loc == NULL || reg == NULL)
2135 continue; 2135 continue;
2136 DBG(" matching location: %s, reg: 0x%08x\n", loc, *reg); 2136 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 a1d3a987cb3a..35233de460ad 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -492,7 +492,7 @@ g4fan_init( void )
492 492
493 if( !(np=of_find_node_by_name(NULL, "power-mgt")) ) 493 if( !(np=of_find_node_by_name(NULL, "power-mgt")) )
494 return -ENODEV; 494 return -ENODEV;
495 info = get_property(np, "thermal-info", NULL); 495 info = of_get_property(np, "thermal-info", NULL);
496 of_node_put(np); 496 of_node_put(np);
497 497
498 if( !info || !machine_is_compatible("PowerMac3,6") ) 498 if( !info || !machine_is_compatible("PowerMac3,6") )
diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c
index d58fcf6cca0a..76d21775fc35 100644
--- a/drivers/macintosh/via-cuda.c
+++ b/drivers/macintosh/via-cuda.c
@@ -131,7 +131,7 @@ int __init find_via_cuda(void)
131 if (vias == 0) 131 if (vias == 0)
132 return 0; 132 return 0;
133 133
134 reg = get_property(vias, "reg", NULL); 134 reg = of_get_property(vias, "reg", NULL);
135 if (reg == NULL) { 135 if (reg == NULL) {
136 printk(KERN_ERR "via-cuda: No \"reg\" property !\n"); 136 printk(KERN_ERR "via-cuda: No \"reg\" property !\n");
137 goto fail; 137 goto fail;
diff --git a/drivers/macintosh/via-pmu-led.c b/drivers/macintosh/via-pmu-led.c
index 179af10105d9..fc89a7047cd0 100644
--- a/drivers/macintosh/via-pmu-led.c
+++ b/drivers/macintosh/via-pmu-led.c
@@ -81,7 +81,7 @@ static struct led_classdev pmu_led = {
81}; 81};
82 82
83#ifdef CONFIG_PM 83#ifdef CONFIG_PM
84static int pmu_led_sleep_call(struct pmu_sleep_notifier *self, int when) 84static void pmu_led_sleep_call(struct pmu_sleep_notifier *self, int when)
85{ 85{
86 unsigned long flags; 86 unsigned long flags;
87 87
@@ -99,8 +99,6 @@ static int pmu_led_sleep_call(struct pmu_sleep_notifier *self, int when)
99 break; 99 break;
100 } 100 }
101 spin_unlock_irqrestore(&pmu_blink_lock, flags); 101 spin_unlock_irqrestore(&pmu_blink_lock, flags);
102
103 return PBOOK_SLEEP_OK;
104} 102}
105 103
106static struct pmu_sleep_notifier via_pmu_led_sleep_notif = { 104static struct pmu_sleep_notifier via_pmu_led_sleep_notif = {
@@ -120,11 +118,13 @@ static int __init via_pmu_led_init(void)
120 dt = of_find_node_by_path("/"); 118 dt = of_find_node_by_path("/");
121 if (dt == NULL) 119 if (dt == NULL)
122 return -ENODEV; 120 return -ENODEV;
123 model = get_property(dt, "model", NULL); 121 model = of_get_property(dt, "model", NULL);
124 if (model == NULL) 122 if (model == NULL)
125 return -ENODEV; 123 return -ENODEV;
126 if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 && 124 if (strncmp(model, "PowerBook", strlen("PowerBook")) != 0 &&
127 strncmp(model, "iBook", strlen("iBook")) != 0) { 125 strncmp(model, "iBook", strlen("iBook")) != 0 &&
126 strcmp(model, "PowerMac7,2") != 0 &&
127 strcmp(model, "PowerMac7,3") != 0) {
128 of_node_put(dt); 128 of_node_put(dt);
129 /* ignore */ 129 /* ignore */
130 return -ENODEV; 130 return -ENODEV;
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index b6073bdb50c3..1729d3fd7a11 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -289,7 +289,7 @@ int __init find_via_pmu(void)
289 if (vias == NULL) 289 if (vias == NULL)
290 return 0; 290 return 0;
291 291
292 reg = get_property(vias, "reg", NULL); 292 reg = of_get_property(vias, "reg", NULL);
293 if (reg == NULL) { 293 if (reg == NULL) {
294 printk(KERN_ERR "via-pmu: No \"reg\" property !\n"); 294 printk(KERN_ERR "via-pmu: No \"reg\" property !\n");
295 goto fail; 295 goto fail;
@@ -319,10 +319,13 @@ int __init find_via_pmu(void)
319 else if (device_is_compatible(vias->parent, "Keylargo") 319 else if (device_is_compatible(vias->parent, "Keylargo")
320 || device_is_compatible(vias->parent, "K2-Keylargo")) { 320 || device_is_compatible(vias->parent, "K2-Keylargo")) {
321 struct device_node *gpiop; 321 struct device_node *gpiop;
322 struct device_node *adbp;
322 u64 gaddr = OF_BAD_ADDR; 323 u64 gaddr = OF_BAD_ADDR;
323 324
324 pmu_kind = PMU_KEYLARGO_BASED; 325 pmu_kind = PMU_KEYLARGO_BASED;
325 pmu_has_adb = (find_type_devices("adb") != NULL); 326 adbp = of_find_node_by_type(NULL, "adb");
327 pmu_has_adb = (adbp != NULL);
328 of_node_put(adbp);
326 pmu_intr_mask = PMU_INT_PCEJECT | 329 pmu_intr_mask = PMU_INT_PCEJECT |
327 PMU_INT_SNDBRT | 330 PMU_INT_SNDBRT |
328 PMU_INT_ADB | 331 PMU_INT_ADB |
@@ -331,7 +334,7 @@ int __init find_via_pmu(void)
331 334
332 gpiop = of_find_node_by_name(NULL, "gpio"); 335 gpiop = of_find_node_by_name(NULL, "gpio");
333 if (gpiop) { 336 if (gpiop) {
334 reg = get_property(gpiop, "reg", NULL); 337 reg = of_get_property(gpiop, "reg", NULL);
335 if (reg) 338 if (reg)
336 gaddr = of_translate_address(gpiop, reg); 339 gaddr = of_translate_address(gpiop, reg);
337 if (gaddr != OF_BAD_ADDR) 340 if (gaddr != OF_BAD_ADDR)
@@ -484,10 +487,11 @@ static int __init via_pmu_dev_init(void)
484 pmu_batteries[0].flags |= PMU_BATT_TYPE_SMART; 487 pmu_batteries[0].flags |= PMU_BATT_TYPE_SMART;
485 pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; 488 pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART;
486 } else { 489 } else {
487 struct device_node* prim = find_devices("power-mgt"); 490 struct device_node* prim =
491 of_find_node_by_name(NULL, "power-mgt");
488 const u32 *prim_info = NULL; 492 const u32 *prim_info = NULL;
489 if (prim) 493 if (prim)
490 prim_info = get_property(prim, "prim-info", NULL); 494 prim_info = of_get_property(prim, "prim-info", NULL);
491 if (prim_info) { 495 if (prim_info) {
492 /* Other stuffs here yet unknown */ 496 /* Other stuffs here yet unknown */
493 pmu_battery_count = (prim_info[6] >> 16) & 0xff; 497 pmu_battery_count = (prim_info[6] >> 16) & 0xff;
@@ -495,6 +499,7 @@ static int __init via_pmu_dev_init(void)
495 if (pmu_battery_count > 1) 499 if (pmu_battery_count > 1)
496 pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; 500 pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART;
497 } 501 }
502 of_node_put(prim);
498 } 503 }
499#endif /* CONFIG_PPC32 */ 504#endif /* CONFIG_PPC32 */
500 505
@@ -1769,35 +1774,21 @@ EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
1769#if defined(CONFIG_PM) && defined(CONFIG_PPC32) 1774#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
1770 1775
1771/* Sleep is broadcast last-to-first */ 1776/* Sleep is broadcast last-to-first */
1772static int 1777static void broadcast_sleep(int when)
1773broadcast_sleep(int when, int fallback)
1774{ 1778{
1775 int ret = PBOOK_SLEEP_OK;
1776 struct list_head *list; 1779 struct list_head *list;
1777 struct pmu_sleep_notifier *notifier; 1780 struct pmu_sleep_notifier *notifier;
1778 1781
1779 for (list = sleep_notifiers.prev; list != &sleep_notifiers; 1782 for (list = sleep_notifiers.prev; list != &sleep_notifiers;
1780 list = list->prev) { 1783 list = list->prev) {
1781 notifier = list_entry(list, struct pmu_sleep_notifier, list); 1784 notifier = list_entry(list, struct pmu_sleep_notifier, list);
1782 ret = notifier->notifier_call(notifier, when); 1785 notifier->notifier_call(notifier, when);
1783 if (ret != PBOOK_SLEEP_OK) {
1784 printk(KERN_DEBUG "sleep %d rejected by %p (%p)\n",
1785 when, notifier, notifier->notifier_call);
1786 for (; list != &sleep_notifiers; list = list->next) {
1787 notifier = list_entry(list, struct pmu_sleep_notifier, list);
1788 notifier->notifier_call(notifier, fallback);
1789 }
1790 return ret;
1791 }
1792 } 1786 }
1793 return ret;
1794} 1787}
1795 1788
1796/* Wake is broadcast first-to-last */ 1789/* Wake is broadcast first-to-last */
1797static int 1790static void broadcast_wake(void)
1798broadcast_wake(void)
1799{ 1791{
1800 int ret = PBOOK_SLEEP_OK;
1801 struct list_head *list; 1792 struct list_head *list;
1802 struct pmu_sleep_notifier *notifier; 1793 struct pmu_sleep_notifier *notifier;
1803 1794
@@ -1806,7 +1797,6 @@ broadcast_wake(void)
1806 notifier = list_entry(list, struct pmu_sleep_notifier, list); 1797 notifier = list_entry(list, struct pmu_sleep_notifier, list);
1807 notifier->notifier_call(notifier, PBOOK_WAKE); 1798 notifier->notifier_call(notifier, PBOOK_WAKE);
1808 } 1799 }
1809 return ret;
1810} 1800}
1811 1801
1812/* 1802/*
@@ -2013,12 +2003,8 @@ pmac_suspend_devices(void)
2013 2003
2014 pm_prepare_console(); 2004 pm_prepare_console();
2015 2005
2016 /* Notify old-style device drivers & userland */ 2006 /* Notify old-style device drivers */
2017 ret = broadcast_sleep(PBOOK_SLEEP_REQUEST, PBOOK_SLEEP_REJECT); 2007 broadcast_sleep(PBOOK_SLEEP_REQUEST);
2018 if (ret != PBOOK_SLEEP_OK) {
2019 printk(KERN_ERR "Sleep rejected by drivers\n");
2020 return -EBUSY;
2021 }
2022 2008
2023 /* Sync the disks. */ 2009 /* Sync the disks. */
2024 /* XXX It would be nice to have some way to ensure that 2010 /* XXX It would be nice to have some way to ensure that
@@ -2028,12 +2014,7 @@ pmac_suspend_devices(void)
2028 */ 2014 */
2029 sys_sync(); 2015 sys_sync();
2030 2016
2031 /* Sleep can fail now. May not be very robust but useful for debugging */ 2017 broadcast_sleep(PBOOK_SLEEP_NOW);
2032 ret = broadcast_sleep(PBOOK_SLEEP_NOW, PBOOK_WAKE);
2033 if (ret != PBOOK_SLEEP_OK) {
2034 printk(KERN_ERR "Driver sleep failed\n");
2035 return -EBUSY;
2036 }
2037 2018
2038 /* Send suspend call to devices, hold the device core's dpm_sem */ 2019 /* Send suspend call to devices, hold the device core's dpm_sem */
2039 ret = device_suspend(PMSG_SUSPEND); 2020 ret = device_suspend(PMSG_SUSPEND);
@@ -2154,7 +2135,7 @@ static int powerbook_sleep_grackle(void)
2154 int ret; 2135 int ret;
2155 struct pci_dev *grackle; 2136 struct pci_dev *grackle;
2156 2137
2157 grackle = pci_find_slot(0, 0); 2138 grackle = pci_get_bus_and_slot(0, 0);
2158 if (!grackle) 2139 if (!grackle)
2159 return -ENODEV; 2140 return -ENODEV;
2160 2141
@@ -2202,6 +2183,8 @@ static int powerbook_sleep_grackle(void)
2202 pmcr1 &= ~(GRACKLE_PM|GRACKLE_DOZE|GRACKLE_SLEEP|GRACKLE_NAP); 2183 pmcr1 &= ~(GRACKLE_PM|GRACKLE_DOZE|GRACKLE_SLEEP|GRACKLE_NAP);
2203 pci_write_config_word(grackle, 0x70, pmcr1); 2184 pci_write_config_word(grackle, 0x70, pmcr1);
2204 2185
2186 pci_dev_put(grackle);
2187
2205 /* Make sure the PMU is idle */ 2188 /* Make sure the PMU is idle */
2206 pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,0); 2189 pmac_call_feature(PMAC_FTR_SLEEP_STATE,NULL,0,0);
2207 restore_via_state(); 2190 restore_via_state();
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c
index 3f7967feaf5b..ab4d1b63f63e 100644
--- a/drivers/macintosh/windfarm_lm75_sensor.c
+++ b/drivers/macintosh/windfarm_lm75_sensor.c
@@ -176,7 +176,7 @@ static int wf_lm75_attach(struct i2c_adapter *adapter)
176 for (dev = NULL; 176 for (dev = NULL;
177 (dev = of_get_next_child(busnode, dev)) != NULL;) { 177 (dev = of_get_next_child(busnode, dev)) != NULL;) {
178 const char *loc = 178 const char *loc =
179 get_property(dev, "hwsensor-location", NULL); 179 of_get_property(dev, "hwsensor-location", NULL);
180 u8 addr; 180 u8 addr;
181 181
182 /* We must re-match the adapter in order to properly check 182 /* We must re-match the adapter in order to properly check
diff --git a/drivers/macintosh/windfarm_max6690_sensor.c b/drivers/macintosh/windfarm_max6690_sensor.c
index eae1189d6c41..eaa74afa175b 100644
--- a/drivers/macintosh/windfarm_max6690_sensor.c
+++ b/drivers/macintosh/windfarm_max6690_sensor.c
@@ -134,7 +134,7 @@ static int wf_max6690_attach(struct i2c_adapter *adapter)
134 if (!device_is_compatible(dev, "max6690")) 134 if (!device_is_compatible(dev, "max6690"))
135 continue; 135 continue;
136 addr = pmac_i2c_get_dev_addr(dev); 136 addr = pmac_i2c_get_dev_addr(dev);
137 loc = get_property(dev, "hwsensor-location", NULL); 137 loc = of_get_property(dev, "hwsensor-location", NULL);
138 if (loc == NULL || addr == 0) 138 if (loc == NULL || addr == 0)
139 continue; 139 continue;
140 printk("found max6690, loc=%s addr=0x%02x\n", loc, addr); 140 printk("found max6690, loc=%s addr=0x%02x\n", loc, addr);
diff --git a/drivers/macintosh/windfarm_smu_controls.c b/drivers/macintosh/windfarm_smu_controls.c
index 31b750d61206..ff398adc0283 100644
--- a/drivers/macintosh/windfarm_smu_controls.c
+++ b/drivers/macintosh/windfarm_smu_controls.c
@@ -167,7 +167,7 @@ static struct smu_fan_control *smu_fan_create(struct device_node *node,
167 if (fct == NULL) 167 if (fct == NULL)
168 return NULL; 168 return NULL;
169 fct->ctrl.ops = &smu_fan_ops; 169 fct->ctrl.ops = &smu_fan_ops;
170 l = get_property(node, "location", NULL); 170 l = of_get_property(node, "location", NULL);
171 if (l == NULL) 171 if (l == NULL)
172 goto fail; 172 goto fail;
173 173
@@ -224,17 +224,17 @@ static struct smu_fan_control *smu_fan_create(struct device_node *node,
224 goto fail; 224 goto fail;
225 225
226 /* Get min & max values*/ 226 /* Get min & max values*/
227 v = get_property(node, "min-value", NULL); 227 v = of_get_property(node, "min-value", NULL);
228 if (v == NULL) 228 if (v == NULL)
229 goto fail; 229 goto fail;
230 fct->min = *v; 230 fct->min = *v;
231 v = get_property(node, "max-value", NULL); 231 v = of_get_property(node, "max-value", NULL);
232 if (v == NULL) 232 if (v == NULL)
233 goto fail; 233 goto fail;
234 fct->max = *v; 234 fct->max = *v;
235 235
236 /* Get "reg" value */ 236 /* Get "reg" value */
237 reg = get_property(node, "reg", NULL); 237 reg = of_get_property(node, "reg", NULL);
238 if (reg == NULL) 238 if (reg == NULL)
239 goto fail; 239 goto fail;
240 fct->reg = *reg; 240 fct->reg = *reg;
diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c
index 83f79de7174b..9a6c2cf8fd0e 100644
--- a/drivers/macintosh/windfarm_smu_sat.c
+++ b/drivers/macintosh/windfarm_smu_sat.c
@@ -241,7 +241,7 @@ static void wf_sat_create(struct i2c_adapter *adapter, struct device_node *dev)
241 char *name; 241 char *name;
242 int vsens[2], isens[2]; 242 int vsens[2], isens[2];
243 243
244 reg = get_property(dev, "reg", NULL); 244 reg = of_get_property(dev, "reg", NULL);
245 if (reg == NULL) 245 if (reg == NULL)
246 return; 246 return;
247 addr = *reg; 247 addr = *reg;
@@ -268,9 +268,9 @@ 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 = get_property(child, "reg", NULL); 271 reg = of_get_property(child, "reg", NULL);
272 type = get_property(child, "device_type", NULL); 272 type = of_get_property(child, "device_type", NULL);
273 loc = get_property(child, "location", NULL); 273 loc = of_get_property(child, "location", NULL);
274 if (reg == NULL || loc == NULL) 274 if (reg == NULL || loc == NULL)
275 continue; 275 continue;
276 276
diff --git a/drivers/macintosh/windfarm_smu_sensors.c b/drivers/macintosh/windfarm_smu_sensors.c
index 01b4c50143dd..9c567b93f417 100644
--- a/drivers/macintosh/windfarm_smu_sensors.c
+++ b/drivers/macintosh/windfarm_smu_sensors.c
@@ -204,8 +204,8 @@ static struct smu_ad_sensor *smu_ads_create(struct device_node *node)
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 = get_property(node, "device_type", NULL); 207 c = of_get_property(node, "device_type", NULL);
208 l = get_property(node, "location", NULL); 208 l = of_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 = get_property(node, "reg", NULL); 258 v = of_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;
diff --git a/drivers/media/video/planb.c b/drivers/media/video/planb.c
index fe184f93c016..1455a8f4e930 100644
--- a/drivers/media/video/planb.c
+++ b/drivers/media/video/planb.c
@@ -2160,7 +2160,7 @@ static int find_planb(void)
2160 if (!machine_is(powermac)) 2160 if (!machine_is(powermac))
2161 return 0; 2161 return 0;
2162 2162
2163 planb_devices = find_devices("planb"); 2163 planb_devices = of_find_node_by_name(NULL, "planb");
2164 if (planb_devices == 0) { 2164 if (planb_devices == 0) {
2165 planb_num=0; 2165 planb_num=0;
2166 printk(KERN_WARNING "PlanB: no device found!\n"); 2166 printk(KERN_WARNING "PlanB: no device found!\n");
@@ -2175,12 +2175,14 @@ static int find_planb(void)
2175 if (planb_devices->n_addrs != 1) { 2175 if (planb_devices->n_addrs != 1) {
2176 printk (KERN_WARNING "PlanB: expecting 1 address for planb " 2176 printk (KERN_WARNING "PlanB: expecting 1 address for planb "
2177 "(got %d)", planb_devices->n_addrs); 2177 "(got %d)", planb_devices->n_addrs);
2178 of_node_put(planb_devices);
2178 return 0; 2179 return 0;
2179 } 2180 }
2180 2181
2181 if (planb_devices->n_intrs == 0) { 2182 if (planb_devices->n_intrs == 0) {
2182 printk(KERN_WARNING "PlanB: no intrs for device %s\n", 2183 printk(KERN_WARNING "PlanB: no intrs for device %s\n",
2183 planb_devices->full_name); 2184 planb_devices->full_name);
2185 of_node_put(planb_devices);
2184 return 0; 2186 return 0;
2185 } else { 2187 } else {
2186 irq = planb_devices->intrs[0].line; 2188 irq = planb_devices->intrs[0].line;
@@ -2202,6 +2204,7 @@ static int find_planb(void)
2202 confreg = planb_devices->addrs[0].space & 0xff; 2204 confreg = planb_devices->addrs[0].space & 0xff;
2203 old_base = planb_devices->addrs[0].address; 2205 old_base = planb_devices->addrs[0].address;
2204 new_base = 0xf1000000; 2206 new_base = 0xf1000000;
2207 of_node_put(planb_devices);
2205 2208
2206 DEBUG("PlanB: Found on bus %d, dev %d, func %d, " 2209 DEBUG("PlanB: Found on bus %d, dev %d, func %d, "
2207 "membase 0x%x (base reg. 0x%x)\n", 2210 "membase 0x%x (base reg. 0x%x)\n",
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 545c405a5cb0..eb4b96c4d388 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2274,11 +2274,12 @@ config GFAR_NAPI
2274 depends on GIANFAR 2274 depends on GIANFAR
2275 2275
2276config UCC_GETH 2276config UCC_GETH
2277 tristate "Freescale QE UCC GETH" 2277 tristate "Freescale QE Gigabit Ethernet"
2278 depends on QUICC_ENGINE && UCC_FAST 2278 depends on QUICC_ENGINE
2279 select UCC_FAST
2279 help 2280 help
2280 This driver supports the Gigabit Ethernet mode of QE UCC. 2281 This driver supports the Gigabit Ethernet mode of the QUICC Engine,
2281 QE can be found on MPC836x CPUs. 2282 which is available on some Freescale SOCs.
2282 2283
2283config UGETH_NAPI 2284config UGETH_NAPI
2284 bool "NAPI Support" 2285 bool "NAPI Support"
diff --git a/drivers/ps3/vuart.c b/drivers/ps3/vuart.c
index 6c12744eeb9d..7d7cab1d91b4 100644
--- a/drivers/ps3/vuart.c
+++ b/drivers/ps3/vuart.c
@@ -82,14 +82,6 @@ struct ports_bmp {
82 u64 unused[3]; 82 u64 unused[3];
83} __attribute__ ((aligned (32))); 83} __attribute__ ((aligned (32)));
84 84
85/* redefine dev_dbg to do a syntax check */
86
87#if !defined(DEBUG)
88#undef dev_dbg
89static inline int __attribute__ ((format (printf, 2, 3))) dev_dbg(
90 const struct device *_dev, const char *fmt, ...) {return 0;}
91#endif
92
93#define dump_ports_bmp(_b) _dump_ports_bmp(_b, __func__, __LINE__) 85#define dump_ports_bmp(_b) _dump_ports_bmp(_b, __func__, __LINE__)
94static void __attribute__ ((unused)) _dump_ports_bmp( 86static void __attribute__ ((unused)) _dump_ports_bmp(
95 const struct ports_bmp* bmp, const char* func, int line) 87 const struct ports_bmp* bmp, const char* func, int line)
diff --git a/drivers/scsi/ibmvscsi/ibmvstgt.c b/drivers/scsi/ibmvscsi/ibmvstgt.c
index 4368ca0e8270..a39a478bb39a 100644
--- a/drivers/scsi/ibmvscsi/ibmvstgt.c
+++ b/drivers/scsi/ibmvscsi/ibmvstgt.c
@@ -897,9 +897,9 @@ static int get_system_info(void)
897{ 897{
898 struct device_node *rootdn; 898 struct device_node *rootdn;
899 const char *id, *model, *name; 899 const char *id, *model, *name;
900 unsigned int *num; 900 const unsigned int *num;
901 901
902 rootdn = find_path_device("/"); 902 rootdn = of_find_node_by_path("/");
903 if (!rootdn) 903 if (!rootdn)
904 return -ENOENT; 904 return -ENOENT;
905 905
@@ -912,10 +912,11 @@ static int get_system_info(void)
912 if (name) 912 if (name)
913 strncpy(partition_name, name, sizeof(partition_name)); 913 strncpy(partition_name, name, sizeof(partition_name));
914 914
915 num = (unsigned int *) get_property(rootdn, "ibm,partition-no", NULL); 915 num = get_property(rootdn, "ibm,partition-no", NULL);
916 if (num) 916 if (num)
917 partition_number = *num; 917 partition_number = *num;
918 918
919 of_node_put(rootdn);
919 return 0; 920 return 0;
920} 921}
921 922
diff --git a/drivers/scsi/ibmvscsi/rpa_vscsi.c b/drivers/scsi/ibmvscsi/rpa_vscsi.c
index 227c0f2f4d74..0a533f398f52 100644
--- a/drivers/scsi/ibmvscsi/rpa_vscsi.c
+++ b/drivers/scsi/ibmvscsi/rpa_vscsi.c
@@ -157,7 +157,7 @@ static void gather_partition_info(void)
157 const unsigned int *p_number_ptr; 157 const unsigned int *p_number_ptr;
158 158
159 /* Retrieve information about this partition */ 159 /* Retrieve information about this partition */
160 rootdn = find_path_device("/"); 160 rootdn = of_find_node_by_path("/");
161 if (!rootdn) { 161 if (!rootdn) {
162 return; 162 return;
163 } 163 }
@@ -169,6 +169,7 @@ static void gather_partition_info(void)
169 p_number_ptr = get_property(rootdn, "ibm,partition-no", NULL); 169 p_number_ptr = get_property(rootdn, "ibm,partition-no", NULL);
170 if (p_number_ptr) 170 if (p_number_ptr)
171 partition_number = *p_number_ptr; 171 partition_number = *p_number_ptr;
172 of_node_put(rootdn);
172} 173}
173 174
174static void set_adapter_info(struct ibmvscsi_host_data *hostdata) 175static void set_adapter_info(struct ibmvscsi_host_data *hostdata)
diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c
index 752ef07516b9..be8d75721a85 100644
--- a/drivers/serial/pmac_zilog.c
+++ b/drivers/serial/pmac_zilog.c
@@ -1467,7 +1467,8 @@ no_dma:
1467 if (ZS_IS_IRDA(uap)) 1467 if (ZS_IS_IRDA(uap))
1468 uap->port_type = PMAC_SCC_IRDA; 1468 uap->port_type = PMAC_SCC_IRDA;
1469 if (ZS_IS_INTMODEM(uap)) { 1469 if (ZS_IS_INTMODEM(uap)) {
1470 struct device_node* i2c_modem = find_devices("i2c-modem"); 1470 struct device_node* i2c_modem =
1471 of_find_node_by_name(NULL, "i2c-modem");
1471 if (i2c_modem) { 1472 if (i2c_modem) {
1472 const char* mid = 1473 const char* mid =
1473 get_property(i2c_modem, "modem-id", NULL); 1474 get_property(i2c_modem, "modem-id", NULL);
@@ -1482,6 +1483,7 @@ no_dma:
1482 } 1483 }
1483 printk(KERN_INFO "pmac_zilog: i2c-modem detected, id: %d\n", 1484 printk(KERN_INFO "pmac_zilog: i2c-modem detected, id: %d\n",
1484 mid ? (*mid) : 0); 1485 mid ? (*mid) : 0);
1486 of_node_put(i2c_modem);
1485 } else { 1487 } else {
1486 printk(KERN_INFO "pmac_zilog: serial modem detected\n"); 1488 printk(KERN_INFO "pmac_zilog: serial modem detected\n");
1487 } 1489 }
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 8372ace4a0d9..b1cb72c3780f 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -396,7 +396,7 @@ config FB_ATARI
396 396
397config FB_OF 397config FB_OF
398 bool "Open Firmware frame buffer device support" 398 bool "Open Firmware frame buffer device support"
399 depends on (FB = y) && (PPC64 || PPC_OF) 399 depends on (FB = y) && (PPC64 || PPC_OF) && (!PPC_PSERIES || PCI)
400 select FB_CFB_FILLRECT 400 select FB_CFB_FILLRECT
401 select FB_CFB_COPYAREA 401 select FB_CFB_COPYAREA
402 select FB_CFB_IMAGEBLIT 402 select FB_CFB_IMAGEBLIT
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index 9a2b0d69b0ae..c411293cefc8 100644
--- a/drivers/video/aty/radeon_pm.c
+++ b/drivers/video/aty/radeon_pm.c
@@ -1262,7 +1262,7 @@ static void radeon_pm_full_reset_sdram(struct radeonfb_info *rinfo)
1262 /* This is the code for the Aluminium PowerBooks M10 / iBooks M11 */ 1262 /* This is the code for the Aluminium PowerBooks M10 / iBooks M11 */
1263 if (rinfo->family == CHIP_FAMILY_RV350) { 1263 if (rinfo->family == CHIP_FAMILY_RV350) {
1264 u32 sdram_mode_reg = rinfo->save_regs[35]; 1264 u32 sdram_mode_reg = rinfo->save_regs[35];
1265 static u32 default_mrtable[] = 1265 static const u32 default_mrtable[] =
1266 { 0x21320032, 1266 { 0x21320032,
1267 0x21321000, 0xa1321000, 0x21321000, 0xffffffff, 1267 0x21321000, 0xa1321000, 0x21321000, 0xffffffff,
1268 0x21320032, 0xa1320032, 0x21320032, 0xffffffff, 1268 0x21320032, 0xa1320032, 0x21320032, 0xffffffff,
diff --git a/drivers/video/controlfb.c b/drivers/video/controlfb.c
index fd60dba294da..8b762739b1e0 100644
--- a/drivers/video/controlfb.c
+++ b/drivers/video/controlfb.c
@@ -179,12 +179,14 @@ MODULE_LICENSE("GPL");
179int init_module(void) 179int init_module(void)
180{ 180{
181 struct device_node *dp; 181 struct device_node *dp;
182 int ret = -ENXIO;
182 183
183 dp = find_devices("control"); 184 dp = of_find_node_by_name(NULL, "control");
184 if (dp != 0 && !control_of_init(dp)) 185 if (dp != 0 && !control_of_init(dp))
185 return 0; 186 ret = 0;
187 of_node_put(dp);
186 188
187 return -ENXIO; 189 return ret;
188} 190}
189 191
190void cleanup_module(void) 192void cleanup_module(void)
@@ -589,16 +591,18 @@ static int __init control_init(void)
589{ 591{
590 struct device_node *dp; 592 struct device_node *dp;
591 char *option = NULL; 593 char *option = NULL;
594 int ret = -ENXIO;
592 595
593 if (fb_get_options("controlfb", &option)) 596 if (fb_get_options("controlfb", &option))
594 return -ENODEV; 597 return -ENODEV;
595 control_setup(option); 598 control_setup(option);
596 599
597 dp = find_devices("control"); 600 dp = of_find_node_by_name(NULL, "control");
598 if (dp != 0 && !control_of_init(dp)) 601 if (dp != 0 && !control_of_init(dp))
599 return 0; 602 ret = 0;
603 of_node_put(dp);
600 604
601 return -ENXIO; 605 return ret;
602} 606}
603 607
604module_init(control_init); 608module_init(control_init);
diff --git a/fs/proc/proc_devtree.c b/fs/proc/proc_devtree.c
index abdf068bc27f..eca471bc8512 100644
--- a/fs/proc/proc_devtree.c
+++ b/fs/proc/proc_devtree.c
@@ -38,7 +38,7 @@ static int property_read_proc(char *page, char **start, off_t off,
38 n = count; 38 n = count;
39 else 39 else
40 *eof = 1; 40 *eof = 1;
41 memcpy(page, pp->value + off, n); 41 memcpy(page, (char *)pp->value + off, n);
42 *start = page; 42 *start = page;
43 return n; 43 return n;
44} 44}
diff --git a/include/asm-powerpc/asm-compat.h b/include/asm-powerpc/asm-compat.h
index c89bd58ee283..c19e7367fce6 100644
--- a/include/asm-powerpc/asm-compat.h
+++ b/include/asm-powerpc/asm-compat.h
@@ -78,6 +78,15 @@
78#define PPC_STLCX stringify_in_c(stdcx.) 78#define PPC_STLCX stringify_in_c(stdcx.)
79#define PPC_CNTLZL stringify_in_c(cntlzd) 79#define PPC_CNTLZL stringify_in_c(cntlzd)
80 80
81/* Move to CR, single-entry optimized version. Only available
82 * on POWER4 and later.
83 */
84#ifdef CONFIG_POWER4_ONLY
85#define PPC_MTOCRF stringify_in_c(mtocrf)
86#else
87#define PPC_MTOCRF stringify_in_c(mtcrf)
88#endif
89
81#else /* 32-bit */ 90#else /* 32-bit */
82 91
83/* operations for longs and pointers */ 92/* operations for longs and pointers */
@@ -89,6 +98,7 @@
89#define PPC_LLARX stringify_in_c(lwarx) 98#define PPC_LLARX stringify_in_c(lwarx)
90#define PPC_STLCX stringify_in_c(stwcx.) 99#define PPC_STLCX stringify_in_c(stwcx.)
91#define PPC_CNTLZL stringify_in_c(cntlzw) 100#define PPC_CNTLZL stringify_in_c(cntlzw)
101#define PPC_MTOCRF stringify_in_c(mtcrf)
92 102
93#endif 103#endif
94 104
diff --git a/include/asm-powerpc/cacheflush.h b/include/asm-powerpc/cacheflush.h
index 08e93e789219..ba667a383b8c 100644
--- a/include/asm-powerpc/cacheflush.h
+++ b/include/asm-powerpc/cacheflush.h
@@ -64,6 +64,12 @@ extern void flush_dcache_phys_range(unsigned long start, unsigned long stop);
64 memcpy(dst, src, len) 64 memcpy(dst, src, len)
65 65
66 66
67
68#ifdef CONFIG_DEBUG_PAGEALLOC
69/* internal debugging function */
70void kernel_map_pages(struct page *page, int numpages, int enable);
71#endif
72
67#endif /* __KERNEL__ */ 73#endif /* __KERNEL__ */
68 74
69#endif /* _ASM_POWERPC_CACHEFLUSH_H */ 75#endif /* _ASM_POWERPC_CACHEFLUSH_H */
diff --git a/include/asm-powerpc/cell-pmu.h b/include/asm-powerpc/cell-pmu.h
index 35b95773746c..8066eede3a0c 100644
--- a/include/asm-powerpc/cell-pmu.h
+++ b/include/asm-powerpc/cell-pmu.h
@@ -97,11 +97,6 @@ extern void cbe_disable_pm_interrupts(u32 cpu);
97extern u32 cbe_get_and_clear_pm_interrupts(u32 cpu); 97extern u32 cbe_get_and_clear_pm_interrupts(u32 cpu);
98extern void cbe_sync_irq(int node); 98extern void cbe_sync_irq(int node);
99 99
100/* Utility functions, macros */
101extern u32 cbe_get_hw_thread_id(int cpu);
102
103#define cbe_cpu_to_node(cpu) ((cpu) >> 1)
104
105#define CBE_COUNT_SUPERVISOR_MODE 0 100#define CBE_COUNT_SUPERVISOR_MODE 0
106#define CBE_COUNT_HYPERVISOR_MODE 1 101#define CBE_COUNT_HYPERVISOR_MODE 1
107#define CBE_COUNT_PROBLEM_MODE 2 102#define CBE_COUNT_PROBLEM_MODE 2
diff --git a/include/asm-powerpc/cputable.h b/include/asm-powerpc/cputable.h
index e870b5393175..434524931ef3 100644
--- a/include/asm-powerpc/cputable.h
+++ b/include/asm-powerpc/cputable.h
@@ -48,6 +48,7 @@ enum powerpc_oprofile_type {
48 PPC_OPROFILE_G4 = 3, 48 PPC_OPROFILE_G4 = 3,
49 PPC_OPROFILE_BOOKE = 4, 49 PPC_OPROFILE_BOOKE = 4,
50 PPC_OPROFILE_CELL = 5, 50 PPC_OPROFILE_CELL = 5,
51 PPC_OPROFILE_PA6T = 6,
51}; 52};
52 53
53enum powerpc_pmc_type { 54enum powerpc_pmc_type {
@@ -223,6 +224,10 @@ extern void do_feature_fixups(unsigned long value, void *fixup_start,
223 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | \ 224 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | \
224 CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP | \ 225 CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP | \
225 CPU_FTR_PPC_LE) 226 CPU_FTR_PPC_LE)
227#define CPU_FTRS_750CL (CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | \
228 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | \
229 CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP | \
230 CPU_FTR_HAS_HIGH_BATS | CPU_FTR_PPC_LE)
226#define CPU_FTRS_750FX1 (CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | \ 231#define CPU_FTRS_750FX1 (CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | \
227 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | \ 232 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | \
228 CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP | \ 233 CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP | \
@@ -235,9 +240,9 @@ extern void do_feature_fixups(unsigned long value, void *fixup_start,
235 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | \ 240 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | \
236 CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP | \ 241 CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP | \
237 CPU_FTR_DUAL_PLL_750FX | CPU_FTR_HAS_HIGH_BATS | CPU_FTR_PPC_LE) 242 CPU_FTR_DUAL_PLL_750FX | CPU_FTR_HAS_HIGH_BATS | CPU_FTR_PPC_LE)
238#define CPU_FTRS_750GX (CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE | \ 243#define CPU_FTRS_750GX (CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | \
239 CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU | \ 244 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | \
240 CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP | \ 245 CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP | \
241 CPU_FTR_DUAL_PLL_750FX | CPU_FTR_HAS_HIGH_BATS | CPU_FTR_PPC_LE) 246 CPU_FTR_DUAL_PLL_750FX | CPU_FTR_HAS_HIGH_BATS | CPU_FTR_PPC_LE)
242#define CPU_FTRS_7400_NOTAU (CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | \ 247#define CPU_FTRS_7400_NOTAU (CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE | \
243 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | \ 248 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR | \
diff --git a/include/asm-powerpc/current.h b/include/asm-powerpc/current.h
index b8708aedf925..e2c7f06931e7 100644
--- a/include/asm-powerpc/current.h
+++ b/include/asm-powerpc/current.h
@@ -12,6 +12,7 @@
12struct task_struct; 12struct task_struct;
13 13
14#ifdef __powerpc64__ 14#ifdef __powerpc64__
15#include <linux/stddef.h>
15#include <asm/paca.h> 16#include <asm/paca.h>
16 17
17static inline struct task_struct *get_current(void) 18static inline struct task_struct *get_current(void)
diff --git a/include/asm-powerpc/edac.h b/include/asm-powerpc/edac.h
new file mode 100644
index 000000000000..6ead88bbfbb8
--- /dev/null
+++ b/include/asm-powerpc/edac.h
@@ -0,0 +1,40 @@
1/*
2 * PPC EDAC common defs
3 *
4 * Author: Dave Jiang <djiang@mvista.com>
5 *
6 * 2007 (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 ASM_EDAC_H
12#define ASM_EDAC_H
13/*
14 * ECC atomic, DMA, SMP and interrupt safe scrub function.
15 * Implements the per arch atomic_scrub() that EDAC use for software
16 * ECC scrubbing. It reads memory and then writes back the original
17 * value, allowing the hardware to detect and correct memory errors.
18 */
19static __inline__ void atomic_scrub(void *va, u32 size)
20{
21 unsigned int *virt_addr = va;
22 unsigned int temp;
23 unsigned int i;
24
25 for (i = 0; i < size / sizeof(*virt_addr); i++, virt_addr++) {
26 /* Very carefully read and write to memory atomically
27 * so we are interrupt, DMA and SMP safe.
28 */
29 __asm__ __volatile__ ("\n\
30 1: lwarx %0,0,%1\n\
31 stwcx. %0,0,%1\n\
32 bne- 1b\n\
33 isync"
34 : "=&r"(temp)
35 : "r"(virt_addr)
36 : "cr0", "memory");
37 }
38}
39
40#endif
diff --git a/include/asm-powerpc/eeh_event.h b/include/asm-powerpc/eeh_event.h
index dc6bf0ffb796..cc3cb04539ac 100644
--- a/include/asm-powerpc/eeh_event.h
+++ b/include/asm-powerpc/eeh_event.h
@@ -30,8 +30,6 @@ struct eeh_event {
30 struct list_head list; 30 struct list_head list;
31 struct device_node *dn; /* struct device node */ 31 struct device_node *dn; /* struct device node */
32 struct pci_dev *dev; /* affected device */ 32 struct pci_dev *dev; /* affected device */
33 enum pci_channel_state state; /* PCI bus state for the affected device */
34 int time_unavail; /* milliseconds until device might be available */
35}; 33};
36 34
37/** 35/**
@@ -46,9 +44,7 @@ struct eeh_event {
46 * (from a workqueue). 44 * (from a workqueue).
47 */ 45 */
48int eeh_send_failure_event (struct device_node *dn, 46int eeh_send_failure_event (struct device_node *dn,
49 struct pci_dev *dev, 47 struct pci_dev *dev);
50 enum pci_channel_state state,
51 int time_unavail);
52 48
53/* Main recovery function */ 49/* Main recovery function */
54struct pci_dn * handle_eeh_events (struct eeh_event *); 50struct pci_dn * handle_eeh_events (struct eeh_event *);
diff --git a/include/asm-powerpc/ibmebus.h b/include/asm-powerpc/ibmebus.h
index 66112114b8c5..87d396e28db2 100644
--- a/include/asm-powerpc/ibmebus.h
+++ b/include/asm-powerpc/ibmebus.h
@@ -2,36 +2,37 @@
2 * IBM PowerPC eBus Infrastructure Support. 2 * IBM PowerPC eBus Infrastructure Support.
3 * 3 *
4 * Copyright (c) 2005 IBM Corporation 4 * Copyright (c) 2005 IBM Corporation
5 * Joachim Fenkes <fenkes@de.ibm.com>
5 * Heiko J Schick <schickhj@de.ibm.com> 6 * Heiko J Schick <schickhj@de.ibm.com>
6 * 7 *
7 * All rights reserved. 8 * All rights reserved.
8 * 9 *
9 * This source code is distributed under a dual license of GPL v2.0 and OpenIB 10 * This source code is distributed under a dual license of GPL v2.0 and OpenIB
10 * BSD. 11 * BSD.
11 * 12 *
12 * OpenIB BSD License 13 * OpenIB BSD License
13 * 14 *
14 * Redistribution and use in source and binary forms, with or without 15 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are met: 16 * modification, are permitted provided that the following conditions are met:
16 * 17 *
17 * Redistributions of source code must retain the above copyright notice, this 18 * Redistributions of source code must retain the above copyright notice, this
18 * list of conditions and the following disclaimer. 19 * list of conditions and the following disclaimer.
19 * 20 *
20 * Redistributions in binary form must reproduce the above copyright notice, 21 * Redistributions in binary form must reproduce the above copyright notice,
21 * this list of conditions and the following disclaimer in the documentation 22 * this list of conditions and the following disclaimer in the documentation
22 * and/or other materials 23 * and/or other materials
23 * provided with the distribution. 24 * provided with the distribution.
24 * 25 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
32 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 33 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
33 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE. 36 * POSSIBILITY OF SUCH DAMAGE.
36 */ 37 */
37 38
@@ -46,12 +47,11 @@
46 47
47extern struct bus_type ibmebus_bus_type; 48extern struct bus_type ibmebus_bus_type;
48 49
49struct ibmebus_dev { 50struct ibmebus_dev {
50 const char *name;
51 struct of_device ofdev; 51 struct of_device ofdev;
52}; 52};
53 53
54struct ibmebus_driver { 54struct ibmebus_driver {
55 char *name; 55 char *name;
56 struct of_device_id *id_table; 56 struct of_device_id *id_table;
57 int (*probe) (struct ibmebus_dev *dev, const struct of_device_id *id); 57 int (*probe) (struct ibmebus_dev *dev, const struct of_device_id *id);
@@ -63,7 +63,7 @@ int ibmebus_register_driver(struct ibmebus_driver *drv);
63void ibmebus_unregister_driver(struct ibmebus_driver *drv); 63void ibmebus_unregister_driver(struct ibmebus_driver *drv);
64 64
65int ibmebus_request_irq(struct ibmebus_dev *dev, 65int ibmebus_request_irq(struct ibmebus_dev *dev,
66 u32 ist, 66 u32 ist,
67 irq_handler_t handler, 67 irq_handler_t handler,
68 unsigned long irq_flags, const char * devname, 68 unsigned long irq_flags, const char * devname,
69 void *dev_id); 69 void *dev_id);
diff --git a/include/asm-powerpc/immap_86xx.h b/include/asm-powerpc/immap_86xx.h
index d905b6622268..59b9e07b8e99 100644
--- a/include/asm-powerpc/immap_86xx.h
+++ b/include/asm-powerpc/immap_86xx.h
@@ -85,81 +85,6 @@ typedef struct ccsr_pci {
85 char res19[472]; 85 char res19[472];
86} ccsr_pci_t; 86} ccsr_pci_t;
87 87
88/* PCI Express Registers */
89typedef struct ccsr_pex {
90 uint pex_config_addr; /* 0x.000 - PCI Express Configuration Address Register */
91 uint pex_config_data; /* 0x.004 - PCI Express Configuration Data Register */
92 char res1[4];
93 uint pex_otb_cpl_tor; /* 0x.00c - PCI Express Outbound completion timeout register */
94 uint pex_conf_tor; /* 0x.010 - PCI Express configuration timeout register */
95 char res2[12];
96 uint pex_pme_mes_dr; /* 0x.020 - PCI Express PME and message detect register */
97 uint pex_pme_mes_disr; /* 0x.024 - PCI Express PME and message disable register */
98 uint pex_pme_mes_ier; /* 0x.028 - PCI Express PME and message interrupt enable register */
99 uint pex_pmcr; /* 0x.02c - PCI Express power management command register */
100 char res3[3024];
101 uint pexotar0; /* 0x.c00 - PCI Express outbound translation address register 0 */
102 uint pexotear0; /* 0x.c04 - PCI Express outbound translation extended address register 0*/
103 char res4[8];
104 uint pexowar0; /* 0x.c10 - PCI Express outbound window attributes register 0*/
105 char res5[12];
106 uint pexotar1; /* 0x.c20 - PCI Express outbound translation address register 1 */
107 uint pexotear1; /* 0x.c24 - PCI Express outbound translation extended address register 1*/
108 uint pexowbar1; /* 0x.c28 - PCI Express outbound window base address register 1*/
109 char res6[4];
110 uint pexowar1; /* 0x.c30 - PCI Express outbound window attributes register 1*/
111 char res7[12];
112 uint pexotar2; /* 0x.c40 - PCI Express outbound translation address register 2 */
113 uint pexotear2; /* 0x.c44 - PCI Express outbound translation extended address register 2*/
114 uint pexowbar2; /* 0x.c48 - PCI Express outbound window base address register 2*/
115 char res8[4];
116 uint pexowar2; /* 0x.c50 - PCI Express outbound window attributes register 2*/
117 char res9[12];
118 uint pexotar3; /* 0x.c60 - PCI Express outbound translation address register 3 */
119 uint pexotear3; /* 0x.c64 - PCI Express outbound translation extended address register 3*/
120 uint pexowbar3; /* 0x.c68 - PCI Express outbound window base address register 3*/
121 char res10[4];
122 uint pexowar3; /* 0x.c70 - PCI Express outbound window attributes register 3*/
123 char res11[12];
124 uint pexotar4; /* 0x.c80 - PCI Express outbound translation address register 4 */
125 uint pexotear4; /* 0x.c84 - PCI Express outbound translation extended address register 4*/
126 uint pexowbar4; /* 0x.c88 - PCI Express outbound window base address register 4*/
127 char res12[4];
128 uint pexowar4; /* 0x.c90 - PCI Express outbound window attributes register 4*/
129 char res13[12];
130 char res14[256];
131 uint pexitar3; /* 0x.da0 - PCI Express inbound translation address register 3 */
132 char res15[4];
133 uint pexiwbar3; /* 0x.da8 - PCI Express inbound window base address register 3 */
134 uint pexiwbear3; /* 0x.dac - PCI Express inbound window base extended address register 3 */
135 uint pexiwar3; /* 0x.db0 - PCI Express inbound window attributes register 3 */
136 char res16[12];
137 uint pexitar2; /* 0x.dc0 - PCI Express inbound translation address register 2 */
138 char res17[4];
139 uint pexiwbar2; /* 0x.dc8 - PCI Express inbound window base address register 2 */
140 uint pexiwbear2; /* 0x.dcc - PCI Express inbound window base extended address register 2 */
141 uint pexiwar2; /* 0x.dd0 - PCI Express inbound window attributes register 2 */
142 char res18[12];
143 uint pexitar1; /* 0x.de0 - PCI Express inbound translation address register 2 */
144 char res19[4];
145 uint pexiwbar1; /* 0x.de8 - PCI Express inbound window base address register 2 */
146 uint pexiwbear1; /* 0x.dec - PCI Express inbound window base extended address register 2 */
147 uint pexiwar1; /* 0x.df0 - PCI Express inbound window attributes register 2 */
148 char res20[12];
149 uint pex_err_dr; /* 0x.e00 - PCI Express error detect register */
150 char res21[4];
151 uint pex_err_en; /* 0x.e08 - PCI Express error interrupt enable register */
152 char res22[4];
153 uint pex_err_disr; /* 0x.e10 - PCI Express error disable register */
154 char res23[12];
155 uint pex_err_cap_stat; /* 0x.e20 - PCI Express error capture status register */
156 char res24[4];
157 uint pex_err_cap_r0; /* 0x.e28 - PCI Express error capture register 0 */
158 uint pex_err_cap_r1; /* 0x.e2c - PCI Express error capture register 0 */
159 uint pex_err_cap_r2; /* 0x.e30 - PCI Express error capture register 0 */
160 uint pex_err_cap_r3; /* 0x.e34 - PCI Express error capture register 0 */
161} ccsr_pex_t;
162
163/* Global Utility Registers */ 88/* Global Utility Registers */
164typedef struct ccsr_guts { 89typedef struct ccsr_guts {
165 uint porpllsr; /* 0x.0000 - POR PLL Ratio Status Register */ 90 uint porpllsr; /* 0x.0000 - POR PLL Ratio Status Register */
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h
index 301c9bb308b1..350c9bdb31dc 100644
--- a/include/asm-powerpc/io.h
+++ b/include/asm-powerpc/io.h
@@ -11,7 +11,12 @@
11 11
12/* Check of existence of legacy devices */ 12/* Check of existence of legacy devices */
13extern int check_legacy_ioport(unsigned long base_port); 13extern int check_legacy_ioport(unsigned long base_port);
14#define PNPBIOS_BASE 0xf000 /* only relevant for PReP */ 14#define I8042_DATA_REG 0x60
15#define FDC_BASE 0x3f0
16/* only relevant for PReP */
17#define _PIDXR 0x279
18#define _PNPWRP 0xa79
19#define PNPBIOS_BASE 0xf000
15 20
16#include <linux/compiler.h> 21#include <linux/compiler.h>
17#include <asm/page.h> 22#include <asm/page.h>
diff --git a/include/asm-powerpc/kprobes.h b/include/asm-powerpc/kprobes.h
index 3a5dd492588f..f850ca7020ed 100644
--- a/include/asm-powerpc/kprobes.h
+++ b/include/asm-powerpc/kprobes.h
@@ -87,6 +87,11 @@ extern void arch_remove_kprobe(struct kprobe *p);
87struct arch_specific_insn { 87struct arch_specific_insn {
88 /* copy of original instruction */ 88 /* copy of original instruction */
89 kprobe_opcode_t *insn; 89 kprobe_opcode_t *insn;
90 /*
91 * Set in kprobes code, initially to 0. If the instruction can be
92 * eumulated, this is set to 1, if not, to -1.
93 */
94 int boostable;
90}; 95};
91 96
92struct prev_kprobe { 97struct prev_kprobe {
diff --git a/include/asm-powerpc/machdep.h b/include/asm-powerpc/machdep.h
index 1b04e5723548..b204926ce913 100644
--- a/include/asm-powerpc/machdep.h
+++ b/include/asm-powerpc/machdep.h
@@ -153,9 +153,6 @@ struct machdep_calls {
153 */ 153 */
154 long (*feature_call)(unsigned int feature, ...); 154 long (*feature_call)(unsigned int feature, ...);
155 155
156 /* Check availability of legacy devices like i8042 */
157 int (*check_legacy_ioport)(unsigned int baseport);
158
159 /* Get legacy PCI/IDE interrupt mapping */ 156 /* Get legacy PCI/IDE interrupt mapping */
160 int (*pci_get_legacy_ide_irq)(struct pci_dev *dev, int channel); 157 int (*pci_get_legacy_ide_irq)(struct pci_dev *dev, int channel);
161 158
diff --git a/include/asm-powerpc/mmu-hash64.h b/include/asm-powerpc/mmu-hash64.h
new file mode 100644
index 000000000000..6739457d8bc0
--- /dev/null
+++ b/include/asm-powerpc/mmu-hash64.h
@@ -0,0 +1,400 @@
1#ifndef _ASM_POWERPC_MMU_HASH64_H_
2#define _ASM_POWERPC_MMU_HASH64_H_
3/*
4 * PowerPC64 memory management structures
5 *
6 * Dave Engebretsen & Mike Corrigan <{engebret|mikejc}@us.ibm.com>
7 * PPC64 rework.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15#include <asm/asm-compat.h>
16#include <asm/page.h>
17
18/*
19 * Segment table
20 */
21
22#define STE_ESID_V 0x80
23#define STE_ESID_KS 0x20
24#define STE_ESID_KP 0x10
25#define STE_ESID_N 0x08
26
27#define STE_VSID_SHIFT 12
28
29/* Location of cpu0's segment table */
30#define STAB0_PAGE 0x6
31#define STAB0_OFFSET (STAB0_PAGE << 12)
32#define STAB0_PHYS_ADDR (STAB0_OFFSET + PHYSICAL_START)
33
34#ifndef __ASSEMBLY__
35extern char initial_stab[];
36#endif /* ! __ASSEMBLY */
37
38/*
39 * SLB
40 */
41
42#define SLB_NUM_BOLTED 3
43#define SLB_CACHE_ENTRIES 8
44
45/* Bits in the SLB ESID word */
46#define SLB_ESID_V ASM_CONST(0x0000000008000000) /* valid */
47
48/* Bits in the SLB VSID word */
49#define SLB_VSID_SHIFT 12
50#define SLB_VSID_B ASM_CONST(0xc000000000000000)
51#define SLB_VSID_B_256M ASM_CONST(0x0000000000000000)
52#define SLB_VSID_B_1T ASM_CONST(0x4000000000000000)
53#define SLB_VSID_KS ASM_CONST(0x0000000000000800)
54#define SLB_VSID_KP ASM_CONST(0x0000000000000400)
55#define SLB_VSID_N ASM_CONST(0x0000000000000200) /* no-execute */
56#define SLB_VSID_L ASM_CONST(0x0000000000000100)
57#define SLB_VSID_C ASM_CONST(0x0000000000000080) /* class */
58#define SLB_VSID_LP ASM_CONST(0x0000000000000030)
59#define SLB_VSID_LP_00 ASM_CONST(0x0000000000000000)
60#define SLB_VSID_LP_01 ASM_CONST(0x0000000000000010)
61#define SLB_VSID_LP_10 ASM_CONST(0x0000000000000020)
62#define SLB_VSID_LP_11 ASM_CONST(0x0000000000000030)
63#define SLB_VSID_LLP (SLB_VSID_L|SLB_VSID_LP)
64
65#define SLB_VSID_KERNEL (SLB_VSID_KP)
66#define SLB_VSID_USER (SLB_VSID_KP|SLB_VSID_KS|SLB_VSID_C)
67
68#define SLBIE_C (0x08000000)
69
70/*
71 * Hash table
72 */
73
74#define HPTES_PER_GROUP 8
75
76#define HPTE_V_AVPN_SHIFT 7
77#define HPTE_V_AVPN ASM_CONST(0xffffffffffffff80)
78#define HPTE_V_AVPN_VAL(x) (((x) & HPTE_V_AVPN) >> HPTE_V_AVPN_SHIFT)
79#define HPTE_V_COMPARE(x,y) (!(((x) ^ (y)) & HPTE_V_AVPN))
80#define HPTE_V_BOLTED ASM_CONST(0x0000000000000010)
81#define HPTE_V_LOCK ASM_CONST(0x0000000000000008)
82#define HPTE_V_LARGE ASM_CONST(0x0000000000000004)
83#define HPTE_V_SECONDARY ASM_CONST(0x0000000000000002)
84#define HPTE_V_VALID ASM_CONST(0x0000000000000001)
85
86#define HPTE_R_PP0 ASM_CONST(0x8000000000000000)
87#define HPTE_R_TS ASM_CONST(0x4000000000000000)
88#define HPTE_R_RPN_SHIFT 12
89#define HPTE_R_RPN ASM_CONST(0x3ffffffffffff000)
90#define HPTE_R_FLAGS ASM_CONST(0x00000000000003ff)
91#define HPTE_R_PP ASM_CONST(0x0000000000000003)
92#define HPTE_R_N ASM_CONST(0x0000000000000004)
93#define HPTE_R_C ASM_CONST(0x0000000000000080)
94#define HPTE_R_R ASM_CONST(0x0000000000000100)
95
96/* Values for PP (assumes Ks=0, Kp=1) */
97/* pp0 will always be 0 for linux */
98#define PP_RWXX 0 /* Supervisor read/write, User none */
99#define PP_RWRX 1 /* Supervisor read/write, User read */
100#define PP_RWRW 2 /* Supervisor read/write, User read/write */
101#define PP_RXRX 3 /* Supervisor read, User read */
102
103#ifndef __ASSEMBLY__
104
105typedef struct {
106 unsigned long v;
107 unsigned long r;
108} hpte_t;
109
110extern hpte_t *htab_address;
111extern unsigned long htab_size_bytes;
112extern unsigned long htab_hash_mask;
113
114/*
115 * Page size definition
116 *
117 * shift : is the "PAGE_SHIFT" value for that page size
118 * sllp : is a bit mask with the value of SLB L || LP to be or'ed
119 * directly to a slbmte "vsid" value
120 * penc : is the HPTE encoding mask for the "LP" field:
121 *
122 */
123struct mmu_psize_def
124{
125 unsigned int shift; /* number of bits */
126 unsigned int penc; /* HPTE encoding */
127 unsigned int tlbiel; /* tlbiel supported for that page size */
128 unsigned long avpnm; /* bits to mask out in AVPN in the HPTE */
129 unsigned long sllp; /* SLB L||LP (exact mask to use in slbmte) */
130};
131
132#endif /* __ASSEMBLY__ */
133
134/*
135 * The kernel use the constants below to index in the page sizes array.
136 * The use of fixed constants for this purpose is better for performances
137 * of the low level hash refill handlers.
138 *
139 * A non supported page size has a "shift" field set to 0
140 *
141 * Any new page size being implemented can get a new entry in here. Whether
142 * the kernel will use it or not is a different matter though. The actual page
143 * size used by hugetlbfs is not defined here and may be made variable
144 */
145
146#define MMU_PAGE_4K 0 /* 4K */
147#define MMU_PAGE_64K 1 /* 64K */
148#define MMU_PAGE_64K_AP 2 /* 64K Admixed (in a 4K segment) */
149#define MMU_PAGE_1M 3 /* 1M */
150#define MMU_PAGE_16M 4 /* 16M */
151#define MMU_PAGE_16G 5 /* 16G */
152#define MMU_PAGE_COUNT 6
153
154#ifndef __ASSEMBLY__
155
156/*
157 * The current system page sizes
158 */
159extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT];
160extern int mmu_linear_psize;
161extern int mmu_virtual_psize;
162extern int mmu_vmalloc_psize;
163extern int mmu_io_psize;
164
165/*
166 * If the processor supports 64k normal pages but not 64k cache
167 * inhibited pages, we have to be prepared to switch processes
168 * to use 4k pages when they create cache-inhibited mappings.
169 * If this is the case, mmu_ci_restrictions will be set to 1.
170 */
171extern int mmu_ci_restrictions;
172
173#ifdef CONFIG_HUGETLB_PAGE
174/*
175 * The page size index of the huge pages for use by hugetlbfs
176 */
177extern int mmu_huge_psize;
178
179#endif /* CONFIG_HUGETLB_PAGE */
180
181/*
182 * This function sets the AVPN and L fields of the HPTE appropriately
183 * for the page size
184 */
185static inline unsigned long hpte_encode_v(unsigned long va, int psize)
186{
187 unsigned long v =
188 v = (va >> 23) & ~(mmu_psize_defs[psize].avpnm);
189 v <<= HPTE_V_AVPN_SHIFT;
190 if (psize != MMU_PAGE_4K)
191 v |= HPTE_V_LARGE;
192 return v;
193}
194
195/*
196 * This function sets the ARPN, and LP fields of the HPTE appropriately
197 * for the page size. We assume the pa is already "clean" that is properly
198 * aligned for the requested page size
199 */
200static inline unsigned long hpte_encode_r(unsigned long pa, int psize)
201{
202 unsigned long r;
203
204 /* A 4K page needs no special encoding */
205 if (psize == MMU_PAGE_4K)
206 return pa & HPTE_R_RPN;
207 else {
208 unsigned int penc = mmu_psize_defs[psize].penc;
209 unsigned int shift = mmu_psize_defs[psize].shift;
210 return (pa & ~((1ul << shift) - 1)) | (penc << 12);
211 }
212 return r;
213}
214
215/*
216 * This hashes a virtual address for a 256Mb segment only for now
217 */
218
219static inline unsigned long hpt_hash(unsigned long va, unsigned int shift)
220{
221 return ((va >> 28) & 0x7fffffffffUL) ^ ((va & 0x0fffffffUL) >> shift);
222}
223
224extern int __hash_page_4K(unsigned long ea, unsigned long access,
225 unsigned long vsid, pte_t *ptep, unsigned long trap,
226 unsigned int local);
227extern int __hash_page_64K(unsigned long ea, unsigned long access,
228 unsigned long vsid, pte_t *ptep, unsigned long trap,
229 unsigned int local);
230struct mm_struct;
231extern int hash_page(unsigned long ea, unsigned long access, unsigned long trap);
232extern int hash_huge_page(struct mm_struct *mm, unsigned long access,
233 unsigned long ea, unsigned long vsid, int local,
234 unsigned long trap);
235
236extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
237 unsigned long pstart, unsigned long mode,
238 int psize);
239
240extern void htab_initialize(void);
241extern void htab_initialize_secondary(void);
242extern void hpte_init_native(void);
243extern void hpte_init_lpar(void);
244extern void hpte_init_iSeries(void);
245extern void hpte_init_beat(void);
246
247extern void stabs_alloc(void);
248extern void slb_initialize(void);
249extern void slb_flush_and_rebolt(void);
250extern void stab_initialize(unsigned long stab);
251
252#endif /* __ASSEMBLY__ */
253
254/*
255 * VSID allocation
256 *
257 * We first generate a 36-bit "proto-VSID". For kernel addresses this
258 * is equal to the ESID, for user addresses it is:
259 * (context << 15) | (esid & 0x7fff)
260 *
261 * The two forms are distinguishable because the top bit is 0 for user
262 * addresses, whereas the top two bits are 1 for kernel addresses.
263 * Proto-VSIDs with the top two bits equal to 0b10 are reserved for
264 * now.
265 *
266 * The proto-VSIDs are then scrambled into real VSIDs with the
267 * multiplicative hash:
268 *
269 * VSID = (proto-VSID * VSID_MULTIPLIER) % VSID_MODULUS
270 * where VSID_MULTIPLIER = 268435399 = 0xFFFFFC7
271 * VSID_MODULUS = 2^36-1 = 0xFFFFFFFFF
272 *
273 * This scramble is only well defined for proto-VSIDs below
274 * 0xFFFFFFFFF, so both proto-VSID and actual VSID 0xFFFFFFFFF are
275 * reserved. VSID_MULTIPLIER is prime, so in particular it is
276 * co-prime to VSID_MODULUS, making this a 1:1 scrambling function.
277 * Because the modulus is 2^n-1 we can compute it efficiently without
278 * a divide or extra multiply (see below).
279 *
280 * This scheme has several advantages over older methods:
281 *
282 * - We have VSIDs allocated for every kernel address
283 * (i.e. everything above 0xC000000000000000), except the very top
284 * segment, which simplifies several things.
285 *
286 * - We allow for 15 significant bits of ESID and 20 bits of
287 * context for user addresses. i.e. 8T (43 bits) of address space for
288 * up to 1M contexts (although the page table structure and context
289 * allocation will need changes to take advantage of this).
290 *
291 * - The scramble function gives robust scattering in the hash
292 * table (at least based on some initial results). The previous
293 * method was more susceptible to pathological cases giving excessive
294 * hash collisions.
295 */
296/*
297 * WARNING - If you change these you must make sure the asm
298 * implementations in slb_allocate (slb_low.S), do_stab_bolted
299 * (head.S) and ASM_VSID_SCRAMBLE (below) are changed accordingly.
300 *
301 * You'll also need to change the precomputed VSID values in head.S
302 * which are used by the iSeries firmware.
303 */
304
305#define VSID_MULTIPLIER ASM_CONST(200730139) /* 28-bit prime */
306#define VSID_BITS 36
307#define VSID_MODULUS ((1UL<<VSID_BITS)-1)
308
309#define CONTEXT_BITS 19
310#define USER_ESID_BITS 16
311
312#define USER_VSID_RANGE (1UL << (USER_ESID_BITS + SID_SHIFT))
313
314/*
315 * This macro generates asm code to compute the VSID scramble
316 * function. Used in slb_allocate() and do_stab_bolted. The function
317 * computed is: (protovsid*VSID_MULTIPLIER) % VSID_MODULUS
318 *
319 * rt = register continaing the proto-VSID and into which the
320 * VSID will be stored
321 * rx = scratch register (clobbered)
322 *
323 * - rt and rx must be different registers
324 * - The answer will end up in the low 36 bits of rt. The higher
325 * bits may contain other garbage, so you may need to mask the
326 * result.
327 */
328#define ASM_VSID_SCRAMBLE(rt, rx) \
329 lis rx,VSID_MULTIPLIER@h; \
330 ori rx,rx,VSID_MULTIPLIER@l; \
331 mulld rt,rt,rx; /* rt = rt * MULTIPLIER */ \
332 \
333 srdi rx,rt,VSID_BITS; \
334 clrldi rt,rt,(64-VSID_BITS); \
335 add rt,rt,rx; /* add high and low bits */ \
336 /* Now, r3 == VSID (mod 2^36-1), and lies between 0 and \
337 * 2^36-1+2^28-1. That in particular means that if r3 >= \
338 * 2^36-1, then r3+1 has the 2^36 bit set. So, if r3+1 has \
339 * the bit clear, r3 already has the answer we want, if it \
340 * doesn't, the answer is the low 36 bits of r3+1. So in all \
341 * cases the answer is the low 36 bits of (r3 + ((r3+1) >> 36))*/\
342 addi rx,rt,1; \
343 srdi rx,rx,VSID_BITS; /* extract 2^36 bit */ \
344 add rt,rt,rx
345
346
347#ifndef __ASSEMBLY__
348
349typedef unsigned long mm_context_id_t;
350
351typedef struct {
352 mm_context_id_t id;
353 u16 user_psize; /* page size index */
354 u16 sllp; /* SLB entry page size encoding */
355#ifdef CONFIG_HUGETLB_PAGE
356 u16 low_htlb_areas, high_htlb_areas;
357#endif
358 unsigned long vdso_base;
359} mm_context_t;
360
361
362static inline unsigned long vsid_scramble(unsigned long protovsid)
363{
364#if 0
365 /* The code below is equivalent to this function for arguments
366 * < 2^VSID_BITS, which is all this should ever be called
367 * with. However gcc is not clever enough to compute the
368 * modulus (2^n-1) without a second multiply. */
369 return ((protovsid * VSID_MULTIPLIER) % VSID_MODULUS);
370#else /* 1 */
371 unsigned long x;
372
373 x = protovsid * VSID_MULTIPLIER;
374 x = (x >> VSID_BITS) + (x & VSID_MODULUS);
375 return (x + ((x+1) >> VSID_BITS)) & VSID_MODULUS;
376#endif /* 1 */
377}
378
379/* This is only valid for addresses >= KERNELBASE */
380static inline unsigned long get_kernel_vsid(unsigned long ea)
381{
382 return vsid_scramble(ea >> SID_SHIFT);
383}
384
385/* This is only valid for user addresses (which are below 2^41) */
386static inline unsigned long get_vsid(unsigned long context, unsigned long ea)
387{
388 return vsid_scramble((context << USER_ESID_BITS)
389 | (ea >> SID_SHIFT));
390}
391
392#define VSID_SCRAMBLE(pvsid) (((pvsid) * VSID_MULTIPLIER) % VSID_MODULUS)
393#define KERNEL_VSID(ea) VSID_SCRAMBLE(GET_ESID(ea))
394
395/* Physical address used by some IO functions */
396typedef unsigned long phys_addr_t;
397
398#endif /* __ASSEMBLY__ */
399
400#endif /* _ASM_POWERPC_MMU_HASH64_H_ */
diff --git a/include/asm-powerpc/mmu.h b/include/asm-powerpc/mmu.h
index 200055a4b82b..06b3e6d336cb 100644
--- a/include/asm-powerpc/mmu.h
+++ b/include/asm-powerpc/mmu.h
@@ -2,407 +2,14 @@
2#define _ASM_POWERPC_MMU_H_ 2#define _ASM_POWERPC_MMU_H_
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5#ifndef CONFIG_PPC64 5#ifdef CONFIG_PPC64
6#include <asm-ppc/mmu.h> 6/* 64-bit classic hash table MMU */
7# include <asm/mmu-hash64.h>
7#else 8#else
8 9/* 32-bit. FIXME: split up the 32-bit MMU types, and revise for
9/* 10 * arch/powerpc */
10 * PowerPC memory management structures 11# include <asm-ppc/mmu.h>
11 *
12 * Dave Engebretsen & Mike Corrigan <{engebret|mikejc}@us.ibm.com>
13 * PPC64 rework.
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version
18 * 2 of the License, or (at your option) any later version.
19 */
20
21#include <asm/asm-compat.h>
22#include <asm/page.h>
23
24/*
25 * Segment table
26 */
27
28#define STE_ESID_V 0x80
29#define STE_ESID_KS 0x20
30#define STE_ESID_KP 0x10
31#define STE_ESID_N 0x08
32
33#define STE_VSID_SHIFT 12
34
35/* Location of cpu0's segment table */
36#define STAB0_PAGE 0x6
37#define STAB0_OFFSET (STAB0_PAGE << 12)
38#define STAB0_PHYS_ADDR (STAB0_OFFSET + PHYSICAL_START)
39
40#ifndef __ASSEMBLY__
41extern char initial_stab[];
42#endif /* ! __ASSEMBLY */
43
44/*
45 * SLB
46 */
47
48#define SLB_NUM_BOLTED 3
49#define SLB_CACHE_ENTRIES 8
50
51/* Bits in the SLB ESID word */
52#define SLB_ESID_V ASM_CONST(0x0000000008000000) /* valid */
53
54/* Bits in the SLB VSID word */
55#define SLB_VSID_SHIFT 12
56#define SLB_VSID_B ASM_CONST(0xc000000000000000)
57#define SLB_VSID_B_256M ASM_CONST(0x0000000000000000)
58#define SLB_VSID_B_1T ASM_CONST(0x4000000000000000)
59#define SLB_VSID_KS ASM_CONST(0x0000000000000800)
60#define SLB_VSID_KP ASM_CONST(0x0000000000000400)
61#define SLB_VSID_N ASM_CONST(0x0000000000000200) /* no-execute */
62#define SLB_VSID_L ASM_CONST(0x0000000000000100)
63#define SLB_VSID_C ASM_CONST(0x0000000000000080) /* class */
64#define SLB_VSID_LP ASM_CONST(0x0000000000000030)
65#define SLB_VSID_LP_00 ASM_CONST(0x0000000000000000)
66#define SLB_VSID_LP_01 ASM_CONST(0x0000000000000010)
67#define SLB_VSID_LP_10 ASM_CONST(0x0000000000000020)
68#define SLB_VSID_LP_11 ASM_CONST(0x0000000000000030)
69#define SLB_VSID_LLP (SLB_VSID_L|SLB_VSID_LP)
70
71#define SLB_VSID_KERNEL (SLB_VSID_KP)
72#define SLB_VSID_USER (SLB_VSID_KP|SLB_VSID_KS|SLB_VSID_C)
73
74#define SLBIE_C (0x08000000)
75
76/*
77 * Hash table
78 */
79
80#define HPTES_PER_GROUP 8
81
82#define HPTE_V_AVPN_SHIFT 7
83#define HPTE_V_AVPN ASM_CONST(0xffffffffffffff80)
84#define HPTE_V_AVPN_VAL(x) (((x) & HPTE_V_AVPN) >> HPTE_V_AVPN_SHIFT)
85#define HPTE_V_COMPARE(x,y) (!(((x) ^ (y)) & HPTE_V_AVPN))
86#define HPTE_V_BOLTED ASM_CONST(0x0000000000000010)
87#define HPTE_V_LOCK ASM_CONST(0x0000000000000008)
88#define HPTE_V_LARGE ASM_CONST(0x0000000000000004)
89#define HPTE_V_SECONDARY ASM_CONST(0x0000000000000002)
90#define HPTE_V_VALID ASM_CONST(0x0000000000000001)
91
92#define HPTE_R_PP0 ASM_CONST(0x8000000000000000)
93#define HPTE_R_TS ASM_CONST(0x4000000000000000)
94#define HPTE_R_RPN_SHIFT 12
95#define HPTE_R_RPN ASM_CONST(0x3ffffffffffff000)
96#define HPTE_R_FLAGS ASM_CONST(0x00000000000003ff)
97#define HPTE_R_PP ASM_CONST(0x0000000000000003)
98#define HPTE_R_N ASM_CONST(0x0000000000000004)
99#define HPTE_R_C ASM_CONST(0x0000000000000080)
100#define HPTE_R_R ASM_CONST(0x0000000000000100)
101
102/* Values for PP (assumes Ks=0, Kp=1) */
103/* pp0 will always be 0 for linux */
104#define PP_RWXX 0 /* Supervisor read/write, User none */
105#define PP_RWRX 1 /* Supervisor read/write, User read */
106#define PP_RWRW 2 /* Supervisor read/write, User read/write */
107#define PP_RXRX 3 /* Supervisor read, User read */
108
109#ifndef __ASSEMBLY__
110
111typedef struct {
112 unsigned long v;
113 unsigned long r;
114} hpte_t;
115
116extern hpte_t *htab_address;
117extern unsigned long htab_size_bytes;
118extern unsigned long htab_hash_mask;
119
120/*
121 * Page size definition
122 *
123 * shift : is the "PAGE_SHIFT" value for that page size
124 * sllp : is a bit mask with the value of SLB L || LP to be or'ed
125 * directly to a slbmte "vsid" value
126 * penc : is the HPTE encoding mask for the "LP" field:
127 *
128 */
129struct mmu_psize_def
130{
131 unsigned int shift; /* number of bits */
132 unsigned int penc; /* HPTE encoding */
133 unsigned int tlbiel; /* tlbiel supported for that page size */
134 unsigned long avpnm; /* bits to mask out in AVPN in the HPTE */
135 unsigned long sllp; /* SLB L||LP (exact mask to use in slbmte) */
136};
137
138#endif /* __ASSEMBLY__ */
139
140/*
141 * The kernel use the constants below to index in the page sizes array.
142 * The use of fixed constants for this purpose is better for performances
143 * of the low level hash refill handlers.
144 *
145 * A non supported page size has a "shift" field set to 0
146 *
147 * Any new page size being implemented can get a new entry in here. Whether
148 * the kernel will use it or not is a different matter though. The actual page
149 * size used by hugetlbfs is not defined here and may be made variable
150 */
151
152#define MMU_PAGE_4K 0 /* 4K */
153#define MMU_PAGE_64K 1 /* 64K */
154#define MMU_PAGE_64K_AP 2 /* 64K Admixed (in a 4K segment) */
155#define MMU_PAGE_1M 3 /* 1M */
156#define MMU_PAGE_16M 4 /* 16M */
157#define MMU_PAGE_16G 5 /* 16G */
158#define MMU_PAGE_COUNT 6
159
160#ifndef __ASSEMBLY__
161
162/*
163 * The current system page sizes
164 */
165extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT];
166extern int mmu_linear_psize;
167extern int mmu_virtual_psize;
168extern int mmu_vmalloc_psize;
169extern int mmu_io_psize;
170
171/*
172 * If the processor supports 64k normal pages but not 64k cache
173 * inhibited pages, we have to be prepared to switch processes
174 * to use 4k pages when they create cache-inhibited mappings.
175 * If this is the case, mmu_ci_restrictions will be set to 1.
176 */
177extern int mmu_ci_restrictions;
178
179#ifdef CONFIG_HUGETLB_PAGE
180/*
181 * The page size index of the huge pages for use by hugetlbfs
182 */
183extern int mmu_huge_psize;
184
185#endif /* CONFIG_HUGETLB_PAGE */
186
187/*
188 * This function sets the AVPN and L fields of the HPTE appropriately
189 * for the page size
190 */
191static inline unsigned long hpte_encode_v(unsigned long va, int psize)
192{
193 unsigned long v =
194 v = (va >> 23) & ~(mmu_psize_defs[psize].avpnm);
195 v <<= HPTE_V_AVPN_SHIFT;
196 if (psize != MMU_PAGE_4K)
197 v |= HPTE_V_LARGE;
198 return v;
199}
200
201/*
202 * This function sets the ARPN, and LP fields of the HPTE appropriately
203 * for the page size. We assume the pa is already "clean" that is properly
204 * aligned for the requested page size
205 */
206static inline unsigned long hpte_encode_r(unsigned long pa, int psize)
207{
208 unsigned long r;
209
210 /* A 4K page needs no special encoding */
211 if (psize == MMU_PAGE_4K)
212 return pa & HPTE_R_RPN;
213 else {
214 unsigned int penc = mmu_psize_defs[psize].penc;
215 unsigned int shift = mmu_psize_defs[psize].shift;
216 return (pa & ~((1ul << shift) - 1)) | (penc << 12);
217 }
218 return r;
219}
220
221/*
222 * This hashes a virtual address for a 256Mb segment only for now
223 */
224
225static inline unsigned long hpt_hash(unsigned long va, unsigned int shift)
226{
227 return ((va >> 28) & 0x7fffffffffUL) ^ ((va & 0x0fffffffUL) >> shift);
228}
229
230extern int __hash_page_4K(unsigned long ea, unsigned long access,
231 unsigned long vsid, pte_t *ptep, unsigned long trap,
232 unsigned int local);
233extern int __hash_page_64K(unsigned long ea, unsigned long access,
234 unsigned long vsid, pte_t *ptep, unsigned long trap,
235 unsigned int local);
236struct mm_struct;
237extern int hash_huge_page(struct mm_struct *mm, unsigned long access,
238 unsigned long ea, unsigned long vsid, int local,
239 unsigned long trap);
240
241extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
242 unsigned long pstart, unsigned long mode,
243 int psize);
244
245extern void htab_initialize(void);
246extern void htab_initialize_secondary(void);
247extern void hpte_init_native(void);
248extern void hpte_init_lpar(void);
249extern void hpte_init_iSeries(void);
250extern void hpte_init_beat(void);
251
252extern void stabs_alloc(void);
253extern void slb_initialize(void);
254extern void slb_flush_and_rebolt(void);
255extern void stab_initialize(unsigned long stab);
256
257#endif /* __ASSEMBLY__ */
258
259/*
260 * VSID allocation
261 *
262 * We first generate a 36-bit "proto-VSID". For kernel addresses this
263 * is equal to the ESID, for user addresses it is:
264 * (context << 15) | (esid & 0x7fff)
265 *
266 * The two forms are distinguishable because the top bit is 0 for user
267 * addresses, whereas the top two bits are 1 for kernel addresses.
268 * Proto-VSIDs with the top two bits equal to 0b10 are reserved for
269 * now.
270 *
271 * The proto-VSIDs are then scrambled into real VSIDs with the
272 * multiplicative hash:
273 *
274 * VSID = (proto-VSID * VSID_MULTIPLIER) % VSID_MODULUS
275 * where VSID_MULTIPLIER = 268435399 = 0xFFFFFC7
276 * VSID_MODULUS = 2^36-1 = 0xFFFFFFFFF
277 *
278 * This scramble is only well defined for proto-VSIDs below
279 * 0xFFFFFFFFF, so both proto-VSID and actual VSID 0xFFFFFFFFF are
280 * reserved. VSID_MULTIPLIER is prime, so in particular it is
281 * co-prime to VSID_MODULUS, making this a 1:1 scrambling function.
282 * Because the modulus is 2^n-1 we can compute it efficiently without
283 * a divide or extra multiply (see below).
284 *
285 * This scheme has several advantages over older methods:
286 *
287 * - We have VSIDs allocated for every kernel address
288 * (i.e. everything above 0xC000000000000000), except the very top
289 * segment, which simplifies several things.
290 *
291 * - We allow for 15 significant bits of ESID and 20 bits of
292 * context for user addresses. i.e. 8T (43 bits) of address space for
293 * up to 1M contexts (although the page table structure and context
294 * allocation will need changes to take advantage of this).
295 *
296 * - The scramble function gives robust scattering in the hash
297 * table (at least based on some initial results). The previous
298 * method was more susceptible to pathological cases giving excessive
299 * hash collisions.
300 */
301/*
302 * WARNING - If you change these you must make sure the asm
303 * implementations in slb_allocate (slb_low.S), do_stab_bolted
304 * (head.S) and ASM_VSID_SCRAMBLE (below) are changed accordingly.
305 *
306 * You'll also need to change the precomputed VSID values in head.S
307 * which are used by the iSeries firmware.
308 */
309
310#define VSID_MULTIPLIER ASM_CONST(200730139) /* 28-bit prime */
311#define VSID_BITS 36
312#define VSID_MODULUS ((1UL<<VSID_BITS)-1)
313
314#define CONTEXT_BITS 19
315#define USER_ESID_BITS 16
316
317#define USER_VSID_RANGE (1UL << (USER_ESID_BITS + SID_SHIFT))
318
319/*
320 * This macro generates asm code to compute the VSID scramble
321 * function. Used in slb_allocate() and do_stab_bolted. The function
322 * computed is: (protovsid*VSID_MULTIPLIER) % VSID_MODULUS
323 *
324 * rt = register continaing the proto-VSID and into which the
325 * VSID will be stored
326 * rx = scratch register (clobbered)
327 *
328 * - rt and rx must be different registers
329 * - The answer will end up in the low 36 bits of rt. The higher
330 * bits may contain other garbage, so you may need to mask the
331 * result.
332 */
333#define ASM_VSID_SCRAMBLE(rt, rx) \
334 lis rx,VSID_MULTIPLIER@h; \
335 ori rx,rx,VSID_MULTIPLIER@l; \
336 mulld rt,rt,rx; /* rt = rt * MULTIPLIER */ \
337 \
338 srdi rx,rt,VSID_BITS; \
339 clrldi rt,rt,(64-VSID_BITS); \
340 add rt,rt,rx; /* add high and low bits */ \
341 /* Now, r3 == VSID (mod 2^36-1), and lies between 0 and \
342 * 2^36-1+2^28-1. That in particular means that if r3 >= \
343 * 2^36-1, then r3+1 has the 2^36 bit set. So, if r3+1 has \
344 * the bit clear, r3 already has the answer we want, if it \
345 * doesn't, the answer is the low 36 bits of r3+1. So in all \
346 * cases the answer is the low 36 bits of (r3 + ((r3+1) >> 36))*/\
347 addi rx,rt,1; \
348 srdi rx,rx,VSID_BITS; /* extract 2^36 bit */ \
349 add rt,rt,rx
350
351
352#ifndef __ASSEMBLY__
353
354typedef unsigned long mm_context_id_t;
355
356typedef struct {
357 mm_context_id_t id;
358 u16 user_psize; /* page size index */
359 u16 sllp; /* SLB entry page size encoding */
360#ifdef CONFIG_HUGETLB_PAGE
361 u16 low_htlb_areas, high_htlb_areas;
362#endif 12#endif
363 unsigned long vdso_base;
364} mm_context_t;
365
366
367static inline unsigned long vsid_scramble(unsigned long protovsid)
368{
369#if 0
370 /* The code below is equivalent to this function for arguments
371 * < 2^VSID_BITS, which is all this should ever be called
372 * with. However gcc is not clever enough to compute the
373 * modulus (2^n-1) without a second multiply. */
374 return ((protovsid * VSID_MULTIPLIER) % VSID_MODULUS);
375#else /* 1 */
376 unsigned long x;
377
378 x = protovsid * VSID_MULTIPLIER;
379 x = (x >> VSID_BITS) + (x & VSID_MODULUS);
380 return (x + ((x+1) >> VSID_BITS)) & VSID_MODULUS;
381#endif /* 1 */
382}
383
384/* This is only valid for addresses >= KERNELBASE */
385static inline unsigned long get_kernel_vsid(unsigned long ea)
386{
387 return vsid_scramble(ea >> SID_SHIFT);
388}
389
390/* This is only valid for user addresses (which are below 2^41) */
391static inline unsigned long get_vsid(unsigned long context, unsigned long ea)
392{
393 return vsid_scramble((context << USER_ESID_BITS)
394 | (ea >> SID_SHIFT));
395}
396
397#define VSID_SCRAMBLE(pvsid) (((pvsid) * VSID_MULTIPLIER) % VSID_MODULUS)
398#define KERNEL_VSID(ea) VSID_SCRAMBLE(GET_ESID(ea))
399
400/* Physical address used by some IO functions */
401typedef unsigned long phys_addr_t;
402
403
404#endif /* __ASSEMBLY */
405 13
406#endif /* CONFIG_PPC64 */
407#endif /* __KERNEL__ */ 14#endif /* __KERNEL__ */
408#endif /* _ASM_POWERPC_MMU_H_ */ 15#endif /* _ASM_POWERPC_MMU_H_ */
diff --git a/include/asm-powerpc/mpic.h b/include/asm-powerpc/mpic.h
index cb204a71e912..e4d5fc5362a0 100644
--- a/include/asm-powerpc/mpic.h
+++ b/include/asm-powerpc/mpic.h
@@ -199,7 +199,7 @@ enum {
199}; 199};
200 200
201 201
202#ifdef CONFIG_MPIC_BROKEN_U3 202#ifdef CONFIG_MPIC_U3_HT_IRQS
203/* Fixup table entry */ 203/* Fixup table entry */
204struct mpic_irq_fixup 204struct mpic_irq_fixup
205{ 205{
@@ -208,7 +208,7 @@ struct mpic_irq_fixup
208 u32 data; 208 u32 data;
209 unsigned int index; 209 unsigned int index;
210}; 210};
211#endif /* CONFIG_MPIC_BROKEN_U3 */ 211#endif /* CONFIG_MPIC_U3_HT_IRQS */
212 212
213 213
214enum mpic_reg_type { 214enum mpic_reg_type {
@@ -239,7 +239,7 @@ struct mpic
239 239
240 /* The "linux" controller struct */ 240 /* The "linux" controller struct */
241 struct irq_chip hc_irq; 241 struct irq_chip hc_irq;
242#ifdef CONFIG_MPIC_BROKEN_U3 242#ifdef CONFIG_MPIC_U3_HT_IRQS
243 struct irq_chip hc_ht_irq; 243 struct irq_chip hc_ht_irq;
244#endif 244#endif
245#ifdef CONFIG_SMP 245#ifdef CONFIG_SMP
@@ -268,7 +268,7 @@ struct mpic
268 /* Spurious vector to program into unused sources */ 268 /* Spurious vector to program into unused sources */
269 unsigned int spurious_vec; 269 unsigned int spurious_vec;
270 270
271#ifdef CONFIG_MPIC_BROKEN_U3 271#ifdef CONFIG_MPIC_U3_HT_IRQS
272 /* The fixup table */ 272 /* The fixup table */
273 struct mpic_irq_fixup *fixups; 273 struct mpic_irq_fixup *fixups;
274 spinlock_t fixup_lock; 274 spinlock_t fixup_lock;
@@ -313,7 +313,7 @@ struct mpic
313/* Set this for a big-endian MPIC */ 313/* Set this for a big-endian MPIC */
314#define MPIC_BIG_ENDIAN 0x00000002 314#define MPIC_BIG_ENDIAN 0x00000002
315/* Broken U3 MPIC */ 315/* Broken U3 MPIC */
316#define MPIC_BROKEN_U3 0x00000004 316#define MPIC_U3_HT_IRQS 0x00000004
317/* Broken IPI registers (autodetected) */ 317/* Broken IPI registers (autodetected) */
318#define MPIC_BROKEN_IPI 0x00000008 318#define MPIC_BROKEN_IPI 0x00000008
319/* MPIC wants a reset */ 319/* MPIC wants a reset */
@@ -352,7 +352,7 @@ struct mpic
352 * @senses_num: number of entries in the array 352 * @senses_num: number of entries in the array
353 * 353 *
354 * Note about the sense array. If none is passed, all interrupts are 354 * Note about the sense array. If none is passed, all interrupts are
355 * setup to be level negative unless MPIC_BROKEN_U3 is set in which 355 * setup to be level negative unless MPIC_U3_HT_IRQS is set in which
356 * case they are edge positive (and the array is ignored anyway). 356 * case they are edge positive (and the array is ignored anyway).
357 * The values in the array start at the first source of the MPIC, 357 * The values in the array start at the first source of the MPIC,
358 * that is senses[0] correspond to linux irq "irq_offset". 358 * that is senses[0] correspond to linux irq "irq_offset".
diff --git a/include/asm-powerpc/of_device.h b/include/asm-powerpc/of_device.h
index a889b2005bf5..4f1aabe0ce73 100644
--- a/include/asm-powerpc/of_device.h
+++ b/include/asm-powerpc/of_device.h
@@ -32,5 +32,8 @@ extern int of_device_register(struct of_device *ofdev);
32extern void of_device_unregister(struct of_device *ofdev); 32extern void of_device_unregister(struct of_device *ofdev);
33extern void of_release_dev(struct device *dev); 33extern void of_release_dev(struct device *dev);
34 34
35extern int of_device_uevent(struct device *dev,
36 char **envp, int num_envp, char *buffer, int buffer_size);
37
35#endif /* __KERNEL__ */ 38#endif /* __KERNEL__ */
36#endif /* _ASM_POWERPC_OF_DEVICE_H */ 39#endif /* _ASM_POWERPC_OF_DEVICE_H */
diff --git a/include/asm-powerpc/oprofile_impl.h b/include/asm-powerpc/oprofile_impl.h
index 94c0ad2bff96..8d6b47f7b300 100644
--- a/include/asm-powerpc/oprofile_impl.h
+++ b/include/asm-powerpc/oprofile_impl.h
@@ -57,6 +57,8 @@ extern struct op_powerpc_model op_model_rs64;
57extern struct op_powerpc_model op_model_power4; 57extern struct op_powerpc_model op_model_power4;
58extern struct op_powerpc_model op_model_7450; 58extern struct op_powerpc_model op_model_7450;
59extern struct op_powerpc_model op_model_cell; 59extern struct op_powerpc_model op_model_cell;
60extern struct op_powerpc_model op_model_pa6t;
61
60 62
61/* All the classic PPC parts use these */ 63/* All the classic PPC parts use these */
62static inline unsigned int classic_ctr_read(unsigned int i) 64static inline unsigned int classic_ctr_read(unsigned int i)
diff --git a/include/asm-powerpc/paca.h b/include/asm-powerpc/paca.h
index 0d3adc09c847..cf95274f735e 100644
--- a/include/asm-powerpc/paca.h
+++ b/include/asm-powerpc/paca.h
@@ -70,6 +70,7 @@ struct paca_struct {
70 s16 hw_cpu_id; /* Physical processor number */ 70 s16 hw_cpu_id; /* Physical processor number */
71 u8 cpu_start; /* At startup, processor spins until */ 71 u8 cpu_start; /* At startup, processor spins until */
72 /* this becomes non-zero. */ 72 /* this becomes non-zero. */
73 struct slb_shadow *slb_shadow_ptr;
73 74
74 /* 75 /*
75 * Now, starting in cacheline 2, the exception save areas 76 * Now, starting in cacheline 2, the exception save areas
@@ -93,6 +94,7 @@ struct paca_struct {
93 u64 stab_rr; /* stab/slb round-robin counter */ 94 u64 stab_rr; /* stab/slb round-robin counter */
94 u64 saved_r1; /* r1 save for RTAS calls */ 95 u64 saved_r1; /* r1 save for RTAS calls */
95 u64 saved_msr; /* MSR saved here by enter_rtas */ 96 u64 saved_msr; /* MSR saved here by enter_rtas */
97 u16 trap_save; /* Used when bad stack is encountered */
96 u8 soft_enabled; /* irq soft-enable flag */ 98 u8 soft_enabled; /* irq soft-enable flag */
97 u8 hard_enabled; /* set if irqs are enabled in MSR */ 99 u8 hard_enabled; /* set if irqs are enabled in MSR */
98 u8 io_sync; /* writel() needs spin_unlock sync */ 100 u8 io_sync; /* writel() needs spin_unlock sync */
@@ -101,8 +103,6 @@ struct paca_struct {
101 u64 user_time; /* accumulated usermode TB ticks */ 103 u64 user_time; /* accumulated usermode TB ticks */
102 u64 system_time; /* accumulated system TB ticks */ 104 u64 system_time; /* accumulated system TB ticks */
103 u64 startpurr; /* PURR/TB value snapshot */ 105 u64 startpurr; /* PURR/TB value snapshot */
104
105 struct slb_shadow *slb_shadow_ptr;
106}; 106};
107 107
108extern struct paca_struct paca[]; 108extern struct paca_struct paca[];
diff --git a/include/asm-powerpc/parport.h b/include/asm-powerpc/parport.h
index 3fca21ddf546..b37b81e37278 100644
--- a/include/asm-powerpc/parport.h
+++ b/include/asm-powerpc/parport.h
@@ -20,18 +20,18 @@ extern struct parport *parport_pc_probe_port (unsigned long int base,
20static int __devinit parport_pc_find_nonpci_ports (int autoirq, int autodma) 20static int __devinit parport_pc_find_nonpci_ports (int autoirq, int autodma)
21{ 21{
22 struct device_node *np; 22 struct device_node *np;
23 u32 *prop; 23 const u32 *prop;
24 u32 io1, io2; 24 u32 io1, io2;
25 int propsize; 25 int propsize;
26 int count = 0; 26 int count = 0;
27 for (np = NULL; (np = of_find_compatible_node(np, 27 for (np = NULL; (np = of_find_compatible_node(np,
28 "parallel", 28 "parallel",
29 "pnpPNP,400")) != NULL;) { 29 "pnpPNP,400")) != NULL;) {
30 prop = (u32 *)get_property(np, "reg", &propsize); 30 prop = of_get_property(np, "reg", &propsize);
31 if (!prop || propsize > 6*sizeof(u32)) 31 if (!prop || propsize > 6*sizeof(u32))
32 continue; 32 continue;
33 io1 = prop[1]; io2 = prop[2]; 33 io1 = prop[1]; io2 = prop[2];
34 prop = (u32 *)get_property(np, "interrupts", NULL); 34 prop = of_get_property(np, "interrupts", NULL);
35 if (!prop) 35 if (!prop)
36 continue; 36 continue;
37 if (parport_pc_probe_port(io1, io2, prop[0], autodma, NULL) != NULL) 37 if (parport_pc_probe_port(io1, io2, prop[0], autodma, NULL) != NULL)
diff --git a/include/asm-powerpc/pci.h b/include/asm-powerpc/pci.h
index ac656ee6bb19..ce0f13e8eb14 100644
--- a/include/asm-powerpc/pci.h
+++ b/include/asm-powerpc/pci.h
@@ -70,19 +70,22 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
70 */ 70 */
71#define PCI_DISABLE_MWI 71#define PCI_DISABLE_MWI
72 72
73extern struct dma_mapping_ops *pci_dma_ops; 73#ifdef CONFIG_PCI
74extern void set_pci_dma_ops(struct dma_mapping_ops *dma_ops);
75extern struct dma_mapping_ops *get_pci_dma_ops(void);
74 76
75/* For DAC DMA, we currently don't support it by default, but 77/* For DAC DMA, we currently don't support it by default, but
76 * we let 64-bit platforms override this. 78 * we let 64-bit platforms override this.
77 */ 79 */
78static inline int pci_dac_dma_supported(struct pci_dev *hwdev,u64 mask) 80static inline int pci_dac_dma_supported(struct pci_dev *hwdev,u64 mask)
79{ 81{
80 if (pci_dma_ops && pci_dma_ops->dac_dma_supported) 82 struct dma_mapping_ops *d = get_pci_dma_ops();
81 return pci_dma_ops->dac_dma_supported(&hwdev->dev, mask); 83
84 if (d && d->dac_dma_supported)
85 return d->dac_dma_supported(&hwdev->dev, mask);
82 return 0; 86 return 0;
83} 87}
84 88
85#ifdef CONFIG_PCI
86static inline void pci_dma_burst_advice(struct pci_dev *pdev, 89static inline void pci_dma_burst_advice(struct pci_dev *pdev,
87 enum pci_dma_burst_strategy *strat, 90 enum pci_dma_burst_strategy *strat,
88 unsigned long *strategy_parameter) 91 unsigned long *strategy_parameter)
@@ -99,6 +102,9 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
99 *strat = PCI_DMA_BURST_MULTIPLE; 102 *strat = PCI_DMA_BURST_MULTIPLE;
100 *strategy_parameter = cacheline_size; 103 *strategy_parameter = cacheline_size;
101} 104}
105#else /* CONFIG_PCI */
106#define set_pci_dma_ops(d)
107#define get_pci_dma_ops() NULL
102#endif 108#endif
103 109
104extern int pci_domain_nr(struct pci_bus *bus); 110extern int pci_domain_nr(struct pci_bus *bus);
diff --git a/include/asm-powerpc/pgtable-4k.h b/include/asm-powerpc/pgtable-4k.h
index 345d9b07b3e2..a28fa8bc01da 100644
--- a/include/asm-powerpc/pgtable-4k.h
+++ b/include/asm-powerpc/pgtable-4k.h
@@ -97,3 +97,6 @@
97 97
98#define pud_ERROR(e) \ 98#define pud_ERROR(e) \
99 printk("%s:%d: bad pud %08lx.\n", __FILE__, __LINE__, pud_val(e)) 99 printk("%s:%d: bad pud %08lx.\n", __FILE__, __LINE__, pud_val(e))
100
101#define remap_4k_pfn(vma, addr, pfn, prot) \
102 remap_pfn_range((vma), (addr), (pfn), PAGE_SIZE, (prot))
diff --git a/include/asm-powerpc/pgtable-64k.h b/include/asm-powerpc/pgtable-64k.h
index 4b7126c53f37..5e84f070eaf7 100644
--- a/include/asm-powerpc/pgtable-64k.h
+++ b/include/asm-powerpc/pgtable-64k.h
@@ -35,6 +35,7 @@
35#define _PAGE_HPTE_SUB 0x0ffff000 /* combo only: sub pages HPTE bits */ 35#define _PAGE_HPTE_SUB 0x0ffff000 /* combo only: sub pages HPTE bits */
36#define _PAGE_HPTE_SUB0 0x08000000 /* combo only: first sub page */ 36#define _PAGE_HPTE_SUB0 0x08000000 /* combo only: first sub page */
37#define _PAGE_COMBO 0x10000000 /* this is a combo 4k page */ 37#define _PAGE_COMBO 0x10000000 /* this is a combo 4k page */
38#define _PAGE_4K_PFN 0x20000000 /* PFN is for a single 4k page */
38#define _PAGE_F_SECOND 0x00008000 /* full page: hidx bits */ 39#define _PAGE_F_SECOND 0x00008000 /* full page: hidx bits */
39#define _PAGE_F_GIX 0x00007000 /* full page: hidx bits */ 40#define _PAGE_F_GIX 0x00007000 /* full page: hidx bits */
40 41
@@ -93,6 +94,10 @@
93#define pte_pagesize_index(pte) \ 94#define pte_pagesize_index(pte) \
94 (((pte) & _PAGE_COMBO)? MMU_PAGE_4K: MMU_PAGE_64K) 95 (((pte) & _PAGE_COMBO)? MMU_PAGE_4K: MMU_PAGE_64K)
95 96
97#define remap_4k_pfn(vma, addr, pfn, prot) \
98 remap_pfn_range((vma), (addr), (pfn), PAGE_SIZE, \
99 __pgprot(pgprot_val((prot)) | _PAGE_4K_PFN))
100
96#endif /* __ASSEMBLY__ */ 101#endif /* __ASSEMBLY__ */
97#endif /* __KERNEL__ */ 102#endif /* __KERNEL__ */
98#endif /* _ASM_POWERPC_PGTABLE_64K_H */ 103#endif /* _ASM_POWERPC_PGTABLE_64K_H */
diff --git a/include/asm-powerpc/pgtable.h b/include/asm-powerpc/pgtable.h
index 10f52743f4ff..19edb6982b81 100644
--- a/include/asm-powerpc/pgtable.h
+++ b/include/asm-powerpc/pgtable.h
@@ -272,7 +272,10 @@ static inline pte_t pte_mkhuge(pte_t pte) {
272 return pte; } 272 return pte; }
273 273
274/* Atomic PTE updates */ 274/* Atomic PTE updates */
275static inline unsigned long pte_update(pte_t *p, unsigned long clr) 275static inline unsigned long pte_update(struct mm_struct *mm,
276 unsigned long addr,
277 pte_t *ptep, unsigned long clr,
278 int huge)
276{ 279{
277 unsigned long old, tmp; 280 unsigned long old, tmp;
278 281
@@ -283,20 +286,15 @@ static inline unsigned long pte_update(pte_t *p, unsigned long clr)
283 andc %1,%0,%4 \n\ 286 andc %1,%0,%4 \n\
284 stdcx. %1,0,%3 \n\ 287 stdcx. %1,0,%3 \n\
285 bne- 1b" 288 bne- 1b"
286 : "=&r" (old), "=&r" (tmp), "=m" (*p) 289 : "=&r" (old), "=&r" (tmp), "=m" (*ptep)
287 : "r" (p), "r" (clr), "m" (*p), "i" (_PAGE_BUSY) 290 : "r" (ptep), "r" (clr), "m" (*ptep), "i" (_PAGE_BUSY)
288 : "cc" ); 291 : "cc" );
292
293 if (old & _PAGE_HASHPTE)
294 hpte_need_flush(mm, addr, ptep, old, huge);
289 return old; 295 return old;
290} 296}
291 297
292/* PTE updating functions, this function puts the PTE in the
293 * batch, doesn't actually triggers the hash flush immediately,
294 * you need to call flush_tlb_pending() to do that.
295 * Pass -1 for "normal" size (4K or 64K)
296 */
297extern void hpte_update(struct mm_struct *mm, unsigned long addr,
298 pte_t *ptep, unsigned long pte, int huge);
299
300static inline int __ptep_test_and_clear_young(struct mm_struct *mm, 298static inline int __ptep_test_and_clear_young(struct mm_struct *mm,
301 unsigned long addr, pte_t *ptep) 299 unsigned long addr, pte_t *ptep)
302{ 300{
@@ -304,11 +302,7 @@ static inline int __ptep_test_and_clear_young(struct mm_struct *mm,
304 302
305 if ((pte_val(*ptep) & (_PAGE_ACCESSED | _PAGE_HASHPTE)) == 0) 303 if ((pte_val(*ptep) & (_PAGE_ACCESSED | _PAGE_HASHPTE)) == 0)
306 return 0; 304 return 0;
307 old = pte_update(ptep, _PAGE_ACCESSED); 305 old = pte_update(mm, addr, ptep, _PAGE_ACCESSED, 0);
308 if (old & _PAGE_HASHPTE) {
309 hpte_update(mm, addr, ptep, old, 0);
310 flush_tlb_pending();
311 }
312 return (old & _PAGE_ACCESSED) != 0; 306 return (old & _PAGE_ACCESSED) != 0;
313} 307}
314#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG 308#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
@@ -331,9 +325,7 @@ static inline int __ptep_test_and_clear_dirty(struct mm_struct *mm,
331 325
332 if ((pte_val(*ptep) & _PAGE_DIRTY) == 0) 326 if ((pte_val(*ptep) & _PAGE_DIRTY) == 0)
333 return 0; 327 return 0;
334 old = pte_update(ptep, _PAGE_DIRTY); 328 old = pte_update(mm, addr, ptep, _PAGE_DIRTY, 0);
335 if (old & _PAGE_HASHPTE)
336 hpte_update(mm, addr, ptep, old, 0);
337 return (old & _PAGE_DIRTY) != 0; 329 return (old & _PAGE_DIRTY) != 0;
338} 330}
339#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY 331#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
@@ -352,9 +344,7 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
352 344
353 if ((pte_val(*ptep) & _PAGE_RW) == 0) 345 if ((pte_val(*ptep) & _PAGE_RW) == 0)
354 return; 346 return;
355 old = pte_update(ptep, _PAGE_RW); 347 old = pte_update(mm, addr, ptep, _PAGE_RW, 0);
356 if (old & _PAGE_HASHPTE)
357 hpte_update(mm, addr, ptep, old, 0);
358} 348}
359 349
360/* 350/*
@@ -378,7 +368,6 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
378({ \ 368({ \
379 int __dirty = __ptep_test_and_clear_dirty((__vma)->vm_mm, __address, \ 369 int __dirty = __ptep_test_and_clear_dirty((__vma)->vm_mm, __address, \
380 __ptep); \ 370 __ptep); \
381 flush_tlb_page(__vma, __address); \
382 __dirty; \ 371 __dirty; \
383}) 372})
384 373
@@ -386,20 +375,14 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
386static inline pte_t ptep_get_and_clear(struct mm_struct *mm, 375static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
387 unsigned long addr, pte_t *ptep) 376 unsigned long addr, pte_t *ptep)
388{ 377{
389 unsigned long old = pte_update(ptep, ~0UL); 378 unsigned long old = pte_update(mm, addr, ptep, ~0UL, 0);
390
391 if (old & _PAGE_HASHPTE)
392 hpte_update(mm, addr, ptep, old, 0);
393 return __pte(old); 379 return __pte(old);
394} 380}
395 381
396static inline void pte_clear(struct mm_struct *mm, unsigned long addr, 382static inline void pte_clear(struct mm_struct *mm, unsigned long addr,
397 pte_t * ptep) 383 pte_t * ptep)
398{ 384{
399 unsigned long old = pte_update(ptep, ~0UL); 385 pte_update(mm, addr, ptep, ~0UL, 0);
400
401 if (old & _PAGE_HASHPTE)
402 hpte_update(mm, addr, ptep, old, 0);
403} 386}
404 387
405/* 388/*
@@ -408,10 +391,8 @@ static inline void pte_clear(struct mm_struct *mm, unsigned long addr,
408static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, 391static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
409 pte_t *ptep, pte_t pte) 392 pte_t *ptep, pte_t pte)
410{ 393{
411 if (pte_present(*ptep)) { 394 if (pte_present(*ptep))
412 pte_clear(mm, addr, ptep); 395 pte_clear(mm, addr, ptep);
413 flush_tlb_pending();
414 }
415 pte = __pte(pte_val(pte) & ~_PAGE_HPTEFLAGS); 396 pte = __pte(pte_val(pte) & ~_PAGE_HPTEFLAGS);
416 *ptep = pte; 397 *ptep = pte;
417} 398}
@@ -467,16 +448,6 @@ extern pgd_t swapper_pg_dir[];
467 448
468extern void paging_init(void); 449extern void paging_init(void);
469 450
470/*
471 * This gets called at the end of handling a page fault, when
472 * the kernel has put a new PTE into the page table for the process.
473 * We use it to put a corresponding HPTE into the hash table
474 * ahead of time, instead of waiting for the inevitable extra
475 * hash-table miss exception.
476 */
477struct vm_area_struct;
478extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t);
479
480/* Encode and de-code a swap entry */ 451/* Encode and de-code a swap entry */
481#define __swp_type(entry) (((entry).val >> 1) & 0x3f) 452#define __swp_type(entry) (((entry).val >> 1) & 0x3f)
482#define __swp_offset(entry) ((entry).val >> 8) 453#define __swp_offset(entry) ((entry).val >> 8)
@@ -522,6 +493,7 @@ void pgtable_cache_init(void);
522 return pt; 493 return pt;
523} 494}
524 495
496
525#include <asm-generic/pgtable.h> 497#include <asm-generic/pgtable.h>
526 498
527#endif /* __ASSEMBLY__ */ 499#endif /* __ASSEMBLY__ */
diff --git a/include/asm-powerpc/pmc.h b/include/asm-powerpc/pmc.h
index 8588be68e0ad..d6a616a1b3ea 100644
--- a/include/asm-powerpc/pmc.h
+++ b/include/asm-powerpc/pmc.h
@@ -30,6 +30,7 @@ void release_pmc_hardware(void);
30 30
31#ifdef CONFIG_PPC64 31#ifdef CONFIG_PPC64
32void power4_enable_pmcs(void); 32void power4_enable_pmcs(void);
33void pasemi_enable_pmcs(void);
33#endif 34#endif
34 35
35#endif /* __KERNEL__ */ 36#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/ppc-pci.h b/include/asm-powerpc/ppc-pci.h
index ab6eddb518c7..d74b2965bb82 100644
--- a/include/asm-powerpc/ppc-pci.h
+++ b/include/asm-powerpc/ppc-pci.h
@@ -10,6 +10,8 @@
10#define _ASM_POWERPC_PPC_PCI_H 10#define _ASM_POWERPC_PPC_PCI_H
11#ifdef __KERNEL__ 11#ifdef __KERNEL__
12 12
13#ifdef CONFIG_PCI
14
13#include <linux/pci.h> 15#include <linux/pci.h>
14#include <asm/pci-bridge.h> 16#include <asm/pci-bridge.h>
15 17
@@ -22,7 +24,7 @@ extern void pci_setup_phb_io_dynamic(struct pci_controller *hose, int primary);
22extern struct list_head hose_list; 24extern struct list_head hose_list;
23extern int global_phb_number; 25extern int global_phb_number;
24 26
25extern unsigned long find_and_init_phbs(void); 27extern void find_and_init_phbs(void);
26 28
27extern struct pci_dev *ppc64_isabridge_dev; /* may be NULL if no ISA bus */ 29extern struct pci_dev *ppc64_isabridge_dev; /* may be NULL if no ISA bus */
28 30
@@ -68,7 +70,7 @@ struct pci_dev *pci_get_device_by_addr(unsigned long addr);
68void eeh_slot_error_detail (struct pci_dn *pdn, int severity); 70void eeh_slot_error_detail (struct pci_dn *pdn, int severity);
69 71
70/** 72/**
71 * rtas_pci_enableo - enable IO transfers for this slot 73 * rtas_pci_enable - enable IO transfers for this slot
72 * @pdn: pci device node 74 * @pdn: pci device node
73 * @function: either EEH_THAW_MMIO or EEH_THAW_DMA 75 * @function: either EEH_THAW_MMIO or EEH_THAW_DMA
74 * 76 *
@@ -89,6 +91,7 @@ int rtas_pci_enable(struct pci_dn *pdn, int function);
89 * Returns a non-zero value if the reset failed. 91 * Returns a non-zero value if the reset failed.
90 */ 92 */
91int rtas_set_slot_reset (struct pci_dn *); 93int rtas_set_slot_reset (struct pci_dn *);
94int eeh_wait_for_slot_status(struct pci_dn *pdn, int max_wait_msecs);
92 95
93/** 96/**
94 * eeh_restore_bars - Restore device configuration info. 97 * eeh_restore_bars - Restore device configuration info.
@@ -126,5 +129,10 @@ struct device_node * find_device_pe(struct device_node *dn);
126 129
127#endif 130#endif
128 131
132#else /* CONFIG_PCI */
133static inline void find_and_init_phbs(void) { }
134static inline void init_pci_config_tokens(void) { }
135#endif /* !CONFIG_PCI */
136
129#endif /* __KERNEL__ */ 137#endif /* __KERNEL__ */
130#endif /* _ASM_POWERPC_PPC_PCI_H */ 138#endif /* _ASM_POWERPC_PPC_PCI_H */
diff --git a/include/asm-powerpc/processor.h b/include/asm-powerpc/processor.h
index a26c32ee5527..d947b1609491 100644
--- a/include/asm-powerpc/processor.h
+++ b/include/asm-powerpc/processor.h
@@ -133,7 +133,6 @@ struct thread_struct {
133 mm_segment_t fs; /* for get_fs() validation */ 133 mm_segment_t fs; /* for get_fs() validation */
134#ifdef CONFIG_PPC32 134#ifdef CONFIG_PPC32
135 void *pgdir; /* root of page-table tree */ 135 void *pgdir; /* root of page-table tree */
136 signed long last_syscall;
137#endif 136#endif
138#if defined(CONFIG_4xx) || defined (CONFIG_BOOKE) 137#if defined(CONFIG_4xx) || defined (CONFIG_BOOKE)
139 unsigned long dbcr0; /* debug control register values */ 138 unsigned long dbcr0; /* debug control register values */
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h
index 020ed015a94b..ec400f608e16 100644
--- a/include/asm-powerpc/prom.h
+++ b/include/asm-powerpc/prom.h
@@ -18,7 +18,9 @@
18#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/proc_fs.h> 19#include <linux/proc_fs.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <asm/irq.h>
21#include <asm/atomic.h> 22#include <asm/atomic.h>
23#include <asm/io.h>
22 24
23/* Definitions used by the flattened device tree */ 25/* Definitions used by the flattened device tree */
24#define OF_DT_HEADER 0xd00dfeed /* marker */ 26#define OF_DT_HEADER 0xd00dfeed /* marker */
@@ -58,6 +60,8 @@ struct boot_param_header
58 u32 boot_cpuid_phys; /* Physical CPU id we're booting on */ 60 u32 boot_cpuid_phys; /* Physical CPU id we're booting on */
59 /* version 3 fields below */ 61 /* version 3 fields below */
60 u32 dt_strings_size; /* size of the DT strings block */ 62 u32 dt_strings_size; /* size of the DT strings block */
63 /* version 17 fields below */
64 u32 dt_struct_size; /* size of the DT structure block */
61}; 65};
62 66
63 67
@@ -68,7 +72,7 @@ typedef u32 ihandle;
68struct property { 72struct property {
69 char *name; 73 char *name;
70 int length; 74 int length;
71 unsigned char *value; 75 void *value;
72 struct property *next; 76 struct property *next;
73}; 77};
74 78
@@ -108,14 +112,6 @@ static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_e
108} 112}
109 113
110 114
111/* OBSOLETE: Old style node lookup */
112extern struct device_node *find_devices(const char *name);
113extern struct device_node *find_type_devices(const char *type);
114extern struct device_node *find_path_device(const char *path);
115extern struct device_node *find_compatible_devices(const char *type,
116 const char *compat);
117extern struct device_node *find_all_nodes(void);
118
119/* New style node lookup */ 115/* New style node lookup */
120extern struct device_node *of_find_node_by_name(struct device_node *from, 116extern struct device_node *of_find_node_by_name(struct device_node *from,
121 const char *name); 117 const char *name);
@@ -159,15 +155,17 @@ extern void of_detach_node(const struct device_node *);
159extern void finish_device_tree(void); 155extern void finish_device_tree(void);
160extern void unflatten_device_tree(void); 156extern void unflatten_device_tree(void);
161extern void early_init_devtree(void *); 157extern void early_init_devtree(void *);
162extern int device_is_compatible(const struct device_node *device, 158extern int of_device_is_compatible(const struct device_node *device,
163 const char *); 159 const char *);
160#define device_is_compatible(d, c) of_device_is_compatible((d), (c))
164extern int machine_is_compatible(const char *compat); 161extern int machine_is_compatible(const char *compat);
165extern const void *get_property(const struct device_node *node, 162extern const void *of_get_property(const struct device_node *node,
166 const char *name, 163 const char *name,
167 int *lenp); 164 int *lenp);
165#define get_property(a, b, c) of_get_property((a), (b), (c))
168extern void print_properties(struct device_node *node); 166extern void print_properties(struct device_node *node);
169extern int prom_n_addr_cells(struct device_node* np); 167extern int of_n_addr_cells(struct device_node* np);
170extern int prom_n_size_cells(struct device_node* np); 168extern int of_n_size_cells(struct device_node* np);
171extern int prom_n_intr_cells(struct device_node* np); 169extern int prom_n_intr_cells(struct device_node* np);
172extern void prom_get_irq_senses(unsigned char *senses, int off, int max); 170extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
173extern int prom_add_property(struct device_node* np, struct property* prop); 171extern int prom_add_property(struct device_node* np, struct property* prop);
@@ -350,6 +348,16 @@ static inline int of_irq_to_resource(struct device_node *dev, int index, struct
350 return irq; 348 return irq;
351} 349}
352 350
351static inline void __iomem *of_iomap(struct device_node *np, int index)
352{
353 struct resource res;
354
355 if (of_address_to_resource(np, index, &res))
356 return NULL;
357
358 return ioremap(res.start, 1 + res.end - res.start);
359}
360
353 361
354#endif /* __KERNEL__ */ 362#endif /* __KERNEL__ */
355#endif /* _POWERPC_PROM_H */ 363#endif /* _POWERPC_PROM_H */
diff --git a/include/asm-powerpc/reg.h b/include/asm-powerpc/reg.h
index 0d7f0164ed81..749c7f953b58 100644
--- a/include/asm-powerpc/reg.h
+++ b/include/asm-powerpc/reg.h
@@ -469,12 +469,68 @@
469#define SPRN_SIAR 780 469#define SPRN_SIAR 780
470#define SPRN_SDAR 781 470#define SPRN_SDAR 781
471 471
472#define PA6T_SPRN_PMC0 787 472#define SPRN_PA6T_MMCR0 795
473#define PA6T_SPRN_PMC1 788 473#define PA6T_MMCR0_EN0 0x0000000000000001UL
474#define PA6T_SPRN_PMC2 789 474#define PA6T_MMCR0_EN1 0x0000000000000002UL
475#define PA6T_SPRN_PMC3 790 475#define PA6T_MMCR0_EN2 0x0000000000000004UL
476#define PA6T_SPRN_PMC4 791 476#define PA6T_MMCR0_EN3 0x0000000000000008UL
477#define PA6T_SPRN_PMC5 792 477#define PA6T_MMCR0_EN4 0x0000000000000010UL
478#define PA6T_MMCR0_EN5 0x0000000000000020UL
479#define PA6T_MMCR0_SUPEN 0x0000000000000040UL
480#define PA6T_MMCR0_PREN 0x0000000000000080UL
481#define PA6T_MMCR0_HYPEN 0x0000000000000100UL
482#define PA6T_MMCR0_FCM0 0x0000000000000200UL
483#define PA6T_MMCR0_FCM1 0x0000000000000400UL
484#define PA6T_MMCR0_INTGEN 0x0000000000000800UL
485#define PA6T_MMCR0_INTEN0 0x0000000000001000UL
486#define PA6T_MMCR0_INTEN1 0x0000000000002000UL
487#define PA6T_MMCR0_INTEN2 0x0000000000004000UL
488#define PA6T_MMCR0_INTEN3 0x0000000000008000UL
489#define PA6T_MMCR0_INTEN4 0x0000000000010000UL
490#define PA6T_MMCR0_INTEN5 0x0000000000020000UL
491#define PA6T_MMCR0_DISCNT 0x0000000000040000UL
492#define PA6T_MMCR0_UOP 0x0000000000080000UL
493#define PA6T_MMCR0_TRG 0x0000000000100000UL
494#define PA6T_MMCR0_TRGEN 0x0000000000200000UL
495#define PA6T_MMCR0_TRGREG 0x0000000001600000UL
496#define PA6T_MMCR0_SIARLOG 0x0000000002000000UL
497#define PA6T_MMCR0_SDARLOG 0x0000000004000000UL
498#define PA6T_MMCR0_PROEN 0x0000000008000000UL
499#define PA6T_MMCR0_PROLOG 0x0000000010000000UL
500#define PA6T_MMCR0_DAMEN2 0x0000000020000000UL
501#define PA6T_MMCR0_DAMEN3 0x0000000040000000UL
502#define PA6T_MMCR0_DAMEN4 0x0000000080000000UL
503#define PA6T_MMCR0_DAMEN5 0x0000000100000000UL
504#define PA6T_MMCR0_DAMSEL2 0x0000000200000000UL
505#define PA6T_MMCR0_DAMSEL3 0x0000000400000000UL
506#define PA6T_MMCR0_DAMSEL4 0x0000000800000000UL
507#define PA6T_MMCR0_DAMSEL5 0x0000001000000000UL
508#define PA6T_MMCR0_HANDDIS 0x0000002000000000UL
509#define PA6T_MMCR0_PCTEN 0x0000004000000000UL
510#define PA6T_MMCR0_SOCEN 0x0000008000000000UL
511#define PA6T_MMCR0_SOCMOD 0x0000010000000000UL
512
513#define SPRN_PA6T_MMCR1 798
514#define PA6T_MMCR1_ES2 0x00000000000000ffUL
515#define PA6T_MMCR1_ES3 0x000000000000ff00UL
516#define PA6T_MMCR1_ES4 0x0000000000ff0000UL
517#define PA6T_MMCR1_ES5 0x00000000ff000000UL
518
519#define SPRN_PA6T_SIAR 780
520#define SPRN_PA6T_UPMC0 771
521#define SPRN_PA6T_UPMC1 772
522#define SPRN_PA6T_UPMC2 773
523#define SPRN_PA6T_UPMC3 774
524#define SPRN_PA6T_UPMC4 775
525#define SPRN_PA6T_UPMC5 776
526#define SPRN_PA6T_UMMCR0 779
527#define SPRN_PA6T_UMMCR1 782
528#define SPRN_PA6T_PMC0 787
529#define SPRN_PA6T_PMC1 788
530#define SPRN_PA6T_PMC2 789
531#define SPRN_PA6T_PMC3 790
532#define SPRN_PA6T_PMC4 791
533#define SPRN_PA6T_PMC5 792
478 534
479#else /* 32-bit */ 535#else /* 32-bit */
480#define SPRN_MMCR0 952 /* Monitor Mode Control Register 0 */ 536#define SPRN_MMCR0 952 /* Monitor Mode Control Register 0 */
diff --git a/include/asm-powerpc/spu_csa.h b/include/asm-powerpc/spu_csa.h
index 8aad0619eb8e..02e56a6685a2 100644
--- a/include/asm-powerpc/spu_csa.h
+++ b/include/asm-powerpc/spu_csa.h
@@ -242,6 +242,7 @@ struct spu_state {
242 u64 spu_chnldata_RW[32]; 242 u64 spu_chnldata_RW[32];
243 u32 spu_mailbox_data[4]; 243 u32 spu_mailbox_data[4];
244 u32 pu_mailbox_data[1]; 244 u32 pu_mailbox_data[1];
245 u64 dar, dsisr;
245 unsigned long suspend_time; 246 unsigned long suspend_time;
246 spinlock_t register_lock; 247 spinlock_t register_lock;
247}; 248};
diff --git a/include/asm-powerpc/system.h b/include/asm-powerpc/system.h
index f7b1227d6454..d3e0906ff2bc 100644
--- a/include/asm-powerpc/system.h
+++ b/include/asm-powerpc/system.h
@@ -131,6 +131,7 @@ extern void enable_kernel_altivec(void);
131extern void giveup_altivec(struct task_struct *); 131extern void giveup_altivec(struct task_struct *);
132extern void load_up_altivec(struct task_struct *); 132extern void load_up_altivec(struct task_struct *);
133extern int emulate_altivec(struct pt_regs *); 133extern int emulate_altivec(struct pt_regs *);
134extern void enable_kernel_spe(void);
134extern void giveup_spe(struct task_struct *); 135extern void giveup_spe(struct task_struct *);
135extern void load_up_spe(struct task_struct *); 136extern void load_up_spe(struct task_struct *);
136extern int fix_alignment(struct pt_regs *); 137extern int fix_alignment(struct pt_regs *);
diff --git a/include/asm-powerpc/tlb.h b/include/asm-powerpc/tlb.h
index 4e2a834683fb..0a17682663d8 100644
--- a/include/asm-powerpc/tlb.h
+++ b/include/asm-powerpc/tlb.h
@@ -38,7 +38,6 @@ extern void pte_free_finish(void);
38 38
39static inline void tlb_flush(struct mmu_gather *tlb) 39static inline void tlb_flush(struct mmu_gather *tlb)
40{ 40{
41 flush_tlb_pending();
42 pte_free_finish(); 41 pte_free_finish();
43} 42}
44 43
diff --git a/include/asm-powerpc/tlbflush.h b/include/asm-powerpc/tlbflush.h
index 93c7d0c7230f..86e6266a028b 100644
--- a/include/asm-powerpc/tlbflush.h
+++ b/include/asm-powerpc/tlbflush.h
@@ -17,10 +17,73 @@
17 */ 17 */
18#ifdef __KERNEL__ 18#ifdef __KERNEL__
19 19
20
21struct mm_struct; 20struct mm_struct;
21struct vm_area_struct;
22
23#if defined(CONFIG_4xx) || defined(CONFIG_8xx) || defined(CONFIG_FSL_BOOKE)
24/*
25 * TLB flushing for software loaded TLB chips
26 *
27 * TODO: (CONFIG_FSL_BOOKE) determine if flush_tlb_range &
28 * flush_tlb_kernel_range are best implemented as tlbia vs
29 * specific tlbie's
30 */
31
32extern void _tlbie(unsigned long address);
33
34#if defined(CONFIG_40x) || defined(CONFIG_8xx)
35#define _tlbia() asm volatile ("tlbia; sync" : : : "memory")
36#else /* CONFIG_44x || CONFIG_FSL_BOOKE */
37extern void _tlbia(void);
38#endif
39
40static inline void flush_tlb_mm(struct mm_struct *mm)
41{
42 _tlbia();
43}
44
45static inline void flush_tlb_page(struct vm_area_struct *vma,
46 unsigned long vmaddr)
47{
48 _tlbie(vmaddr);
49}
50
51static inline void flush_tlb_page_nohash(struct vm_area_struct *vma,
52 unsigned long vmaddr)
53{
54 _tlbie(vmaddr);
55}
56
57static inline void flush_tlb_range(struct vm_area_struct *vma,
58 unsigned long start, unsigned long end)
59{
60 _tlbia();
61}
62
63static inline void flush_tlb_kernel_range(unsigned long start,
64 unsigned long end)
65{
66 _tlbia();
67}
22 68
23#ifdef CONFIG_PPC64 69#elif defined(CONFIG_PPC32)
70/*
71 * TLB flushing for "classic" hash-MMMU 32-bit CPUs, 6xx, 7xx, 7xxx
72 */
73extern void _tlbie(unsigned long address);
74extern void _tlbia(void);
75
76extern void flush_tlb_mm(struct mm_struct *mm);
77extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
78extern void flush_tlb_page_nohash(struct vm_area_struct *vma, unsigned long addr);
79extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
80 unsigned long end);
81extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
82
83#else
84/*
85 * TLB flushing for 64-bit has-MMU CPUs
86 */
24 87
25#include <linux/percpu.h> 88#include <linux/percpu.h>
26#include <asm/page.h> 89#include <asm/page.h>
@@ -28,117 +91,90 @@ struct mm_struct;
28#define PPC64_TLB_BATCH_NR 192 91#define PPC64_TLB_BATCH_NR 192
29 92
30struct ppc64_tlb_batch { 93struct ppc64_tlb_batch {
31 unsigned long index; 94 int active;
32 struct mm_struct *mm; 95 unsigned long index;
33 real_pte_t pte[PPC64_TLB_BATCH_NR]; 96 struct mm_struct *mm;
34 unsigned long vaddr[PPC64_TLB_BATCH_NR]; 97 real_pte_t pte[PPC64_TLB_BATCH_NR];
35 unsigned int psize; 98 unsigned long vaddr[PPC64_TLB_BATCH_NR];
99 unsigned int psize;
36}; 100};
37DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch); 101DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
38 102
39extern void __flush_tlb_pending(struct ppc64_tlb_batch *batch); 103extern void __flush_tlb_pending(struct ppc64_tlb_batch *batch);
40 104
41static inline void flush_tlb_pending(void) 105extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr,
106 pte_t *ptep, unsigned long pte, int huge);
107
108#define __HAVE_ARCH_ENTER_LAZY_MMU_MODE
109
110static inline void arch_enter_lazy_mmu_mode(void)
111{
112 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
113
114 batch->active = 1;
115}
116
117static inline void arch_leave_lazy_mmu_mode(void)
42{ 118{
43 struct ppc64_tlb_batch *batch = &get_cpu_var(ppc64_tlb_batch); 119 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
44 120
45 if (batch->index) 121 if (batch->index)
46 __flush_tlb_pending(batch); 122 __flush_tlb_pending(batch);
47 put_cpu_var(ppc64_tlb_batch); 123 batch->active = 0;
48} 124}
49 125
126#define arch_flush_lazy_mmu_mode() do {} while (0)
127
128
50extern void flush_hash_page(unsigned long va, real_pte_t pte, int psize, 129extern void flush_hash_page(unsigned long va, real_pte_t pte, int psize,
51 int local); 130 int local);
52extern void flush_hash_range(unsigned long number, int local); 131extern void flush_hash_range(unsigned long number, int local);
53 132
54#else /* CONFIG_PPC64 */
55
56#include <linux/mm.h>
57
58extern void _tlbie(unsigned long address);
59extern void _tlbia(void);
60
61/*
62 * TODO: (CONFIG_FSL_BOOKE) determine if flush_tlb_range &
63 * flush_tlb_kernel_range are best implemented as tlbia vs
64 * specific tlbie's
65 */
66
67#if (defined(CONFIG_4xx) && !defined(CONFIG_44x)) || defined(CONFIG_8xx)
68#define flush_tlb_pending() asm volatile ("tlbia; sync" : : : "memory")
69#elif defined(CONFIG_4xx) || defined(CONFIG_FSL_BOOKE)
70#define flush_tlb_pending() _tlbia()
71#endif
72
73/*
74 * This gets called at the end of handling a page fault, when
75 * the kernel has put a new PTE into the page table for the process.
76 * We use it to ensure coherency between the i-cache and d-cache
77 * for the page which has just been mapped in.
78 * On machines which use an MMU hash table, we use this to put a
79 * corresponding HPTE into the hash table ahead of time, instead of
80 * waiting for the inevitable extra hash-table miss exception.
81 */
82extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t);
83
84#endif /* CONFIG_PPC64 */
85
86#if defined(CONFIG_PPC64) || defined(CONFIG_4xx) || \
87 defined(CONFIG_FSL_BOOKE) || defined(CONFIG_8xx)
88 133
89static inline void flush_tlb_mm(struct mm_struct *mm) 134static inline void flush_tlb_mm(struct mm_struct *mm)
90{ 135{
91 flush_tlb_pending();
92} 136}
93 137
94static inline void flush_tlb_page(struct vm_area_struct *vma, 138static inline void flush_tlb_page(struct vm_area_struct *vma,
95 unsigned long vmaddr) 139 unsigned long vmaddr)
96{ 140{
97#ifdef CONFIG_PPC64
98 flush_tlb_pending();
99#else
100 _tlbie(vmaddr);
101#endif
102} 141}
103 142
104static inline void flush_tlb_page_nohash(struct vm_area_struct *vma, 143static inline void flush_tlb_page_nohash(struct vm_area_struct *vma,
105 unsigned long vmaddr) 144 unsigned long vmaddr)
106{ 145{
107#ifndef CONFIG_PPC64
108 _tlbie(vmaddr);
109#endif
110} 146}
111 147
112static inline void flush_tlb_range(struct vm_area_struct *vma, 148static inline void flush_tlb_range(struct vm_area_struct *vma,
113 unsigned long start, unsigned long end) 149 unsigned long start, unsigned long end)
114{ 150{
115 flush_tlb_pending();
116} 151}
117 152
118static inline void flush_tlb_kernel_range(unsigned long start, 153static inline void flush_tlb_kernel_range(unsigned long start,
119 unsigned long end) 154 unsigned long end)
120{ 155{
121 flush_tlb_pending();
122} 156}
123 157
124#else /* 6xx, 7xx, 7xxx cpus */
125
126extern void flush_tlb_mm(struct mm_struct *mm);
127extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
128extern void flush_tlb_page_nohash(struct vm_area_struct *vma, unsigned long addr);
129extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
130 unsigned long end);
131extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
132
133#endif 158#endif
134 159
135/* 160/*
161 * This gets called at the end of handling a page fault, when
162 * the kernel has put a new PTE into the page table for the process.
163 * We use it to ensure coherency between the i-cache and d-cache
164 * for the page which has just been mapped in.
165 * On machines which use an MMU hash table, we use this to put a
166 * corresponding HPTE into the hash table ahead of time, instead of
167 * waiting for the inevitable extra hash-table miss exception.
168 */
169extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t);
170
171/*
136 * This is called in munmap when we have freed up some page-table 172 * This is called in munmap when we have freed up some page-table
137 * pages. We don't need to do anything here, there's nothing special 173 * pages. We don't need to do anything here, there's nothing special
138 * about our page-table pages. -- paulus 174 * about our page-table pages. -- paulus
139 */ 175 */
140static inline void flush_tlb_pgtables(struct mm_struct *mm, 176static inline void flush_tlb_pgtables(struct mm_struct *mm,
141 unsigned long start, unsigned long end) 177 unsigned long start, unsigned long end)
142{ 178{
143} 179}
144 180
diff --git a/include/asm-powerpc/uaccess.h b/include/asm-powerpc/uaccess.h
index adbf16b8cfbb..8e798e3758bc 100644
--- a/include/asm-powerpc/uaccess.h
+++ b/include/asm-powerpc/uaccess.h
@@ -110,12 +110,18 @@ struct exception_table_entry {
110 __get_user_nocheck((x), (ptr), sizeof(*(ptr))) 110 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
111#define __put_user(x, ptr) \ 111#define __put_user(x, ptr) \
112 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) 112 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
113
113#ifndef __powerpc64__ 114#ifndef __powerpc64__
114#define __get_user64(x, ptr) \ 115#define __get_user64(x, ptr) \
115 __get_user64_nocheck((x), (ptr), sizeof(*(ptr))) 116 __get_user64_nocheck((x), (ptr), sizeof(*(ptr)))
116#define __put_user64(x, ptr) __put_user(x, ptr) 117#define __put_user64(x, ptr) __put_user(x, ptr)
117#endif 118#endif
118 119
120#define __get_user_inatomic(x, ptr) \
121 __get_user_nosleep((x), (ptr), sizeof(*(ptr)))
122#define __put_user_inatomic(x, ptr) \
123 __put_user_nosleep((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
124
119#define __get_user_unaligned __get_user 125#define __get_user_unaligned __get_user
120#define __put_user_unaligned __put_user 126#define __put_user_unaligned __put_user
121 127
@@ -198,6 +204,16 @@ do { \
198 __pu_err; \ 204 __pu_err; \
199}) 205})
200 206
207#define __put_user_nosleep(x, ptr, size) \
208({ \
209 long __pu_err; \
210 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
211 __chk_user_ptr(ptr); \
212 __put_user_size((x), __pu_addr, (size), __pu_err); \
213 __pu_err; \
214})
215
216
201extern long __get_user_bad(void); 217extern long __get_user_bad(void);
202 218
203#define __get_user_asm(x, addr, err, op) \ 219#define __get_user_asm(x, addr, err, op) \
@@ -297,6 +313,18 @@ do { \
297 __gu_err; \ 313 __gu_err; \
298}) 314})
299 315
316#define __get_user_nosleep(x, ptr, size) \
317({ \
318 long __gu_err; \
319 unsigned long __gu_val; \
320 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
321 __chk_user_ptr(ptr); \
322 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
323 (x) = (__typeof__(*(ptr)))__gu_val; \
324 __gu_err; \
325})
326
327
300/* more complex routines */ 328/* more complex routines */
301 329
302extern unsigned long __copy_tofrom_user(void __user *to, 330extern unsigned long __copy_tofrom_user(void __user *to,
diff --git a/include/asm-powerpc/uic.h b/include/asm-powerpc/uic.h
new file mode 100644
index 000000000000..970eb7e2186a
--- /dev/null
+++ b/include/asm-powerpc/uic.h
@@ -0,0 +1,23 @@
1/*
2 * include/asm-powerpc/uic.h
3 *
4 * IBM PPC4xx UIC external definitions and structure.
5 *
6 * Maintainer: David Gibson <dwg@au1.ibm.com>
7 * Copyright 2007 IBM Corporation.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
13 */
14#ifndef _ASM_POWERPC_UIC_H
15#define _ASM_POWERPC_UIC_H
16
17#ifdef __KERNEL__
18
19extern void __init uic_init_tree(void);
20extern unsigned int uic_get_irq(void);
21
22#endif /* __KERNEL__ */
23#endif /* _ASM_POWERPC_UIC_H */
diff --git a/include/asm-ppc/ibm4xx.h b/include/asm-ppc/ibm4xx.h
index 92fd02d7b177..ed6891af05d3 100644
--- a/include/asm-ppc/ibm4xx.h
+++ b/include/asm-ppc/ibm4xx.h
@@ -47,12 +47,8 @@
47#include <platforms/4xx/walnut.h> 47#include <platforms/4xx/walnut.h>
48#endif 48#endif
49 49
50#if defined(CONFIG_XILINX_ML300) 50#if defined(CONFIG_XILINX_VIRTEX)
51#include <platforms/4xx/xilinx_ml300.h> 51#include <platforms/4xx/virtex.h>
52#endif
53
54#if defined(CONFIG_XILINX_ML403)
55#include <platforms/4xx/xilinx_ml403.h>
56#endif 52#endif
57 53
58#ifndef __ASSEMBLY__ 54#ifndef __ASSEMBLY__
diff --git a/include/asm-ppc/ppc_sys.h b/include/asm-ppc/ppc_sys.h
index 40f197af6508..de99e92d627b 100644
--- a/include/asm-ppc/ppc_sys.h
+++ b/include/asm-ppc/ppc_sys.h
@@ -33,8 +33,6 @@
33#include <asm/mpc52xx.h> 33#include <asm/mpc52xx.h>
34#elif defined(CONFIG_MPC10X_BRIDGE) 34#elif defined(CONFIG_MPC10X_BRIDGE)
35#include <asm/mpc10x.h> 35#include <asm/mpc10x.h>
36#elif defined(CONFIG_XILINX_VIRTEX)
37#include <platforms/4xx/virtex.h>
38#else 36#else
39#error "need definition of ppc_sys_devices" 37#error "need definition of ppc_sys_devices"
40#endif 38#endif
diff --git a/include/asm-ppc/prom.h b/include/asm-ppc/prom.h
index adc5ae784924..901f7fa8b2d7 100644
--- a/include/asm-ppc/prom.h
+++ b/include/asm-ppc/prom.h
@@ -34,7 +34,8 @@ extern unsigned long sub_reloc_offset(unsigned long);
34 */ 34 */
35#define machine_is_compatible(x) 0 35#define machine_is_compatible(x) 0
36#define of_find_compatible_node(f, t, c) NULL 36#define of_find_compatible_node(f, t, c) NULL
37#define get_property(p, n, l) NULL 37#define of_get_property(p, n, l) NULL
38#define get_property(a, b, c) of_get_property((a), (b), (c))
38 39
39#endif /* _PPC_PROM_H */ 40#endif /* _PPC_PROM_H */
40#endif /* __KERNEL__ */ 41#endif /* __KERNEL__ */
diff --git a/include/linux/pmu.h b/include/linux/pmu.h
index 783177387ac6..b0952e532ed5 100644
--- a/include/linux/pmu.h
+++ b/include/linux/pmu.h
@@ -168,24 +168,16 @@ extern int pmu_get_model(void);
168 168
169struct pmu_sleep_notifier 169struct pmu_sleep_notifier
170{ 170{
171 int (*notifier_call)(struct pmu_sleep_notifier *self, int when); 171 void (*notifier_call)(struct pmu_sleep_notifier *self, int when);
172 int priority; 172 int priority;
173 struct list_head list; 173 struct list_head list;
174}; 174};
175 175
176/* Code values for calling sleep/wakeup handlers 176/* Code values for calling sleep/wakeup handlers
177 *
178 * Note: If a sleep request got cancelled, all drivers will get
179 * the PBOOK_SLEEP_REJECT, even those who didn't get the PBOOK_SLEEP_REQUEST.
180 */ 177 */
181#define PBOOK_SLEEP_REQUEST 1 178#define PBOOK_SLEEP_REQUEST 1
182#define PBOOK_SLEEP_NOW 2 179#define PBOOK_SLEEP_NOW 2
183#define PBOOK_SLEEP_REJECT 3 180#define PBOOK_WAKE 3
184#define PBOOK_WAKE 4
185
186/* Result codes returned by the notifiers */
187#define PBOOK_SLEEP_OK 0
188#define PBOOK_SLEEP_REFUSE -1
189 181
190/* priority levels in notifiers */ 182/* priority levels in notifiers */
191#define SLEEP_LEVEL_VIDEO 100 /* Video driver (first wake) */ 183#define SLEEP_LEVEL_VIDEO 100 /* Video driver (first wake) */
diff --git a/sound/aoa/codecs/snd-aoa-codec-onyx.c b/sound/aoa/codecs/snd-aoa-codec-onyx.c
index b00fc4842c93..7f980be5d060 100644
--- a/sound/aoa/codecs/snd-aoa-codec-onyx.c
+++ b/sound/aoa/codecs/snd-aoa-codec-onyx.c
@@ -1062,9 +1062,9 @@ static int onyx_i2c_attach(struct i2c_adapter *adapter)
1062 1062
1063 while ((dev = of_get_next_child(busnode, dev)) != NULL) { 1063 while ((dev = of_get_next_child(busnode, dev)) != NULL) {
1064 if (device_is_compatible(dev, "pcm3052")) { 1064 if (device_is_compatible(dev, "pcm3052")) {
1065 u32 *addr; 1065 const u32 *addr;
1066 printk(KERN_DEBUG PFX "found pcm3052\n"); 1066 printk(KERN_DEBUG PFX "found pcm3052\n");
1067 addr = (u32 *) get_property(dev, "reg", NULL); 1067 addr = of_get_property(dev, "reg", NULL);
1068 if (!addr) 1068 if (!addr)
1069 return -ENODEV; 1069 return -ENODEV;
1070 return onyx_create(adapter, dev, (*addr)>>1); 1070 return onyx_create(adapter, dev, (*addr)>>1);
diff --git a/sound/aoa/codecs/snd-aoa-codec-tas.c b/sound/aoa/codecs/snd-aoa-codec-tas.c
index 2cd81fa07ce1..ceca38486eae 100644
--- a/sound/aoa/codecs/snd-aoa-codec-tas.c
+++ b/sound/aoa/codecs/snd-aoa-codec-tas.c
@@ -939,9 +939,9 @@ static int tas_i2c_attach(struct i2c_adapter *adapter)
939 939
940 while ((dev = of_get_next_child(busnode, dev)) != NULL) { 940 while ((dev = of_get_next_child(busnode, dev)) != NULL) {
941 if (device_is_compatible(dev, "tas3004")) { 941 if (device_is_compatible(dev, "tas3004")) {
942 u32 *addr; 942 const u32 *addr;
943 printk(KERN_DEBUG PFX "found tas3004\n"); 943 printk(KERN_DEBUG PFX "found tas3004\n");
944 addr = (u32 *) get_property(dev, "reg", NULL); 944 addr = of_get_property(dev, "reg", NULL);
945 if (!addr) 945 if (!addr)
946 continue; 946 continue;
947 return tas_create(adapter, dev, ((*addr) >> 1) & 0x7f); 947 return tas_create(adapter, dev, ((*addr) >> 1) & 0x7f);
@@ -950,9 +950,10 @@ static int tas_i2c_attach(struct i2c_adapter *adapter)
950 * property that says 'tas3004', they just have a 'deq' 950 * property that says 'tas3004', they just have a 'deq'
951 * node without any such property... */ 951 * node without any such property... */
952 if (strcmp(dev->name, "deq") == 0) { 952 if (strcmp(dev->name, "deq") == 0) {
953 u32 *_addr, addr; 953 const u32 *_addr;
954 u32 addr;
954 printk(KERN_DEBUG PFX "found 'deq' node\n"); 955 printk(KERN_DEBUG PFX "found 'deq' node\n");
955 _addr = (u32 *) get_property(dev, "i2c-address", NULL); 956 _addr = of_get_property(dev, "i2c-address", NULL);
956 if (!_addr) 957 if (!_addr)
957 continue; 958 continue;
958 addr = ((*_addr) >> 1) & 0x7f; 959 addr = ((*_addr) >> 1) & 0x7f;
diff --git a/sound/aoa/core/snd-aoa-gpio-feature.c b/sound/aoa/core/snd-aoa-gpio-feature.c
index 2b03bc798bcb..805dcbff2257 100644
--- a/sound/aoa/core/snd-aoa-gpio-feature.c
+++ b/sound/aoa/core/snd-aoa-gpio-feature.c
@@ -55,7 +55,7 @@ static struct device_node *get_gpio(char *name,
55 int *gpioactiveptr) 55 int *gpioactiveptr)
56{ 56{
57 struct device_node *np, *gpio; 57 struct device_node *np, *gpio;
58 u32 *reg; 58 const u32 *reg;
59 const char *audio_gpio; 59 const char *audio_gpio;
60 60
61 *gpioptr = -1; 61 *gpioptr = -1;
@@ -71,7 +71,7 @@ static struct device_node *get_gpio(char *name,
71 if (!gpio) 71 if (!gpio)
72 return NULL; 72 return NULL;
73 while ((np = of_get_next_child(gpio, np))) { 73 while ((np = of_get_next_child(gpio, np))) {
74 audio_gpio = get_property(np, "audio-gpio", NULL); 74 audio_gpio = of_get_property(np, "audio-gpio", NULL);
75 if (!audio_gpio) 75 if (!audio_gpio)
76 continue; 76 continue;
77 if (strcmp(audio_gpio, name) == 0) 77 if (strcmp(audio_gpio, name) == 0)
@@ -84,7 +84,7 @@ static struct device_node *get_gpio(char *name,
84 return NULL; 84 return NULL;
85 } 85 }
86 86
87 reg = (u32 *)get_property(np, "reg", NULL); 87 reg = of_get_property(np, "reg", NULL);
88 if (!reg) 88 if (!reg)
89 return NULL; 89 return NULL;
90 90
@@ -96,7 +96,7 @@ static struct device_node *get_gpio(char *name,
96 if (*gpioptr < 0x50) 96 if (*gpioptr < 0x50)
97 *gpioptr += 0x50; 97 *gpioptr += 0x50;
98 98
99 reg = (u32 *)get_property(np, "audio-gpio-active-state", NULL); 99 reg = of_get_property(np, "audio-gpio-active-state", NULL);
100 if (!reg) 100 if (!reg)
101 /* Apple seems to default to 1, but 101 /* Apple seems to default to 1, but
102 * that doesn't seem right at least on most 102 * that doesn't seem right at least on most
diff --git a/sound/aoa/fabrics/snd-aoa-fabric-layout.c b/sound/aoa/fabrics/snd-aoa-fabric-layout.c
index 1b94ba6dd279..98806283d1b2 100644
--- a/sound/aoa/fabrics/snd-aoa-fabric-layout.c
+++ b/sound/aoa/fabrics/snd-aoa-fabric-layout.c
@@ -724,7 +724,7 @@ static int check_codec(struct aoa_codec *codec,
724 struct layout_dev *ldev, 724 struct layout_dev *ldev,
725 struct codec_connect_info *cci) 725 struct codec_connect_info *cci)
726{ 726{
727 u32 *ref; 727 const u32 *ref;
728 char propname[32]; 728 char propname[32];
729 struct codec_connection *cc; 729 struct codec_connection *cc;
730 730
@@ -732,7 +732,7 @@ static int check_codec(struct aoa_codec *codec,
732 if (codec->node && (strcmp(codec->node->name, "codec") == 0)) { 732 if (codec->node && (strcmp(codec->node->name, "codec") == 0)) {
733 snprintf(propname, sizeof(propname), 733 snprintf(propname, sizeof(propname),
734 "platform-%s-codec-ref", codec->name); 734 "platform-%s-codec-ref", codec->name);
735 ref = (u32*)get_property(ldev->sound, propname, NULL); 735 ref = of_get_property(ldev->sound, propname, NULL);
736 if (!ref) { 736 if (!ref) {
737 printk(KERN_INFO "snd-aoa-fabric-layout: " 737 printk(KERN_INFO "snd-aoa-fabric-layout: "
738 "required property %s not present\n", propname); 738 "required property %s not present\n", propname);
@@ -946,7 +946,7 @@ static struct aoa_fabric layout_fabric = {
946static int aoa_fabric_layout_probe(struct soundbus_dev *sdev) 946static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
947{ 947{
948 struct device_node *sound = NULL; 948 struct device_node *sound = NULL;
949 unsigned int *layout_id; 949 const unsigned int *layout_id;
950 struct layout *layout; 950 struct layout *layout;
951 struct layout_dev *ldev = NULL; 951 struct layout_dev *ldev = NULL;
952 int err; 952 int err;
@@ -962,7 +962,7 @@ static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
962 } 962 }
963 if (!sound) return -ENODEV; 963 if (!sound) return -ENODEV;
964 964
965 layout_id = (unsigned int *) get_property(sound, "layout-id", NULL); 965 layout_id = of_get_property(sound, "layout-id", NULL);
966 if (!layout_id) 966 if (!layout_id)
967 goto outnodev; 967 goto outnodev;
968 printk(KERN_INFO "snd-aoa-fabric-layout: found bus with layout %d\n", 968 printk(KERN_INFO "snd-aoa-fabric-layout: found bus with layout %d\n",
diff --git a/sound/aoa/soundbus/core.c b/sound/aoa/soundbus/core.c
index 418a98a10c73..8b2e9b905cda 100644
--- a/sound/aoa/soundbus/core.c
+++ b/sound/aoa/soundbus/core.c
@@ -61,7 +61,7 @@ static int soundbus_uevent(struct device *dev, char **envp, int num_envp,
61{ 61{
62 struct soundbus_dev * soundbus_dev; 62 struct soundbus_dev * soundbus_dev;
63 struct of_device * of; 63 struct of_device * of;
64 char *compat; 64 const char *compat;
65 int retval = 0, i = 0, length = 0; 65 int retval = 0, i = 0, length = 0;
66 int cplen, seen = 0; 66 int cplen, seen = 0;
67 67
@@ -91,7 +91,7 @@ static int soundbus_uevent(struct device *dev, char **envp, int num_envp,
91 * it's not really legal to split it out with commas. We split it 91 * it's not really legal to split it out with commas. We split it
92 * up using a number of environment variables instead. */ 92 * up using a number of environment variables instead. */
93 93
94 compat = (char *) get_property(of->node, "compatible", &cplen); 94 compat = of_get_property(of->node, "compatible", &cplen);
95 while (compat && cplen > 0) { 95 while (compat && cplen > 0) {
96 int tmp = length; 96 int tmp = length;
97 retval = add_uevent_var(envp, num_envp, &i, 97 retval = add_uevent_var(envp, num_envp, &i,
diff --git a/sound/aoa/soundbus/i2sbus/i2sbus-core.c b/sound/aoa/soundbus/i2sbus/i2sbus-core.c
index e36f6aa448d4..79fc4bc09e5e 100644
--- a/sound/aoa/soundbus/i2sbus/i2sbus-core.c
+++ b/sound/aoa/soundbus/i2sbus/i2sbus-core.c
@@ -122,7 +122,7 @@ static int i2sbus_get_and_fixup_rsrc(struct device_node *np, int index,
122{ 122{
123 struct device_node *parent; 123 struct device_node *parent;
124 int pindex, rc = -ENXIO; 124 int pindex, rc = -ENXIO;
125 u32 *reg; 125 const u32 *reg;
126 126
127 /* Machines with layout 76 and 36 (K2 based) have a weird device 127 /* Machines with layout 76 and 36 (K2 based) have a weird device
128 * tree what we need to special case. 128 * tree what we need to special case.
@@ -141,7 +141,7 @@ static int i2sbus_get_and_fixup_rsrc(struct device_node *np, int index,
141 rc = of_address_to_resource(parent, pindex, res); 141 rc = of_address_to_resource(parent, pindex, res);
142 if (rc) 142 if (rc)
143 goto bail; 143 goto bail;
144 reg = (u32 *)get_property(np, "reg", NULL); 144 reg = of_get_property(np, "reg", NULL);
145 if (reg == NULL) { 145 if (reg == NULL) {
146 rc = -ENXIO; 146 rc = -ENXIO;
147 goto bail; 147 goto bail;
@@ -188,8 +188,8 @@ static int i2sbus_add_dev(struct macio_dev *macio,
188 } 188 }
189 } 189 }
190 if (i == 1) { 190 if (i == 1) {
191 u32 *layout_id; 191 const u32 *layout_id =
192 layout_id = (u32*) get_property(sound, "layout-id", NULL); 192 of_get_property(sound, "layout-id", NULL);
193 if (layout_id) { 193 if (layout_id) {
194 layout = *layout_id; 194 layout = *layout_id;
195 snprintf(dev->sound.modalias, 32, 195 snprintf(dev->sound.modalias, 32,
diff --git a/sound/oss/dmasound/dmasound_awacs.c b/sound/oss/dmasound/dmasound_awacs.c
index 37773b1deea5..730fa1d001a5 100644
--- a/sound/oss/dmasound/dmasound_awacs.c
+++ b/sound/oss/dmasound/dmasound_awacs.c
@@ -257,7 +257,7 @@ static volatile struct dbdma_cmd *emergency_dbdma_cmd;
257/* 257/*
258 * Stuff for restoring after a sleep. 258 * Stuff for restoring after a sleep.
259 */ 259 */
260static int awacs_sleep_notify(struct pmu_sleep_notifier *self, int when); 260static void awacs_sleep_notify(struct pmu_sleep_notifier *self, int when);
261struct pmu_sleep_notifier awacs_sleep_notifier = { 261struct pmu_sleep_notifier awacs_sleep_notifier = {
262 awacs_sleep_notify, SLEEP_LEVEL_SOUND, 262 awacs_sleep_notify, SLEEP_LEVEL_SOUND,
263}; 263};
@@ -346,36 +346,42 @@ int gpio_headphone_irq;
346int 346int
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 *gpiop;
349 struct device_node *np; 350 struct device_node *np;
350 const u32* pp; 351 const u32* pp;
352 int ret = -ENODEV;
351 353
352 np = find_devices("gpio"); 354 gpiop = of_find_node_by_name(NULL, "gpio");
353 if (!np) 355 if (!gpiop)
354 return -ENODEV; 356 goto done;
355 357
356 np = np->child; 358 np = of_get_next_child(gpiop, NULL);
357 while(np != 0) { 359 while(np != 0) {
358 if (name) { 360 if (name) {
359 const char *property = 361 const char *property =
360 get_property(np,"audio-gpio",NULL); 362 of_get_property(np,"audio-gpio",NULL);
361 if (property != 0 && strcmp(property,name) == 0) 363 if (property != 0 && strcmp(property,name) == 0)
362 break; 364 break;
363 } else if (compatible && device_is_compatible(np, compatible)) 365 } else if (compatible && device_is_compatible(np, compatible))
364 break; 366 break;
365 np = np->sibling; 367 np = of_get_next_child(gpiop, np);
366 } 368 }
367 if (!np) 369 if (!np)
368 return -ENODEV; 370 goto done;
369 pp = get_property(np, "AAPL,address", NULL); 371 pp = of_get_property(np, "AAPL,address", NULL);
370 if (!pp) 372 if (!pp)
371 return -ENODEV; 373 goto done;
372 *gpio_addr = (*pp) & 0x0000ffff; 374 *gpio_addr = (*pp) & 0x0000ffff;
373 pp = get_property(np, "audio-gpio-active-state", NULL); 375 pp = of_get_property(np, "audio-gpio-active-state", NULL);
374 if (pp) 376 if (pp)
375 *gpio_pol = *pp; 377 *gpio_pol = *pp;
376 else 378 else
377 *gpio_pol = 1; 379 *gpio_pol = 1;
378 return irq_of_parse_and_map(np, 0); 380 ret = irq_of_parse_and_map(np, 0);
381done:
382 of_node_put(np);
383 of_node_put(gpiop);
384 return ret;
379} 385}
380 386
381static inline void 387static inline void
@@ -578,7 +584,7 @@ tas_mixer_ioctl(u_int cmd, u_long arg)
578} 584}
579 585
580static void __init 586static void __init
581tas_init_frame_rates(unsigned int *prop, unsigned int l) 587tas_init_frame_rates(const unsigned int *prop, unsigned int l)
582{ 588{
583 int i ; 589 int i ;
584 if (prop) { 590 if (prop) {
@@ -1419,7 +1425,7 @@ load_awacs(void)
1419 * Save state when going to sleep, restore it afterwards. 1425 * Save state when going to sleep, restore it afterwards.
1420 */ 1426 */
1421/* FIXME: sort out disabling/re-enabling of read stuff as well */ 1427/* FIXME: sort out disabling/re-enabling of read stuff as well */
1422static int awacs_sleep_notify(struct pmu_sleep_notifier *self, int when) 1428static void awacs_sleep_notify(struct pmu_sleep_notifier *self, int when)
1423{ 1429{
1424 unsigned long flags; 1430 unsigned long flags;
1425 1431
@@ -1548,7 +1554,6 @@ static int awacs_sleep_notify(struct pmu_sleep_notifier *self, int when)
1548 spin_unlock_irqrestore(&dmasound.lock, flags); 1554 spin_unlock_irqrestore(&dmasound.lock, flags);
1549 UNLOCK(); 1555 UNLOCK();
1550 } 1556 }
1551 return PBOOK_SLEEP_OK;
1552} 1557}
1553#endif /* CONFIG_PM */ 1558#endif /* CONFIG_PM */
1554 1559
@@ -2553,32 +2558,33 @@ set_model(void)
2553static struct device_node* __init 2558static struct device_node* __init
2554get_snd_io_node(void) 2559get_snd_io_node(void)
2555{ 2560{
2556 struct device_node *np = NULL; 2561 struct device_node *np;
2557 2562
2558 /* set up awacs_node for early OF which doesn't have a full set of 2563 /* set up awacs_node for early OF which doesn't have a full set of
2559 * properties on davbus 2564 * properties on davbus
2560 */ 2565 */
2561 2566 awacs_node = of_find_node_by_name(NULL, "awacs");
2562 awacs_node = find_devices("awacs");
2563 if (awacs_node) 2567 if (awacs_node)
2564 awacs_revision = AWACS_AWACS; 2568 awacs_revision = AWACS_AWACS;
2565 2569
2566 /* powermac models after 9500 (other than those which use DACA or 2570 /* powermac models after 9500 (other than those which use DACA or
2567 * Tumbler) have a node called "davbus". 2571 * Tumbler) have a node called "davbus".
2568 */ 2572 */
2569 np = find_devices("davbus"); 2573 np = of_find_node_by_name(NULL, "davbus");
2570 /* 2574 /*
2571 * if we didn't find a davbus device, try 'i2s-a' since 2575 * if we didn't find a davbus device, try 'i2s-a' since
2572 * this seems to be what iBooks (& Tumbler) have. 2576 * this seems to be what iBooks (& Tumbler) have.
2573 */ 2577 */
2574 if (np == NULL) 2578 if (np == NULL) {
2575 np = i2s_node = find_devices("i2s-a"); 2579 i2s_node = of_find_node_by_name(NULL, "i2s-a");
2580 np = of_node_get(i2s_node);
2581 }
2576 2582
2577 /* if we didn't find this - perhaps we are on an early model 2583 /* if we didn't find this - perhaps we are on an early model
2578 * which _only_ has an 'awacs' node 2584 * which _only_ has an 'awacs' node
2579 */ 2585 */
2580 if (np == NULL && awacs_node) 2586 if (np == NULL && awacs_node)
2581 np = awacs_node ; 2587 np = of_node_get(awacs_node);
2582 2588
2583 /* if we failed all these return null - this will cause the 2589 /* if we failed all these return null - this will cause the
2584 * driver to give up... 2590 * driver to give up...
@@ -2597,9 +2603,9 @@ get_snd_info_node(struct device_node *io)
2597{ 2603{
2598 struct device_node *info; 2604 struct device_node *info;
2599 2605
2600 info = find_devices("sound"); 2606 for_each_node_by_name(info, "sound")
2601 while (info && info->parent != io) 2607 if (info->parent == io)
2602 info = info->next; 2608 break;
2603 return info; 2609 return info;
2604} 2610}
2605 2611
@@ -2635,11 +2641,17 @@ get_codec_type(struct device_node *info)
2635static void __init 2641static void __init
2636get_expansion_type(void) 2642get_expansion_type(void)
2637{ 2643{
2638 if (find_devices("perch") != NULL) 2644 struct device_node *dn;
2645
2646 dn = of_find_node_by_name(NULL, "perch");
2647 if (dn != NULL)
2639 has_perch = 1; 2648 has_perch = 1;
2649 of_node_put(dn);
2640 2650
2641 if (find_devices("pb-ziva-pc") != NULL) 2651 dn = of_find_node_by_name(NULL, "pb-ziva-pc");
2652 if (dn != NULL)
2642 has_ziva = 1; 2653 has_ziva = 1;
2654 of_node_put(dn);
2643 /* need to work out how we deal with iMac SRS module */ 2655 /* need to work out how we deal with iMac SRS module */
2644} 2656}
2645 2657
@@ -2652,7 +2664,7 @@ get_expansion_type(void)
2652*/ 2664*/
2653 2665
2654static void __init 2666static void __init
2655awacs_init_frame_rates(unsigned int *prop, unsigned int l) 2667awacs_init_frame_rates(const unsigned int *prop, unsigned int l)
2656{ 2668{
2657 int i ; 2669 int i ;
2658 if (prop) { 2670 if (prop) {
@@ -2675,7 +2687,7 @@ awacs_init_frame_rates(unsigned int *prop, unsigned int l)
2675} 2687}
2676 2688
2677static void __init 2689static void __init
2678burgundy_init_frame_rates(unsigned int *prop, unsigned int l) 2690burgundy_init_frame_rates(const unsigned int *prop, unsigned int l)
2679{ 2691{
2680 int temp[9] ; 2692 int temp[9] ;
2681 int i = 0 ; 2693 int i = 0 ;
@@ -2701,7 +2713,7 @@ if (i > 1){
2701} 2713}
2702 2714
2703static void __init 2715static void __init
2704daca_init_frame_rates(unsigned int *prop, unsigned int l) 2716daca_init_frame_rates(const unsigned int *prop, unsigned int l)
2705{ 2717{
2706 int temp[9] ; 2718 int temp[9] ;
2707 int i = 0 ; 2719 int i = 0 ;
@@ -2728,7 +2740,7 @@ if (i > 1){
2728} 2740}
2729 2741
2730static void __init 2742static void __init
2731init_frame_rates(unsigned int *prop, unsigned int l) 2743init_frame_rates(const unsigned int *prop, unsigned int l)
2732{ 2744{
2733 switch (awacs_revision) { 2745 switch (awacs_revision) {
2734 case AWACS_TUMBLER: 2746 case AWACS_TUMBLER:
@@ -2828,7 +2840,7 @@ int __init dmasound_awacs_init(void)
2828#ifdef DEBUG_DMASOUND 2840#ifdef DEBUG_DMASOUND
2829printk("dmasound_pmac: couldn't find sound io OF node\n"); 2841printk("dmasound_pmac: couldn't find sound io OF node\n");
2830#endif 2842#endif
2831 return -ENODEV ; 2843 goto no_device;
2832 } 2844 }
2833 2845
2834 /* find the OF node that tells us about the sound sub-system 2846 /* find the OF node that tells us about the sound sub-system
@@ -2840,7 +2852,7 @@ printk("dmasound_pmac: couldn't find sound io OF node\n");
2840#ifdef DEBUG_DMASOUND 2852#ifdef DEBUG_DMASOUND
2841printk("dmasound_pmac: couldn't find 'sound' OF node\n"); 2853printk("dmasound_pmac: couldn't find 'sound' OF node\n");
2842#endif 2854#endif
2843 return -ENODEV ; 2855 goto no_device;
2844 } 2856 }
2845 } 2857 }
2846 2858
@@ -2849,7 +2861,7 @@ printk("dmasound_pmac: couldn't find 'sound' OF node\n");
2849#ifdef DEBUG_DMASOUND 2861#ifdef DEBUG_DMASOUND
2850printk("dmasound_pmac: couldn't find a Codec we can handle\n"); 2862printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2851#endif 2863#endif
2852 return -ENODEV ; /* we don't know this type of h/w */ 2864 goto no_device; /* we don't know this type of h/w */
2853 } 2865 }
2854 2866
2855 /* set up perch, ziva, SRS or whatever else we have as sound 2867 /* set up perch, ziva, SRS or whatever else we have as sound
@@ -2867,11 +2879,12 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2867 * machines). 2879 * machines).
2868 */ 2880 */
2869 if (awacs_node) { 2881 if (awacs_node) {
2870 io = awacs_node ; 2882 of_node_put(io);
2883 io = of_node_get(awacs_node);
2871 if (of_get_address(io, 2, NULL, NULL) == NULL) { 2884 if (of_get_address(io, 2, NULL, NULL) == NULL) {
2872 printk("dmasound_pmac: can't use %s\n", 2885 printk("dmasound_pmac: can't use %s\n",
2873 io->full_name); 2886 io->full_name);
2874 return -ENODEV; 2887 goto no_device;
2875 } 2888 }
2876 } else 2889 } else
2877 printk("dmasound_pmac: can't use %s\n", io->full_name); 2890 printk("dmasound_pmac: can't use %s\n", io->full_name);
@@ -2882,7 +2895,7 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2882 awacs_rsrc[0].end - awacs_rsrc[0].start + 1, 2895 awacs_rsrc[0].end - awacs_rsrc[0].start + 1,
2883 " (IO)") == NULL) { 2896 " (IO)") == NULL) {
2884 printk(KERN_ERR "dmasound: can't request IO resource !\n"); 2897 printk(KERN_ERR "dmasound: can't request IO resource !\n");
2885 return -ENODEV; 2898 goto no_device;
2886 } 2899 }
2887 if (of_address_to_resource(io, 1, &awacs_rsrc[1]) || 2900 if (of_address_to_resource(io, 1, &awacs_rsrc[1]) ||
2888 request_mem_region(awacs_rsrc[1].start, 2901 request_mem_region(awacs_rsrc[1].start,
@@ -2891,7 +2904,7 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2891 release_mem_region(awacs_rsrc[0].start, 2904 release_mem_region(awacs_rsrc[0].start,
2892 awacs_rsrc[0].end - awacs_rsrc[0].start + 1); 2905 awacs_rsrc[0].end - awacs_rsrc[0].start + 1);
2893 printk(KERN_ERR "dmasound: can't request Tx DMA resource !\n"); 2906 printk(KERN_ERR "dmasound: can't request Tx DMA resource !\n");
2894 return -ENODEV; 2907 goto no_device;
2895 } 2908 }
2896 if (of_address_to_resource(io, 2, &awacs_rsrc[2]) || 2909 if (of_address_to_resource(io, 2, &awacs_rsrc[2]) ||
2897 request_mem_region(awacs_rsrc[2].start, 2910 request_mem_region(awacs_rsrc[2].start,
@@ -2902,7 +2915,7 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2902 release_mem_region(awacs_rsrc[1].start, 2915 release_mem_region(awacs_rsrc[1].start,
2903 awacs_rsrc[1].end - awacs_rsrc[1].start + 1); 2916 awacs_rsrc[1].end - awacs_rsrc[1].start + 1);
2904 printk(KERN_ERR "dmasound: can't request Rx DMA resource !\n"); 2917 printk(KERN_ERR "dmasound: can't request Rx DMA resource !\n");
2905 return -ENODEV; 2918 goto no_device;
2906 } 2919 }
2907 2920
2908 awacs_beep_dev = input_allocate_device(); 2921 awacs_beep_dev = input_allocate_device();
@@ -2914,7 +2927,7 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2914 release_mem_region(awacs_rsrc[2].start, 2927 release_mem_region(awacs_rsrc[2].start,
2915 awacs_rsrc[2].end - awacs_rsrc[2].start + 1); 2928 awacs_rsrc[2].end - awacs_rsrc[2].start + 1);
2916 printk(KERN_ERR "dmasound: can't allocate input device !\n"); 2929 printk(KERN_ERR "dmasound: can't allocate input device !\n");
2917 return -ENOMEM; 2930 goto no_device;
2918 } 2931 }
2919 2932
2920 awacs_beep_dev->name = "dmasound beeper"; 2933 awacs_beep_dev->name = "dmasound beeper";
@@ -2942,7 +2955,8 @@ printk("dmasound_pmac: couldn't find a Codec we can handle\n");
2942 awacs_rx_irq = irq_of_parse_and_map(io, 2); 2955 awacs_rx_irq = irq_of_parse_and_map(io, 2);
2943 2956
2944 /* Hack for legacy crap that will be killed someday */ 2957 /* Hack for legacy crap that will be killed someday */
2945 awacs_node = io; 2958 of_node_put(awacs_node);
2959 awacs_node = of_node_get(io);
2946 2960
2947 /* if we have an awacs or screamer - probe the chip to make 2961 /* if we have an awacs or screamer - probe the chip to make
2948 * sure we have the right revision. 2962 * sure we have the right revision.
@@ -2973,24 +2987,26 @@ printk("dmasound_pmac: Awacs/Screamer Codec Mfct: %d Rev %d\n", mfg, rev);
2973 */ 2987 */
2974 2988
2975 if (info) { 2989 if (info) {
2976 unsigned int *prop, l; 2990 const unsigned int *prop;
2991 unsigned int l;
2977 2992
2978 sound_device_id = 0; 2993 sound_device_id = 0;
2979 /* device ID appears post g3 b&w */ 2994 /* device ID appears post g3 b&w */
2980 prop = (unsigned int *)get_property(info, "device-id", NULL); 2995 prop = of_get_property(info, "device-id", NULL);
2981 if (prop != 0) 2996 if (prop != 0)
2982 sound_device_id = *prop; 2997 sound_device_id = *prop;
2983 2998
2984 /* look for a property saying what sample rates 2999 /* look for a property saying what sample rates
2985 are available */ 3000 are available */
2986 3001
2987 prop = (unsigned int *)get_property(info, "sample-rates", &l); 3002 prop = of_get_property(info, "sample-rates", &l);
2988 if (prop == 0) 3003 if (prop == 0)
2989 prop = (unsigned int *) get_property 3004 prop = of_get_property(info, "output-frame-rates", &l);
2990 (info, "output-frame-rates", &l);
2991 3005
2992 /* if it's there use it to set up frame rates */ 3006 /* if it's there use it to set up frame rates */
2993 init_frame_rates(prop, l) ; 3007 init_frame_rates(prop, l) ;
3008 of_node_put(info);
3009 info = NULL;
2994 } 3010 }
2995 3011
2996 if (awacs) 3012 if (awacs)
@@ -3160,7 +3176,16 @@ printk("dmasound_pmac: Awacs/Screamer Codec Mfct: %d Rev %d\n", mfg, rev);
3160 */ 3176 */
3161 input_register_device(awacs_beep_dev); 3177 input_register_device(awacs_beep_dev);
3162 3178
3179 of_node_put(io);
3180
3163 return dmasound_init(); 3181 return dmasound_init();
3182
3183no_device:
3184 of_node_put(info);
3185 of_node_put(awacs_node);
3186 of_node_put(i2s_node);
3187 of_node_put(io);
3188 return -ENODEV ;
3164} 3189}
3165 3190
3166static void __exit dmasound_awacs_cleanup(void) 3191static void __exit dmasound_awacs_cleanup(void)
@@ -3179,6 +3204,8 @@ static void __exit dmasound_awacs_cleanup(void)
3179 } 3204 }
3180 dmasound_deinit(); 3205 dmasound_deinit();
3181 3206
3207 of_node_put(awacs_node);
3208 of_node_put(i2s_node);
3182} 3209}
3183 3210
3184MODULE_DESCRIPTION("PowerMac built-in audio driver."); 3211MODULE_DESCRIPTION("PowerMac built-in audio driver.");
diff --git a/sound/oss/dmasound/tas_common.c b/sound/oss/dmasound/tas_common.c
index 665e85b5562b..b295ef682192 100644
--- a/sound/oss/dmasound/tas_common.c
+++ b/sound/oss/dmasound/tas_common.c
@@ -41,7 +41,6 @@
41 41
42static u8 tas_i2c_address = 0x34; 42static u8 tas_i2c_address = 0x34;
43static struct i2c_client *tas_client; 43static struct i2c_client *tas_client;
44static struct device_node* tas_node;
45 44
46static int tas_attach_adapter(struct i2c_adapter *); 45static int tas_attach_adapter(struct i2c_adapter *);
47static int tas_detach_client(struct i2c_client *); 46static int tas_detach_client(struct i2c_client *);
@@ -190,17 +189,18 @@ tas_cleanup(void)
190int __init 189int __init
191tas_init(int driver_id, const char *driver_name) 190tas_init(int driver_id, const char *driver_name)
192{ 191{
193 u32* paddr; 192 const u32* paddr;
193 struct device_node *tas_node;
194 194
195 printk(KERN_INFO "tas driver [%s])\n", driver_name); 195 printk(KERN_INFO "tas driver [%s])\n", driver_name);
196 196
197#ifndef CONFIG_I2C_POWERMAC 197#ifndef CONFIG_I2C_POWERMAC
198 request_module("i2c-powermac"); 198 request_module("i2c-powermac");
199#endif 199#endif
200 tas_node = find_devices("deq"); 200 tas_node = of_find_node_by_name("deq");
201 if (tas_node == NULL) 201 if (tas_node == NULL)
202 return -ENODEV; 202 return -ENODEV;
203 paddr = (u32 *)get_property(tas_node, "i2c-address", NULL); 203 paddr = of_get_property(tas_node, "i2c-address", NULL);
204 if (paddr) { 204 if (paddr) {
205 tas_i2c_address = (*paddr) >> 1; 205 tas_i2c_address = (*paddr) >> 1;
206 printk(KERN_INFO "using i2c address: 0x%x from device-tree\n", 206 printk(KERN_INFO "using i2c address: 0x%x from device-tree\n",
@@ -208,6 +208,7 @@ tas_init(int driver_id, const char *driver_name)
208 } else 208 } else
209 printk(KERN_INFO "using i2c address: 0x%x (default)\n", 209 printk(KERN_INFO "using i2c address: 0x%x (default)\n",
210 tas_i2c_address); 210 tas_i2c_address);
211 of_node_put(tas_node);
211 212
212 return i2c_add_driver(&tas_driver); 213 return i2c_add_driver(&tas_driver);
213} 214}
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index c64af55865d4..2bae9c1a2b54 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -816,6 +816,7 @@ static int snd_pmac_free(struct snd_pmac *chip)
816 816
817 if (chip->pdev) 817 if (chip->pdev)
818 pci_dev_put(chip->pdev); 818 pci_dev_put(chip->pdev);
819 of_node_put(chip->node);
819 kfree(chip); 820 kfree(chip);
820 return 0; 821 return 0;
821} 822}
@@ -863,8 +864,10 @@ static void __init detect_byte_swap(struct snd_pmac *chip)
863 */ 864 */
864static int __init snd_pmac_detect(struct snd_pmac *chip) 865static int __init snd_pmac_detect(struct snd_pmac *chip)
865{ 866{
866 struct device_node *sound = NULL; 867 struct device_node *sound;
867 unsigned int *prop, l; 868 struct device_node *dn;
869 const unsigned int *prop;
870 unsigned int l;
868 struct macio_chip* macio; 871 struct macio_chip* macio;
869 872
870 if (!machine_is(powermac)) 873 if (!machine_is(powermac))
@@ -890,22 +893,21 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
890 else if (machine_is_compatible("PowerBook1,1") 893 else if (machine_is_compatible("PowerBook1,1")
891 || machine_is_compatible("AAPL,PowerBook1998")) 894 || machine_is_compatible("AAPL,PowerBook1998"))
892 chip->is_pbook_G3 = 1; 895 chip->is_pbook_G3 = 1;
893 chip->node = find_devices("awacs"); 896 chip->node = of_find_node_by_name(NULL, "awacs");
894 if (chip->node) 897 sound = of_node_get(chip->node);
895 sound = chip->node;
896 898
897 /* 899 /*
898 * powermac G3 models have a node called "davbus" 900 * powermac G3 models have a node called "davbus"
899 * with a child called "sound". 901 * with a child called "sound".
900 */ 902 */
901 if (!chip->node) 903 if (!chip->node)
902 chip->node = find_devices("davbus"); 904 chip->node = of_find_node_by_name(NULL, "davbus");
903 /* 905 /*
904 * if we didn't find a davbus device, try 'i2s-a' since 906 * if we didn't find a davbus device, try 'i2s-a' since
905 * this seems to be what iBooks have 907 * this seems to be what iBooks have
906 */ 908 */
907 if (! chip->node) { 909 if (! chip->node) {
908 chip->node = find_devices("i2s-a"); 910 chip->node = of_find_node_by_name(NULL, "i2s-a");
909 if (chip->node && chip->node->parent && 911 if (chip->node && chip->node->parent &&
910 chip->node->parent->parent) { 912 chip->node->parent->parent) {
911 if (device_is_compatible(chip->node->parent->parent, 913 if (device_is_compatible(chip->node->parent->parent,
@@ -917,22 +919,25 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
917 return -ENODEV; 919 return -ENODEV;
918 920
919 if (!sound) { 921 if (!sound) {
920 sound = find_devices("sound"); 922 sound = of_find_node_by_name(NULL, "sound");
921 while (sound && sound->parent != chip->node) 923 while (sound && sound->parent != chip->node)
922 sound = sound->next; 924 sound = of_find_node_by_name(sound, "sound");
923 } 925 }
924 if (! sound) 926 if (! sound) {
927 of_node_put(chip->node);
925 return -ENODEV; 928 return -ENODEV;
926 prop = (unsigned int *) get_property(sound, "sub-frame", NULL); 929 }
930 prop = of_get_property(sound, "sub-frame", NULL);
927 if (prop && *prop < 16) 931 if (prop && *prop < 16)
928 chip->subframe = *prop; 932 chip->subframe = *prop;
929 prop = (unsigned int *) get_property(sound, "layout-id", NULL); 933 prop = of_get_property(sound, "layout-id", NULL);
930 if (prop) { 934 if (prop) {
931 /* partly deprecate snd-powermac, for those machines 935 /* partly deprecate snd-powermac, for those machines
932 * that have a layout-id property for now */ 936 * that have a layout-id property for now */
933 printk(KERN_INFO "snd-powermac no longer handles any " 937 printk(KERN_INFO "snd-powermac no longer handles any "
934 "machines with a layout-id property " 938 "machines with a layout-id property "
935 "in the device-tree, use snd-aoa.\n"); 939 "in the device-tree, use snd-aoa.\n");
940 of_node_put(chip->node);
936 return -ENODEV; 941 return -ENODEV;
937 } 942 }
938 /* This should be verified on older screamers */ 943 /* This should be verified on older screamers */
@@ -967,10 +972,12 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
967 chip->freq_table = tumbler_freqs; 972 chip->freq_table = tumbler_freqs;
968 chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */ 973 chip->control_mask = MASK_IEPC | 0x11; /* disable IEE */
969 } 974 }
970 prop = (unsigned int *)get_property(sound, "device-id", NULL); 975 prop = of_get_property(sound, "device-id", NULL);
971 if (prop) 976 if (prop)
972 chip->device_id = *prop; 977 chip->device_id = *prop;
973 chip->has_iic = (find_devices("perch") != NULL); 978 dn = of_find_node_by_name(NULL, "perch");
979 chip->has_iic = (dn != NULL);
980 of_node_put(dn);
974 981
975 /* We need the PCI device for DMA allocations, let's use a crude method 982 /* We need the PCI device for DMA allocations, let's use a crude method
976 * for now ... 983 * for now ...
@@ -997,10 +1004,9 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
997 1004
998 /* look for a property saying what sample rates 1005 /* look for a property saying what sample rates
999 are available */ 1006 are available */
1000 prop = (unsigned int *) get_property(sound, "sample-rates", &l); 1007 prop = of_get_property(sound, "sample-rates", &l);
1001 if (! prop) 1008 if (! prop)
1002 prop = (unsigned int *) get_property(sound, 1009 prop = of_get_property(sound, "output-frame-rates", &l);
1003 "output-frame-rates", &l);
1004 if (prop) { 1010 if (prop) {
1005 int i; 1011 int i;
1006 chip->freqs_ok = 0; 1012 chip->freqs_ok = 0;
@@ -1021,6 +1027,7 @@ static int __init snd_pmac_detect(struct snd_pmac *chip)
1021 chip->freqs_ok = 1; 1027 chip->freqs_ok = 1;
1022 } 1028 }
1023 1029
1030 of_node_put(sound);
1024 return 0; 1031 return 0;
1025} 1032}
1026 1033
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
index 8f074c7936e6..54e333fbb1d0 100644
--- a/sound/ppc/tumbler.c
+++ b/sound/ppc/tumbler.c
@@ -1031,32 +1031,40 @@ static irqreturn_t headphone_intr(int irq, void *devid)
1031/* look for audio-gpio device */ 1031/* look for audio-gpio device */
1032static struct device_node *find_audio_device(const char *name) 1032static struct device_node *find_audio_device(const char *name)
1033{ 1033{
1034 struct device_node *gpiop;
1034 struct device_node *np; 1035 struct device_node *np;
1035 1036
1036 if (! (np = find_devices("gpio"))) 1037 gpiop = of_find_node_by_name(NULL, "gpio");
1038 if (! gpiop)
1037 return NULL; 1039 return NULL;
1038 1040
1039 for (np = np->child; np; np = np->sibling) { 1041 for (np = of_get_next_child(gpiop, NULL); np;
1040 const char *property = get_property(np, "audio-gpio", NULL); 1042 np = of_get_next_child(gpiop, np)) {
1043 const char *property = of_get_property(np, "audio-gpio", NULL);
1041 if (property && strcmp(property, name) == 0) 1044 if (property && strcmp(property, name) == 0)
1042 return np; 1045 break;
1043 } 1046 }
1044 return NULL; 1047 of_node_put(gpiop);
1048 return np;
1045} 1049}
1046 1050
1047/* look for audio-gpio device */ 1051/* look for audio-gpio device */
1048static struct device_node *find_compatible_audio_device(const char *name) 1052static struct device_node *find_compatible_audio_device(const char *name)
1049{ 1053{
1054 struct device_node *gpiop;
1050 struct device_node *np; 1055 struct device_node *np;
1051 1056
1052 if (! (np = find_devices("gpio"))) 1057 gpiop = of_find_node_by_name(NULL, "gpio");
1058 if (!gpiop)
1053 return NULL; 1059 return NULL;
1054 1060
1055 for (np = np->child; np; np = np->sibling) { 1061 for (np = of_get_next_child(gpiop, NULL); np;
1062 np = of_get_next_child(gpiop, np)) {
1056 if (device_is_compatible(np, name)) 1063 if (device_is_compatible(np, name))
1057 return np; 1064 break;
1058 } 1065 }
1059 return NULL; 1066 of_node_put(gpiop);
1067 return np;
1060} 1068}
1061 1069
1062/* find an audio device and get its address */ 1070/* find an audio device and get its address */
@@ -1066,6 +1074,7 @@ static long tumbler_find_device(const char *device, const char *platform,
1066 struct device_node *node; 1074 struct device_node *node;
1067 const u32 *base; 1075 const u32 *base;
1068 u32 addr; 1076 u32 addr;
1077 long ret;
1069 1078
1070 if (is_compatible) 1079 if (is_compatible)
1071 node = find_compatible_audio_device(device); 1080 node = find_compatible_audio_device(device);
@@ -1077,12 +1086,13 @@ static long tumbler_find_device(const char *device, const char *platform,
1077 return -ENODEV; 1086 return -ENODEV;
1078 } 1087 }
1079 1088
1080 base = get_property(node, "AAPL,address", NULL); 1089 base = of_get_property(node, "AAPL,address", NULL);
1081 if (! base) { 1090 if (! base) {
1082 base = get_property(node, "reg", NULL); 1091 base = of_get_property(node, "reg", NULL);
1083 if (!base) { 1092 if (!base) {
1084 DBG("(E) cannot find address for device %s !\n", device); 1093 DBG("(E) cannot find address for device %s !\n", device);
1085 snd_printd("cannot find address for device %s\n", device); 1094 snd_printd("cannot find address for device %s\n", device);
1095 of_node_put(node);
1086 return -ENODEV; 1096 return -ENODEV;
1087 } 1097 }
1088 addr = *base; 1098 addr = *base;
@@ -1093,7 +1103,7 @@ static long tumbler_find_device(const char *device, const char *platform,
1093 1103
1094 gp->addr = addr & 0x0000ffff; 1104 gp->addr = addr & 0x0000ffff;
1095 /* Try to find the active state, default to 0 ! */ 1105 /* Try to find the active state, default to 0 ! */
1096 base = get_property(node, "audio-gpio-active-state", NULL); 1106 base = of_get_property(node, "audio-gpio-active-state", NULL);
1097 if (base) { 1107 if (base) {
1098 gp->active_state = *base; 1108 gp->active_state = *base;
1099 gp->active_val = (*base) ? 0x5 : 0x4; 1109 gp->active_val = (*base) ? 0x5 : 0x4;
@@ -1108,7 +1118,7 @@ static long tumbler_find_device(const char *device, const char *platform,
1108 * as we don't yet have an interpreter for these things 1118 * as we don't yet have an interpreter for these things
1109 */ 1119 */
1110 if (platform) 1120 if (platform)
1111 prop = get_property(node, platform, NULL); 1121 prop = of_get_property(node, platform, NULL);
1112 if (prop) { 1122 if (prop) {
1113 if (prop[3] == 0x9 && prop[4] == 0x9) { 1123 if (prop[3] == 0x9 && prop[4] == 0x9) {
1114 gp->active_val = 0xd; 1124 gp->active_val = 0xd;
@@ -1124,7 +1134,9 @@ static long tumbler_find_device(const char *device, const char *platform,
1124 DBG("(I) GPIO device %s found, offset: %x, active state: %d !\n", 1134 DBG("(I) GPIO device %s found, offset: %x, active state: %d !\n",
1125 device, gp->addr, gp->active_state); 1135 device, gp->addr, gp->active_state);
1126 1136
1127 return irq_of_parse_and_map(node, 0); 1137 ret = irq_of_parse_and_map(node, 0);
1138 of_node_put(node);
1139 return ret;
1128} 1140}
1129 1141
1130/* reset audio */ 1142/* reset audio */
@@ -1310,7 +1322,7 @@ int __init snd_pmac_tumbler_init(struct snd_pmac *chip)
1310{ 1322{
1311 int i, err; 1323 int i, err;
1312 struct pmac_tumbler *mix; 1324 struct pmac_tumbler *mix;
1313 u32 *paddr; 1325 const u32 *paddr;
1314 struct device_node *tas_node, *np; 1326 struct device_node *tas_node, *np;
1315 char *chipname; 1327 char *chipname;
1316 1328
@@ -1331,9 +1343,9 @@ int __init snd_pmac_tumbler_init(struct snd_pmac *chip)
1331 1343
1332 for (np = chip->node->child; np; np = np->sibling) { 1344 for (np = chip->node->child; np; np = np->sibling) {
1333 if (!strcmp(np->name, "sound")) { 1345 if (!strcmp(np->name, "sound")) {
1334 if (get_property(np, "has-anded-reset", NULL)) 1346 if (of_get_property(np, "has-anded-reset", NULL))
1335 mix->anded_reset = 1; 1347 mix->anded_reset = 1;
1336 if (get_property(np, "layout-id", NULL)) 1348 if (of_get_property(np, "layout-id", NULL))
1337 mix->reset_on_sleep = 0; 1349 mix->reset_on_sleep = 0;
1338 break; 1350 break;
1339 } 1351 }
@@ -1342,19 +1354,20 @@ int __init snd_pmac_tumbler_init(struct snd_pmac *chip)
1342 return err; 1354 return err;
1343 1355
1344 /* set up TAS */ 1356 /* set up TAS */
1345 tas_node = find_devices("deq"); 1357 tas_node = of_find_node_by_name(NULL, "deq");
1346 if (tas_node == NULL) 1358 if (tas_node == NULL)
1347 tas_node = find_devices("codec"); 1359 tas_node = of_find_node_by_name(NULL, "codec");
1348 if (tas_node == NULL) 1360 if (tas_node == NULL)
1349 return -ENODEV; 1361 return -ENODEV;
1350 1362
1351 paddr = (u32 *)get_property(tas_node, "i2c-address", NULL); 1363 paddr = of_get_property(tas_node, "i2c-address", NULL);
1352 if (paddr == NULL) 1364 if (paddr == NULL)
1353 paddr = (u32 *)get_property(tas_node, "reg", NULL); 1365 paddr = of_get_property(tas_node, "reg", NULL);
1354 if (paddr) 1366 if (paddr)
1355 mix->i2c.addr = (*paddr) >> 1; 1367 mix->i2c.addr = (*paddr) >> 1;
1356 else 1368 else
1357 mix->i2c.addr = TAS_I2C_ADDR; 1369 mix->i2c.addr = TAS_I2C_ADDR;
1370 of_node_put(tas_node);
1358 1371
1359 DBG("(I) TAS i2c address is: %x\n", mix->i2c.addr); 1372 DBG("(I) TAS i2c address is: %x\n", mix->i2c.addr);
1360 1373